@@ -74789,28 +74789,38 @@ static wc_test_ret_t aes_siv_negative_test(const AesSivTestVector* testVectors)
7478974789 byte computedCiphertext[82];
7479074790 byte computedPlaintext[82];
7479174791 byte siv[WC_AES_BLOCK_SIZE];
74792+ word32 j;
7479274793 wc_test_ret_t ret;
7479374794
7479474795 /* Negative test: corrupted SIV must be rejected with AES_SIV_AUTH_E. */
74795- ret = wc_AesSivEncrypt(testVectors[0 ].key, testVectors[0 ].keySz,
74796- testVectors[0 ].assoc1, testVectors[0 ].assoc1Sz,
74797- testVectors[0 ].nonce, testVectors[0 ].nonceSz,
74798- testVectors[0 ].plaintext,
74799- testVectors[0 ].plaintextSz, siv,
74796+ ret = wc_AesSivEncrypt(testVectors[5 ].key, testVectors[5 ].keySz,
74797+ testVectors[5 ].assoc1, testVectors[5 ].assoc1Sz,
74798+ testVectors[5 ].nonce, testVectors[5 ].nonceSz,
74799+ testVectors[5 ].plaintext,
74800+ testVectors[5 ].plaintextSz, siv,
7480074801 computedCiphertext);
7480174802 if (ret != 0) {
7480274803 return WC_TEST_RET_ENC_EC(ret);
7480374804 }
74805+ XMEMSET(computedPlaintext, 0xFF, sizeof(computedPlaintext));
7480474806 /* Corrupt one byte of the SIV tag. */
7480574807 siv[0] ^= 0x01;
74806- ret = wc_AesSivDecrypt(testVectors[0 ].key, testVectors[0 ].keySz,
74807- testVectors[0 ].assoc1, testVectors[0 ].assoc1Sz,
74808- testVectors[0 ].nonce, testVectors[0 ].nonceSz,
74809- computedCiphertext, testVectors[0 ].plaintextSz,
74808+ ret = wc_AesSivDecrypt(testVectors[5 ].key, testVectors[5 ].keySz,
74809+ testVectors[5 ].assoc1, testVectors[5 ].assoc1Sz,
74810+ testVectors[5 ].nonce, testVectors[5 ].nonceSz,
74811+ computedCiphertext, testVectors[5 ].plaintextSz,
7481074812 siv, computedPlaintext);
7481174813 if (ret != WC_NO_ERR_TRACE(AES_SIV_AUTH_E)) {
7481274814 return WC_TEST_RET_ENC_EC(ret);
7481374815 }
74816+ if (testVectors[5].plaintextSz == 0U) {
74817+ return WC_TEST_RET_ENC_NC;
74818+ }
74819+ for (j = 0; j < testVectors[5].plaintextSz; ++j) {
74820+ if (computedPlaintext[j] != 0) {
74821+ return WC_TEST_RET_ENC_NC;
74822+ }
74823+ }
7481474824 return 0;
7481574825}
7481674826
0 commit comments