TestSimpleSignKnownAnswer pins the whole signing path: RSA PKCS#1 v1.5 is deterministic, so the Signature for a fixed message, relay state and key never changes.
(t *testing.T)
| 102 | // deterministic, so the Signature for a fixed message, relay state and key |
| 103 | // never changes. |
| 104 | func TestSimpleSignKnownAnswer(t *testing.T) { |
| 105 | e := spcovSetup(t) |
| 106 | ctx, err := dsig.NewSigningContext(e.idpKey, nil) |
| 107 | assert.NilError(t, err) |
| 108 | assert.NilError(t, ctx.SetSignatureMethod(dsig.RSASHA256SignatureMethod)) |
| 109 | sigAlg, signature, err := signSimpleSign(ctx, "SAMLResponse", []byte("<samlp:Response/>"), "token") |
| 110 | assert.NilError(t, err) |
| 111 | assert.Equal(t, sigAlg, dsig.RSASHA256SignatureMethod) |
| 112 | assert.Equal(t, signature, "AW4WbYmeV5ZjSdnxFUAouuzk3bMUZslSnPrukjUTYL7wQs7rX9JRVlPzpzRgFOHYpKtahC/XMRWMMC1PUZEKVfl2vNnC1V6XLcMAoZticUPTLvJaLJ0N7Ujek18gG1t6hvAwN+GaFezqwbdAQvjpuWzi1A32/n+Ax1QFT0txuuY=") |
| 113 | |
| 114 | // It is a plain RSA-SHA256 signature over the literal octet string. |
| 115 | sig, err := base64.StdEncoding.DecodeString(signature) |
| 116 | assert.NilError(t, err) |
| 117 | assert.NilError(t, e.idpCert.CheckSignature(x509.SHA256WithRSA, |
| 118 | []byte("SAMLResponse=<samlp:Response/>&RelayState=token&SigAlg=http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"), sig)) |
| 119 | } |
| 120 | |
| 121 | // otherKey returns a key that no test certificate trusts as the IDP's, and |
| 122 | // its certificate. |
nothing calls this directly
no test coverage detected