A sender of modified CBC ciphertexts must not learn from the error whether one failed on its padding or on the XML it decrypted to.
(t *testing.T)
| 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. |
| 29 | func TestDecryptionErrorsIndistinguishable(t *testing.T) { |
| 30 | e := spcovSetup(t) |
| 31 | parse := func(encrypted *etree.Element) error { |
| 32 | el := e.response().Element() |
| 33 | el.AddChild(encrypted) |
| 34 | _, err := e.sp.ParseXMLResponse(spcovSerialize(t, el), []string{spcovRequestID}, e.sp.AcsURL) |
| 35 | return spcovPrivateErr(t, err) |
| 36 | } |
| 37 | |
| 38 | plaintext := []byte("<!-- nothing -->") // 16 bytes, so 16 bytes of padding |
| 39 | badPadding := e.encryptedAssertion(t, plaintext) |
| 40 | withPaddingCount(t, badPadding, 16) |
| 41 | noRoot := e.encryptedAssertion(t, plaintext) |
| 42 | notXML := e.encryptedAssertion(t, []byte("<a>\x01</a>")) |
| 43 | unbalanced := e.encryptedAssertion(t, []byte("<a>")) |
| 44 | |
| 45 | const want = "failed to decrypt EncryptedAssertion: xmlenc: decryption failed" |
| 46 | for name, el := range map[string]*etree.Element{ |
| 47 | "bad padding": badPadding, |
| 48 | "no root": noRoot, |
| 49 | "not XML": notXML, |
| 50 | "unbalanced": unbalanced, |
| 51 | } { |
| 52 | assert.Check(t, is.Error(parse(el), want), name) |
| 53 | } |
| 54 | } |
nothing calls this directly
no test coverage detected