withPaddingCount sets the padding count, the last byte of the plaintext of the CBC encrypted assertion el, to 0 (which is never valid). from is the count the encryptor wrote. Changing a byte of the last ciphertext block but one changes the same byte of the last plaintext block.
(t *testing.T, el *etree.Element, from byte)
| 15 | // count the encryptor wrote. Changing a byte of the last ciphertext block but |
| 16 | // one changes the same byte of the last plaintext block. |
| 17 | func withPaddingCount(t *testing.T, el *etree.Element, from byte) { |
| 18 | t.Helper() |
| 19 | cipherValue := el.FindElement("./EncryptedData/CipherData/CipherValue") |
| 20 | assert.Assert(t, cipherValue != nil) |
| 21 | buf, err := base64.StdEncoding.DecodeString(strings.TrimSpace(cipherValue.Text())) |
| 22 | assert.NilError(t, err) |
| 23 | buf[len(buf)-16-1] ^= from |
| 24 | cipherValue.SetText(base64.StdEncoding.EncodeToString(buf)) |
| 25 | } |
| 26 | |
| 27 | // A sender of modified CBC ciphertexts must not learn from the error whether |
| 28 | // one failed on its padding or on the XML it decrypted to. |
no outgoing calls
no test coverage detected