File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17094,10 +17094,14 @@ static WARN_UNUSED_RESULT int AesSivCipher(
1709417094 WOLFSSL_MSG("S2V failed.");
1709517095 }
1709617096
17097- if (ConstantCompare(siv, sivTmp, WC_AES_BLOCK_SIZE) != 0) {
17097+ if (ret == 0 && ConstantCompare(siv, sivTmp, WC_AES_BLOCK_SIZE) != 0) {
1709817098 WOLFSSL_MSG("Computed SIV doesn't match received SIV.");
1709917099 ret = AES_SIV_AUTH_E;
1710017100 }
17101+
17102+ if (ret != 0) {
17103+ ForceZero(out, dataSz);
17104+ }
1710117105 }
1710217106
1710317107 #ifdef WOLFSSL_SMALL_STACK
Original file line number Diff line number Diff line change @@ -74789,6 +74789,7 @@ 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. */
@@ -74801,6 +74802,7 @@ static wc_test_ret_t aes_siv_negative_test(const AesSivTestVector* testVectors)
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;
7480674808 ret = wc_AesSivDecrypt(testVectors[0].key, testVectors[0].keySz,
@@ -74811,6 +74813,11 @@ static wc_test_ret_t aes_siv_negative_test(const AesSivTestVector* testVectors)
7481174813 if (ret != WC_NO_ERR_TRACE(AES_SIV_AUTH_E)) {
7481274814 return WC_TEST_RET_ENC_EC(ret);
7481374815 }
74816+ for (j = 0; j < testVectors[0].plaintextSz; ++j) {
74817+ if (computedPlaintext[j] != 0) {
74818+ return WC_TEST_RET_ENC_NC;
74819+ }
74820+ }
7481474821 return 0;
7481574822}
7481674823
You can’t perform that action at this time.
0 commit comments