MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / decrypt_rsa_key

Function decrypt_rsa_key

keepercommander/api.py:159–176  ·  view source on GitHub ↗

Decrypt the RSA private key PKCS1 formatted private key, which is described by the ASN.1 type: RSAPrivateKey ::= SEQUENCE { version Version, modulus INTEGER, -- n publicExponent INTEGER, -- e privateExponent INTEGER, -- d

(encrypted_private_key, data_key)

Source from the content-addressed store, hash-verified

157
158
159def decrypt_rsa_key(encrypted_private_key, data_key):
160 """ Decrypt the RSA private key
161 PKCS1 formatted private key, which is described by the ASN.1 type:
162 RSAPrivateKey ::= SEQUENCE {
163 version Version,
164 modulus INTEGER, -- n
165 publicExponent INTEGER, -- e
166 privateExponent INTEGER, -- d
167 prime1 INTEGER, -- p
168 prime2 INTEGER, -- q
169 exponent1 INTEGER, -- d mod (p-1)
170 exponent2 INTEGER, -- d mod (q-1)
171 coefficient INTEGER, -- (inverse of q) mod p
172 otherPrimeInfos OtherPrimeInfos OPTIONAL
173 }
174 """
175 decoded_data = utils.base64_url_decode(encrypted_private_key)
176 return RSA.importKey(crypto.decrypt_aes_v1(decoded_data, data_key))
177
178
179def get_record(params, record_uid):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected