Prechádzať zdrojové kódy

add testvectors for smaller RC2 keysizes

originates from rfc2268

1 byte keylen is commented
Steffen Jaeckel 8 rokov pred
rodič
commit
952caf3cd7
1 zmenil súbory, kde vykonal 16 pridanie a 2 odobranie
  1. 16 2
      src/ciphers/rc2.c

+ 16 - 2
src/ciphers/rc2.c

@@ -288,12 +288,25 @@ int rc2_test(void)
         unsigned char key[16], pt[8], ct[8];
         unsigned char key[16], pt[8], ct[8];
    } tests[] = {
    } tests[] = {
 
 
+#if 0
+   { 1,
+     { 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+     { 0x61, 0xa8, 0xa2, 0x44, 0xad, 0xac, 0xcc, 0xf0 }
+   },
+#endif
+   { 7,
+     { 0x88, 0xbc, 0xa9, 0x0e, 0x90, 0x87, 0x5a, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+     { 0x6c, 0xcf, 0x43, 0x08, 0x97, 0x4c, 0x26, 0x7f }
+   },
    { 8,
    { 8,
      { 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      { 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
      { 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
      { 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
      { 0x30, 0x64, 0x9e, 0xdf, 0x9b, 0xe7, 0xd2, 0xc2 }
      { 0x30, 0x64, 0x9e, 0xdf, 0x9b, 0xe7, 0xd2, 0xc2 }
-
    },
    },
    { 16,
    { 16,
      { 0x88, 0xbc, 0xa9, 0x0e, 0x90, 0x87, 0x5a, 0x7f,
      { 0x88, 0xbc, 0xa9, 0x0e, 0x90, 0x87, 0x5a, 0x7f,
@@ -315,7 +328,8 @@ int rc2_test(void)
         rc2_ecb_encrypt(tests[x].pt, tmp[0], &skey);
         rc2_ecb_encrypt(tests[x].pt, tmp[0], &skey);
         rc2_ecb_decrypt(tmp[0], tmp[1], &skey);
         rc2_ecb_decrypt(tmp[0], tmp[1], &skey);
 
 
-        if (XMEMCMP(tmp[0], tests[x].ct, 8) != 0 || XMEMCMP(tmp[1], tests[x].pt, 8) != 0) {
+        if (compare_testvector(tmp[0], 8, tests[x].ct, 8, "RC2 CT", x) != 0 ||
+              compare_testvector(tmp[1], 8, tests[x].pt, 8, "RC2 PT", x) != 0) {
            return CRYPT_FAIL_TESTVECTOR;
            return CRYPT_FAIL_TESTVECTOR;
         }
         }