diff options
Diffstat (limited to 'src/util/test_crypto_aes.c')
-rw-r--r-- | src/util/test_crypto_aes.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/util/test_crypto_aes.c b/src/util/test_crypto_aes.c index 968c7f40f..971e9afbe 100644 --- a/src/util/test_crypto_aes.c +++ b/src/util/test_crypto_aes.c | |||
@@ -39,22 +39,21 @@ testSymcipher () | |||
39 | char res[100]; | 39 | char res[100]; |
40 | 40 | ||
41 | GNUNET_CRYPTO_aes_create_session_key (&key); | 41 | GNUNET_CRYPTO_aes_create_session_key (&key); |
42 | size = GNUNET_CRYPTO_aes_encrypt (TESTSTRING, | 42 | size = |
43 | strlen (TESTSTRING) + 1, | 43 | GNUNET_CRYPTO_aes_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, &key, |
44 | &key, | 44 | (const struct |
45 | (const struct | 45 | GNUNET_CRYPTO_AesInitializationVector *) |
46 | GNUNET_CRYPTO_AesInitializationVector *) | 46 | INITVALUE, result); |
47 | INITVALUE, result); | ||
48 | if (size == -1) | 47 | if (size == -1) |
49 | { | 48 | { |
50 | printf ("symciphertest failed: encryptBlock returned %d\n", size); | 49 | printf ("symciphertest failed: encryptBlock returned %d\n", size); |
51 | return 1; | 50 | return 1; |
52 | } | 51 | } |
53 | size = GNUNET_CRYPTO_aes_decrypt (result, size, | 52 | size = |
54 | &key, | 53 | GNUNET_CRYPTO_aes_decrypt (result, size, &key, |
55 | (const struct | 54 | (const struct |
56 | GNUNET_CRYPTO_AesInitializationVector *) | 55 | GNUNET_CRYPTO_AesInitializationVector *) |
57 | INITVALUE, res); | 56 | INITVALUE, res); |
58 | if (strlen (TESTSTRING) + 1 != size) | 57 | if (strlen (TESTSTRING) + 1 != size) |
59 | { | 58 | { |
60 | printf ("symciphertest failed: decryptBlock returned %d\n", size); | 59 | printf ("symciphertest failed: decryptBlock returned %d\n", size); |
@@ -101,17 +100,15 @@ verifyCrypto () | |||
101 | 100 | ||
102 | if (ntohl (key.crc32) != (unsigned int) 38125195LL) | 101 | if (ntohl (key.crc32) != (unsigned int) 38125195LL) |
103 | { | 102 | { |
104 | printf ("Static key has different CRC: %u - %u\n", | 103 | printf ("Static key has different CRC: %u - %u\n", ntohl (key.crc32), |
105 | ntohl (key.crc32), key.crc32); | 104 | key.crc32); |
106 | 105 | ||
107 | ret = 1; | 106 | ret = 1; |
108 | goto error; | 107 | goto error; |
109 | } | 108 | } |
110 | 109 | ||
111 | if (GNUNET_CRYPTO_AES_KEY_LENGTH != | 110 | if (GNUNET_CRYPTO_AES_KEY_LENGTH != |
112 | GNUNET_CRYPTO_aes_encrypt (plain, | 111 | GNUNET_CRYPTO_aes_encrypt (plain, GNUNET_CRYPTO_AES_KEY_LENGTH, &key, |
113 | GNUNET_CRYPTO_AES_KEY_LENGTH, | ||
114 | &key, | ||
115 | (const struct | 112 | (const struct |
116 | GNUNET_CRYPTO_AesInitializationVector *) | 113 | GNUNET_CRYPTO_AesInitializationVector *) |
117 | "testtesttesttest", result)) | 114 | "testtesttesttest", result)) |
@@ -131,9 +128,7 @@ verifyCrypto () | |||
131 | res = GNUNET_malloc (GNUNET_CRYPTO_AES_KEY_LENGTH); | 128 | res = GNUNET_malloc (GNUNET_CRYPTO_AES_KEY_LENGTH); |
132 | 129 | ||
133 | if (GNUNET_CRYPTO_AES_KEY_LENGTH != | 130 | if (GNUNET_CRYPTO_AES_KEY_LENGTH != |
134 | GNUNET_CRYPTO_aes_decrypt (result, | 131 | GNUNET_CRYPTO_aes_decrypt (result, GNUNET_CRYPTO_AES_KEY_LENGTH, &key, |
135 | GNUNET_CRYPTO_AES_KEY_LENGTH, | ||
136 | &key, | ||
137 | (const struct | 132 | (const struct |
138 | GNUNET_CRYPTO_AesInitializationVector *) | 133 | GNUNET_CRYPTO_AesInitializationVector *) |
139 | "testtesttesttest", res)) | 134 | "testtesttesttest", res)) |