diff options
Diffstat (limited to 'src/util/crypto_aes.c')
-rw-r--r-- | src/util/crypto_aes.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/util/crypto_aes.c b/src/util/crypto_aes.c index 200c367c1..a984e17fc 100644 --- a/src/util/crypto_aes.c +++ b/src/util/crypto_aes.c | |||
@@ -73,12 +73,11 @@ GNUNET_CRYPTO_aes_check_session_key (const struct GNUNET_CRYPTO_AesSessionKey | |||
73 | * @returns the size of the encrypted block, -1 for errors | 73 | * @returns the size of the encrypted block, -1 for errors |
74 | */ | 74 | */ |
75 | ssize_t | 75 | ssize_t |
76 | GNUNET_CRYPTO_aes_encrypt (const void *block, | 76 | GNUNET_CRYPTO_aes_encrypt (const void *block, size_t len, |
77 | size_t len, | 77 | const struct GNUNET_CRYPTO_AesSessionKey * |
78 | const struct GNUNET_CRYPTO_AesSessionKey | 78 | sessionkey, |
79 | * sessionkey, | 79 | const struct GNUNET_CRYPTO_AesInitializationVector * |
80 | const struct GNUNET_CRYPTO_AesInitializationVector | 80 | iv, void *result) |
81 | * iv, void *result) | ||
82 | { | 81 | { |
83 | gcry_cipher_hd_t handle; | 82 | gcry_cipher_hd_t handle; |
84 | int rc; | 83 | int rc; |
@@ -89,9 +88,9 @@ GNUNET_CRYPTO_aes_encrypt (const void *block, | |||
89 | GNUNET_break (0); | 88 | GNUNET_break (0); |
90 | return -1; | 89 | return -1; |
91 | } | 90 | } |
92 | GNUNET_assert (0 == gcry_cipher_open (&handle, | 91 | GNUNET_assert (0 == |
93 | GCRY_CIPHER_AES256, | 92 | gcry_cipher_open (&handle, GCRY_CIPHER_AES256, |
94 | GCRY_CIPHER_MODE_CFB, 0)); | 93 | GCRY_CIPHER_MODE_CFB, 0)); |
95 | rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH); | 94 | rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH); |
96 | GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); | 95 | GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); |
97 | rc = gcry_cipher_setiv (handle, iv, | 96 | rc = gcry_cipher_setiv (handle, iv, |
@@ -115,12 +114,11 @@ GNUNET_CRYPTO_aes_encrypt (const void *block, | |||
115 | * @return -1 on failure, size of decrypted block on success | 114 | * @return -1 on failure, size of decrypted block on success |
116 | */ | 115 | */ |
117 | ssize_t | 116 | ssize_t |
118 | GNUNET_CRYPTO_aes_decrypt (const void *block, | 117 | GNUNET_CRYPTO_aes_decrypt (const void *block, size_t size, |
119 | size_t size, | 118 | const struct GNUNET_CRYPTO_AesSessionKey * |
120 | const struct GNUNET_CRYPTO_AesSessionKey | 119 | sessionkey, |
121 | * sessionkey, | 120 | const struct GNUNET_CRYPTO_AesInitializationVector * |
122 | const struct GNUNET_CRYPTO_AesInitializationVector | 121 | iv, void *result) |
123 | * iv, void *result) | ||
124 | { | 122 | { |
125 | gcry_cipher_hd_t handle; | 123 | gcry_cipher_hd_t handle; |
126 | int rc; | 124 | int rc; |
@@ -131,9 +129,9 @@ GNUNET_CRYPTO_aes_decrypt (const void *block, | |||
131 | GNUNET_break (0); | 129 | GNUNET_break (0); |
132 | return -1; | 130 | return -1; |
133 | } | 131 | } |
134 | GNUNET_assert (0 == gcry_cipher_open (&handle, | 132 | GNUNET_assert (0 == |
135 | GCRY_CIPHER_AES256, | 133 | gcry_cipher_open (&handle, GCRY_CIPHER_AES256, |
136 | GCRY_CIPHER_MODE_CFB, 0)); | 134 | GCRY_CIPHER_MODE_CFB, 0)); |
137 | rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH); | 135 | rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH); |
138 | GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); | 136 | GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); |
139 | rc = gcry_cipher_setiv (handle, iv, | 137 | rc = gcry_cipher_setiv (handle, iv, |