formating and sanity check on pointer with test case

This commit is contained in:
Jacob Barthelmeh
2018-08-01 11:57:36 -06:00
parent cb756397b3
commit ce5e787afc

View File

@ -6587,8 +6587,10 @@ Aes dec;
#endif #endif
if (result != 0) if (result != 0)
return -4702; return -4702;
if (XMEMCMP(cipher, resultC, cipherSz)) if (cipher != NULL) {
return -4703; if (XMEMCMP(cipher, resultC, cipherSz))
return -4703;
}
if (XMEMCMP(tag, resultT, tagSz)) if (XMEMCMP(tag, resultT, tagSz))
return -4704; return -4704;
@ -6606,8 +6608,10 @@ Aes dec;
#endif #endif
if (result != 0) if (result != 0)
return -4706; return -4706;
if (XMEMCMP(plain, resultP, plainSz)) if (plain != NULL) {
return -4707; if (XMEMCMP(plain, resultP, plainSz))
return -4707;
}
wc_AesFree(&dec); wc_AesFree(&dec);
#endif /* HAVE_AES_DECRYPT */ #endif /* HAVE_AES_DECRYPT */
@ -6621,82 +6625,82 @@ Aes dec;
* https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/CAVP-TESTING-BLOCK-CIPHER-MODES*/ * https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/CAVP-TESTING-BLOCK-CIPHER-MODES*/
int aesgcm_default_test(void) int aesgcm_default_test(void)
{ {
byte key1[] = { byte key1[] = {
0x29, 0x8e, 0xfa, 0x1c, 0xcf, 0x29, 0xcf, 0x62, 0x29, 0x8e, 0xfa, 0x1c, 0xcf, 0x29, 0xcf, 0x62,
0xae, 0x68, 0x24, 0xbf, 0xc1, 0x95, 0x57, 0xfc 0xae, 0x68, 0x24, 0xbf, 0xc1, 0x95, 0x57, 0xfc
}; };
byte iv1[] = { byte iv1[] = {
0x6f, 0x58, 0xa9, 0x3f, 0xe1, 0xd2, 0x07, 0xfa, 0x6f, 0x58, 0xa9, 0x3f, 0xe1, 0xd2, 0x07, 0xfa,
0xe4, 0xed, 0x2f, 0x6d 0xe4, 0xed, 0x2f, 0x6d
}; };
byte plain1[] = { byte plain1[] = {
0xcc, 0x38, 0xbc, 0xcd, 0x6b, 0xc5, 0x36, 0xad, 0xcc, 0x38, 0xbc, 0xcd, 0x6b, 0xc5, 0x36, 0xad,
0x91, 0x9b, 0x13, 0x95, 0xf5, 0xd6, 0x38, 0x01, 0x91, 0x9b, 0x13, 0x95, 0xf5, 0xd6, 0x38, 0x01,
0xf9, 0x9f, 0x80, 0x68, 0xd6, 0x5c, 0xa5, 0xac, 0xf9, 0x9f, 0x80, 0x68, 0xd6, 0x5c, 0xa5, 0xac,
0x63, 0x87, 0x2d, 0xaf, 0x16, 0xb9, 0x39, 0x01 0x63, 0x87, 0x2d, 0xaf, 0x16, 0xb9, 0x39, 0x01
}; };
byte aad1[] = { byte aad1[] = {
0x02, 0x1f, 0xaf, 0xd2, 0x38, 0x46, 0x39, 0x73, 0x02, 0x1f, 0xaf, 0xd2, 0x38, 0x46, 0x39, 0x73,
0xff, 0xe8, 0x02, 0x56, 0xe5, 0xb1, 0xc6, 0xb1 0xff, 0xe8, 0x02, 0x56, 0xe5, 0xb1, 0xc6, 0xb1
}; };
byte cipher1[] = { byte cipher1[] = {
0xdf, 0xce, 0x4e, 0x9c, 0xd2, 0x91, 0x10, 0x3d, 0xdf, 0xce, 0x4e, 0x9c, 0xd2, 0x91, 0x10, 0x3d,
0x7f, 0xe4, 0xe6, 0x33, 0x51, 0xd9, 0xe7, 0x9d, 0x7f, 0xe4, 0xe6, 0x33, 0x51, 0xd9, 0xe7, 0x9d,
0x3d, 0xfd, 0x39, 0x1e, 0x32, 0x67, 0x10, 0x46, 0x3d, 0xfd, 0x39, 0x1e, 0x32, 0x67, 0x10, 0x46,
0x58, 0x21, 0x2d, 0xa9, 0x65, 0x21, 0xb7, 0xdb 0x58, 0x21, 0x2d, 0xa9, 0x65, 0x21, 0xb7, 0xdb
}; };
byte tag1[] = { byte tag1[] = {
0x54, 0x24, 0x65, 0xef, 0x59, 0x93, 0x16, 0xf7, 0x54, 0x24, 0x65, 0xef, 0x59, 0x93, 0x16, 0xf7,
0x3a, 0x7a, 0x56, 0x05, 0x09, 0xa2, 0xd9, 0xf2 0x3a, 0x7a, 0x56, 0x05, 0x09, 0xa2, 0xd9, 0xf2
}; };
byte key2[] = { byte key2[] = {
0x01, 0x6d, 0xbb, 0x38, 0xda, 0xa7, 0x6d, 0xfe, 0x01, 0x6d, 0xbb, 0x38, 0xda, 0xa7, 0x6d, 0xfe,
0x7d, 0xa3, 0x84, 0xeb, 0xf1, 0x24, 0x03, 0x64 0x7d, 0xa3, 0x84, 0xeb, 0xf1, 0x24, 0x03, 0x64
}; };
byte iv2[] = { byte iv2[] = {
0x07, 0x93, 0xef, 0x3a, 0xda, 0x78, 0x2f, 0x78, 0x07, 0x93, 0xef, 0x3a, 0xda, 0x78, 0x2f, 0x78,
0xc9, 0x8a, 0xff, 0xe3 0xc9, 0x8a, 0xff, 0xe3
}; };
byte plain2[] = { byte plain2[] = {
0x4b, 0x34, 0xa9, 0xec, 0x57, 0x63, 0x52, 0x4b, 0x4b, 0x34, 0xa9, 0xec, 0x57, 0x63, 0x52, 0x4b,
0x19, 0x1d, 0x56, 0x16, 0xc5, 0x47, 0xf6, 0xb7 0x19, 0x1d, 0x56, 0x16, 0xc5, 0x47, 0xf6, 0xb7
}; };
byte cipher2[] = { byte cipher2[] = {
0x60, 0x9a, 0xa3, 0xf4, 0x54, 0x1b, 0xc0, 0xfe, 0x60, 0x9a, 0xa3, 0xf4, 0x54, 0x1b, 0xc0, 0xfe,
0x99, 0x31, 0xda, 0xad, 0x2e, 0xe1, 0x5d, 0x0c 0x99, 0x31, 0xda, 0xad, 0x2e, 0xe1, 0x5d, 0x0c
}; };
byte tag2[] = { byte tag2[] = {
0x33, 0xaf, 0xec, 0x59, 0xc4, 0x5b, 0xaf, 0x68, 0x33, 0xaf, 0xec, 0x59, 0xc4, 0x5b, 0xaf, 0x68,
0x9a, 0x5e, 0x1b, 0x13, 0xae, 0x42, 0x36, 0x19 0x9a, 0x5e, 0x1b, 0x13, 0xae, 0x42, 0x36, 0x19
}; };
byte key3[] = { byte key3[] = {
0xb0, 0x1e, 0x45, 0xcc, 0x30, 0x88, 0xaa, 0xba, 0xb0, 0x1e, 0x45, 0xcc, 0x30, 0x88, 0xaa, 0xba,
0x9f, 0xa4, 0x3d, 0x81, 0xd4, 0x81, 0x82, 0x3f 0x9f, 0xa4, 0x3d, 0x81, 0xd4, 0x81, 0x82, 0x3f
}; };
byte iv3[] = { byte iv3[] = {
0x5a, 0x2c, 0x4a, 0x66, 0x46, 0x87, 0x13, 0x45, 0x5a, 0x2c, 0x4a, 0x66, 0x46, 0x87, 0x13, 0x45,
0x6a, 0x4b, 0xd5, 0xe1 0x6a, 0x4b, 0xd5, 0xe1
}; };
byte tag3[] = { byte tag3[] = {
0x01, 0x42, 0x80, 0xf9, 0x44, 0xf5, 0x3c, 0x68, 0x01, 0x42, 0x80, 0xf9, 0x44, 0xf5, 0x3c, 0x68,
0x11, 0x64, 0xb2, 0xff 0x11, 0x64, 0xb2, 0xff
}; };
int ret; int ret;
ret = aesgcm_default_test_helper(key1, sizeof(key1), iv1, sizeof(iv1), ret = aesgcm_default_test_helper(key1, sizeof(key1), iv1, sizeof(iv1),
plain1, sizeof(plain1), cipher1, sizeof(cipher1), plain1, sizeof(plain1), cipher1, sizeof(cipher1),
aad1, sizeof(aad1), tag1, sizeof(tag1)); aad1, sizeof(aad1), tag1, sizeof(tag1));