MCPcopy Create free account
hub / github.com/crewjam/saml / defaultSigningMethodForKey

Function defaultSigningMethodForKey

samlsp/new.go:464–478  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
464func 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.

Callers 3

DefaultServiceProviderFunction · 0.85
checkSigningKeyFunction · 0.85

Calls 2

IsNilFunction · 0.92
PublicMethod · 0.45

Tested by 1