decodeDetachedSignature maps the SigAlg value of a binding that carries a detached signature (HTTP-Redirect or HTTP-POST-SimpleSign) to an x509 signature algorithm, and decodes the base64 Signature value with enc.
(sigAlg, signature string, enc *base64.Encoding)
| 204 | // detached signature (HTTP-Redirect or HTTP-POST-SimpleSign) to an x509 |
| 205 | // signature algorithm, and decodes the base64 Signature value with enc. |
| 206 | func decodeDetachedSignature(sigAlg, signature string, enc *base64.Encoding) (x509.SignatureAlgorithm, []byte, error) { |
| 207 | algorithm, ok := redirectSignatureAlgorithms[sigAlg] |
| 208 | if !ok { |
| 209 | return x509.UnknownSignatureAlgorithm, nil, fmt.Errorf("unsupported signature algorithm %q", sigAlg) |
| 210 | } |
| 211 | |
| 212 | sig, err := enc.DecodeString(signature) |
| 213 | if err != nil { |
| 214 | return x509.UnknownSignatureAlgorithm, nil, fmt.Errorf("cannot decode signature: %w", err) |
| 215 | } |
| 216 | return algorithm, sig, nil |
| 217 | } |
| 218 | |
| 219 | // checkDetachedSignature returns nil if signature is a valid signature over |
| 220 | // signedContent, made with algorithm by the key of one of certs. Unless |
no outgoing calls