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

Method derive_key

pgpy/packet/fields.py:1124–1138  ·  view source on GitHub ↗
(self, s, curve, pkalg, fingerprint)

Source from the content-addressed store, hash-verified

1122 del packet[0]
1123
1124 def derive_key(self, s, curve, pkalg, fingerprint):
1125 # wrapper around the Concatenation KDF method provided by cryptography
1126 # assemble the additional data as defined in RFC 6637:
1127 # Param = curve_OID_len || curve_OID || public_key_alg_ID || 03 || 01 || KDF_hash_ID || KEK_alg_ID for AESKeyWrap || "Anonymous
1128 data = bytearray()
1129 data += encoder.encode(curve.value)[1:]
1130 data.append(pkalg)
1131 data += b'\x03\x01'
1132 data.append(self.halg)
1133 data.append(self.encalg)
1134 data += b'Anonymous Sender '
1135 data += binascii.unhexlify(fingerprint.replace(' ', ''))
1136
1137 ckdf = ConcatKDFHash(algorithm=getattr(hashes, self.halg.name)(), length=self.encalg.key_size // 8, otherinfo=bytes(data), backend=default_backend())
1138 return ckdf.derive(s)
1139
1140
1141class PrivKey(PubKey):

Callers 6

encrypt_keyblobMethod · 0.45
decrypt_keyblobMethod · 0.45
encryptMethod · 0.45
decryptMethod · 0.45
decrypt_skMethod · 0.45
encrypt_skMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected