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

Method Decrypt

xmlenc/pubkey.go:96–122  ·  view source on GitHub ↗

Decrypt implements Decryptor. `key` must be an *rsa.PrivateKey.

(key interface{}, ciphertextEl *etree.Element)

Source from the content-addressed store, hash-verified

94
95// Decrypt implements Decryptor. `key` must be an *rsa.PrivateKey.
96func (e RSA) Decrypt(key interface{}, ciphertextEl *etree.Element) ([]byte, error) {
97 rsaKey, err := validateRSAKeyIfPresent(key, ciphertextEl)
98 if err != nil {
99 return nil, err
100 }
101
102 ciphertext, err := getCiphertext(ciphertextEl)
103 if err != nil {
104 return nil, err
105 }
106
107 {
108 digestMethodEl := ciphertextEl.FindElement("./EncryptionMethod/DigestMethod")
109 if digestMethodEl == nil {
110 e.DigestMethod = SHA1
111 } else {
112 hashAlgorithmStr := digestMethodEl.SelectAttrValue("Algorithm", "")
113 digestMethod, ok := digestMethods[hashAlgorithmStr]
114 if !ok {
115 return nil, ErrAlgorithmNotImplemented(hashAlgorithmStr)
116 }
117 e.DigestMethod = digestMethod
118 }
119 }
120
121 return e.keyDecrypter(e, rsaKey, ciphertext)
122}
123
124// OAEP returns a version of RSA that implements RSA in OAEP-MGF1P mode. By default
125// the block cipher used is AES-256 CBC and the digest method is SHA-256. You can

Callers

nothing calls this directly

Calls 3

validateRSAKeyIfPresentFunction · 0.85
getCiphertextFunction · 0.85

Tested by

no test coverage detected