[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r2673 - GNUnet/src/util
From: |
durner |
Subject: |
[GNUnet-SVN] r2673 - GNUnet/src/util |
Date: |
Thu, 27 Apr 2006 14:51:28 -0700 (PDT) |
Author: durner
Date: 2006-04-27 14:51:25 -0700 (Thu, 27 Apr 2006)
New Revision: 2673
Modified:
GNUnet/src/util/symciphertest.c
Log:
add test vector
Modified: GNUnet/src/util/symciphertest.c
===================================================================
--- GNUnet/src/util/symciphertest.c 2006-04-27 16:02:08 UTC (rev 2672)
+++ GNUnet/src/util/symciphertest.c 2006-04-27 21:51:25 UTC (rev 2673)
@@ -47,12 +47,75 @@
return 0;
}
+int verifyCrypto()
+{
+ SESSIONKEY key;
+ char *result, *res;
+ int ret;
+
+ unsigned char plain[] = {29, 128, 192, 253, 74, 171, 38, 187, 84, 219, 76,
76, 209, 118, 33, 249, 172, 124, 96, 9, 157, 110, 8, 215, 200, 63, 69, 230,
157, 104, 247, 164};
+ unsigned char raw_key[] = {106, 74, 209, 88, 145, 55, 189, 135, 125, 180,
225, 108, 183, 54, 25, 169, 129, 188, 131, 75, 227, 245, 105, 10, 225, 15, 115,
159, 148, 184, 34, 191};
+ unsigned char encrresult[] = {81, 81, 181, 234, 78, 198, 242, 124, 199, 59,
152, 213, 230, 76, 250, 135, 243, 23, 66, 130, 175, 146, 141, 172, 165, 82,
193, 236, 133, 145, 93, 37};
+
+ result = MALLOC(SESSIONKEY_LEN);
+ res = NULL;
+ ret = 0;
+
+ memcpy(key.key, raw_key, SESSIONKEY_LEN);
+ key.crc32 = htonl(crc32N(&key, SESSIONKEY_LEN));
+
+ if (key.crc32 != 2344502530)
+ {
+ printf("Static key has different CRC\n");
+
+ ret = 1;
+ goto error;
+ }
+
+ encryptBlock(plain,
+ SESSIONKEY_LEN,
+ &key,
+ (const INITVECTOR*) "test",
+ result);
+
+ if (memcmp(encrresult, result, SESSIONKEY_LEN) != 0)
+ {
+ printf("Encrypted result wrong.\n");
+
+ ret = 1;
+ goto error;
+ }
+
+ res = MALLOC(SESSIONKEY_LEN);
+
+ decryptBlock(&key,
+ result,
+ SESSIONKEY_LEN,
+ (const INITVECTOR*) "test",
+ res);
+
+ if (memcmp(res, plain, SESSIONKEY_LEN) != 0)
+ {
+ printf("Decrypted result does not match input.\n");
+
+ ret = 1;
+ }
+
+error:
+
+ FREE(result);
+ FREENONNULL(res);
+
+ return ret;
+}
+
int main(int argc, char * argv[]) {
int failureCount = 0;
GNUNET_ASSERT(strlen(INITVALUE) > sizeof(INITVECTOR));
initLockingGcrypt();
failureCount += testSymcipher();
+ failureCount += verifyCrypto();
doneLockingGcrypt();
if (failureCount == 0)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r2673 - GNUnet/src/util,
durner <=