aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-09-05 20:38:19 +0000
committerChristian Grothoff <christian@grothoff.org>2009-09-05 20:38:19 +0000
commitba388145e2a982d25fb27af1ea80231625f56ded (patch)
tree40bd24f260d35f2d5018bcbbc43ea770e1f56d2b /src
parent32e19a47f4e6bd369e99e3d292be7b01c009edac (diff)
downloadgnunet-ba388145e2a982d25fb27af1ea80231625f56ded.tar.gz
gnunet-ba388145e2a982d25fb27af1ea80231625f56ded.zip
cleaner crypto api
Diffstat (limited to 'src')
-rw-r--r--src/core/gnunet-service-core.c6
-rw-r--r--src/include/gnunet_crypto_lib.h9
-rw-r--r--src/util/crypto_aes.c10
-rw-r--r--src/util/test_crypto_aes.c12
-rw-r--r--src/util/test_crypto_aes_weak.c2
5 files changed, 20 insertions, 19 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index ec2f08f65..4012ac3a8 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -1264,10 +1264,10 @@ do_decrypt (struct Neighbour *n,
1264 return GNUNET_SYSERR; 1264 return GNUNET_SYSERR;
1265 } 1265 }
1266 if (size != 1266 if (size !=
1267 GNUNET_CRYPTO_aes_decrypt (&n->decrypt_key, 1267 GNUNET_CRYPTO_aes_decrypt (in,
1268 in,
1269 (uint16_t) size, 1268 (uint16_t) size,
1270 (const struct 1269 &n->decrypt_key,
1270 (const struct
1271 GNUNET_CRYPTO_AesInitializationVector *) iv, 1271 GNUNET_CRYPTO_AesInitializationVector *) iv,
1272 out)) 1272 out))
1273 { 1273 {
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 168c79b2a..396f47355 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -273,17 +273,16 @@ int GNUNET_CRYPTO_aes_encrypt (const void *block,
273/** 273/**
274 * Decrypt a given block with the sessionkey. 274 * Decrypt a given block with the sessionkey.
275 * 275 *
276 * @param sessionkey the key used to decrypt
277 * @param block the data to decrypt, encoded as returned by encrypt 276 * @param block the data to decrypt, encoded as returned by encrypt
278 * @param size how big is the block? 277 * @param size how big is the block?
278 * @param sessionkey the key used to decrypt
279 * @param iv the initialization vector to use 279 * @param iv the initialization vector to use
280 * @param result address to store the result at 280 * @param result address to store the result at
281 * @return -1 on failure, size of decrypted block on success 281 * @return -1 on failure, size of decrypted block on success
282 */ 282 */
283int GNUNET_CRYPTO_aes_decrypt (const struct GNUNET_CRYPTO_AesSessionKey 283int GNUNET_CRYPTO_aes_decrypt (const void *block, uint16_t size,
284 *sessionkey, const void *block, uint16_t size, 284 const struct GNUNET_CRYPTO_AesSessionKey *sessionkey,
285 const struct 285 const struct GNUNET_CRYPTO_AesInitializationVector *iv,
286 GNUNET_CRYPTO_AesInitializationVector *iv,
287 void *result); 286 void *result);
288 287
289 288
diff --git a/src/util/crypto_aes.c b/src/util/crypto_aes.c
index 28a65dfca..8fa935d9f 100644
--- a/src/util/crypto_aes.c
+++ b/src/util/crypto_aes.c
@@ -106,18 +106,20 @@ GNUNET_CRYPTO_aes_encrypt (const void *block,
106 106
107/** 107/**
108 * Decrypt a given block with the sessionkey. 108 * Decrypt a given block with the sessionkey.
109 * @param sessionkey the key used to decrypt 109 *
110 * @param block the data to decrypt, encoded as returned by encrypt 110 * @param block the data to decrypt, encoded as returned by encrypt
111 * @param size the size of the block to decrypt 111 * @param size the size of the block to decrypt
112 * @param sessionkey the key used to decrypt
112 * @param iv the initialization vector to use, use INITVALUE 113 * @param iv the initialization vector to use, use INITVALUE
113 * for streams. 114 * for streams.
114 * @param result address to store the result at 115 * @param result address to store the result at
115 * @return -1 on failure, size of decrypted block on success 116 * @return -1 on failure, size of decrypted block on success
116 */ 117 */
117int 118int
118GNUNET_CRYPTO_aes_decrypt (const struct GNUNET_CRYPTO_AesSessionKey 119GNUNET_CRYPTO_aes_decrypt (const void *block, uint16_t size,
119 *sessionkey, const void *block, uint16_t size, 120 const struct GNUNET_CRYPTO_AesSessionKey
120 const struct GNUNET_CRYPTO_AesInitializationVector 121 *sessionkey,
122 const struct GNUNET_CRYPTO_AesInitializationVector
121 *iv, void *result) 123 *iv, void *result)
122{ 124{
123 gcry_cipher_hd_t handle; 125 gcry_cipher_hd_t handle;
diff --git a/src/util/test_crypto_aes.c b/src/util/test_crypto_aes.c
index cdae243e0..f876e4175 100644
--- a/src/util/test_crypto_aes.c
+++ b/src/util/test_crypto_aes.c
@@ -50,9 +50,9 @@ testSymcipher ()
50 printf ("symciphertest failed: encryptBlock returned %d\n", size); 50 printf ("symciphertest failed: encryptBlock returned %d\n", size);
51 return 1; 51 return 1;
52 } 52 }
53 size = GNUNET_CRYPTO_aes_decrypt (&key, 53 size = GNUNET_CRYPTO_aes_decrypt (result, size,
54 result, size, 54 &key,
55 (const struct 55 (const struct
56 GNUNET_CRYPTO_AesInitializationVector *) 56 GNUNET_CRYPTO_AesInitializationVector *)
57 INITVALUE, res); 57 INITVALUE, res);
58 if (strlen (TESTSTRING) + 1 != size) 58 if (strlen (TESTSTRING) + 1 != size)
@@ -131,10 +131,10 @@ verifyCrypto ()
131 res = GNUNET_malloc (GNUNET_CRYPTO_AES_KEY_LENGTH); 131 res = GNUNET_malloc (GNUNET_CRYPTO_AES_KEY_LENGTH);
132 132
133 if (GNUNET_CRYPTO_AES_KEY_LENGTH != 133 if (GNUNET_CRYPTO_AES_KEY_LENGTH !=
134 GNUNET_CRYPTO_aes_decrypt (&key, 134 GNUNET_CRYPTO_aes_decrypt (result,
135 result,
136 GNUNET_CRYPTO_AES_KEY_LENGTH, 135 GNUNET_CRYPTO_AES_KEY_LENGTH,
137 (const struct 136 &key,
137 (const struct
138 GNUNET_CRYPTO_AesInitializationVector *) 138 GNUNET_CRYPTO_AesInitializationVector *)
139 "testtesttesttest", res)) 139 "testtesttesttest", res))
140 { 140 {
diff --git a/src/util/test_crypto_aes_weak.c b/src/util/test_crypto_aes_weak.c
index 27ee57968..2ce553a21 100644
--- a/src/util/test_crypto_aes_weak.c
+++ b/src/util/test_crypto_aes_weak.c
@@ -103,7 +103,7 @@ testWeakKey ()
103 return 1; 103 return 1;
104 } 104 }
105 105
106 size = GNUNET_CRYPTO_aes_decrypt (&weak_key, result, size, &INITVALUE, res); 106 size = GNUNET_CRYPTO_aes_decrypt (result, size, &weak_key, &INITVALUE, res);
107 107
108 if ((strlen (WEAK_KEY_TESTSTRING) + 1) != size) 108 if ((strlen (WEAK_KEY_TESTSTRING) + 1) != size)
109 { 109 {