MCPcopy Create free account
hub / github.com/SecurityInnovation/PGPy / decrypt_sk

Method decrypt_sk

pgpy/packet/packets.py:583–599  ·  view source on GitHub ↗
(self, passphrase)

Source from the content-addressed store, hash-verified

581 del packet[:ctend]
582
583 def decrypt_sk(self, passphrase):
584 # derive the first session key from our passphrase
585 sk = self.s2k.derive_key(passphrase)
586 del passphrase
587
588 # if there is no ciphertext, then the first session key is the session key being used
589 if len(self.ct) == 0:
590 return self.symalg, sk
591
592 # otherwise, we now need to decrypt the encrypted session key
593 m = bytearray(_decrypt(bytes(self.ct), sk, self.symalg))
594 del sk
595
596 symalg = SymmetricKeyAlgorithm(m[0])
597 del m[0]
598
599 return symalg, bytes(m)
600
601 def encrypt_sk(self, passphrase, sk):
602 # generate the salt and derive the key to encrypt sk with from it

Callers

nothing calls this directly

Calls 3

_decryptFunction · 0.85
derive_keyMethod · 0.45

Tested by

no test coverage detected