@@ -35075,7 +35075,6 @@ static int test_pkcs7_padding(void)
3507535075 int outSz;
3507635076 int ctOff = -1;
3507735077 int ctLen = 0;
35078- int i;
3507935078
3508035079 XMEMSET(key, 0xAA, sizeof(key));
3508135080 XMEMSET(plaintext, 'X', sizeof(plaintext));
@@ -35098,32 +35097,10 @@ static int test_pkcs7_padding(void)
3509835097 (word32)encodedSz, output, sizeof(output)), (int)sizeof(plaintext));
3509935098 wc_PKCS7_Free(&pkcs7);
3510035099
35101- /* Find ciphertext block in encoded DER */
35102- if (EXPECT_SUCCESS()) {
35103- for (i = encodedSz - 10; i > 10; i--) {
35104- if (encoded[i] == 0x04 || encoded[i] == 0x80) {
35105- int len, lbytes;
35106-
35107- if (encoded[i+1] < 0x80) {
35108- len = encoded[i+1]; lbytes = 1;
35109- }
35110- else if (encoded[i+1] == 0x81) {
35111- len = encoded[i+2]; lbytes = 2;
35112- }
35113- else {
35114- continue;
35115- }
35116- if (len > 0 && len % 16 == 0 &&
35117- i + 1 + lbytes + len <= encodedSz) {
35118- ctOff = i + 1 + lbytes;
35119- ctLen = len;
35120- break;
35121- }
35122- }
35123- }
35124- }
35125- ExpectIntGT(ctOff, 0);
35126- ExpectIntGE(ctLen, 32);
35100+ /* encryptedContent is the last element in the DER, so it ends at encodedSz;
35101+ * 27-byte plaintext -> 32-byte AES-256-CBC ciphertext. */
35102+ ctLen = 32;
35103+ ctOff = encodedSz - ctLen;
3512735104
3512835105 /* Corrupt an interior padding byte via CBC bit-flip */
3512935106 if (EXPECT_SUCCESS()) {
0 commit comments