defaultSigningMethodForKey returns the signature method used for signed requests when Options.SignRequest is set. SHA-1 based methods are deprecated for XML signatures, so SHA-256 is used for both RSA and ECDSA keys. Callers that need a different method can set ServiceProvider.SignatureMethod on the
(key crypto.Signer)
| 462 | // It returns "" for a nil key and for a key type XML signatures cannot use, |
| 463 | // such as Ed25519; New refuses such a key when signing is requested. |
| 464 | func defaultSigningMethodForKey(key crypto.Signer) string { |
| 465 | if signerutil.IsNil(key) { |
| 466 | return "" |
| 467 | } |
| 468 | // Check public key type to support crypto.Signer implementations (KMS/HSM) |
| 469 | // that aren't concrete *rsa.PrivateKey or *ecdsa.PrivateKey types |
| 470 | switch key.Public().(type) { |
| 471 | case *rsa.PublicKey: |
| 472 | return dsig.RSASHA256SignatureMethod |
| 473 | case *ecdsa.PublicKey: |
| 474 | return dsig.ECDSASHA256SignatureMethod |
| 475 | default: |
| 476 | return "" |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | // checkSigningKey returns an error if opts asks for signed requests or |
| 481 | // logout messages but opts.Key cannot make XML signatures. |