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

Method _generate

pgpy/packet/fields.py:1526–1543  ·  view source on GitHub ↗
(self, oid)

Source from the content-addressed store, hash-verified

1524 self.chksum = bytearray(self.int_to_bytes(chs, 2))
1525
1526 def _generate(self, oid):
1527 if any(c != 0 for c in self): # pragma: no cover
1528 raise PGPError("Key is already populated!")
1529
1530 self.oid = EllipticCurveOID(oid)
1531
1532 if self.oid != EllipticCurveOID.Ed25519:
1533 raise ValueError("EdDSA only supported with {}".format(EllipticCurveOID.Ed25519))
1534
1535 pk = ed25519.Ed25519PrivateKey.generate()
1536 x = pk.public_key().public_bytes(encoding=serialization.Encoding.Raw, format=serialization.PublicFormat.Raw)
1537 self.p = ECPoint.from_values(self.oid.key_size, ECPointFormat.Native, x)
1538 self.s = MPI(self.bytes_to_int(pk.private_bytes(
1539 encoding=serialization.Encoding.Raw,
1540 format=serialization.PrivateFormat.Raw,
1541 encryption_algorithm=serialization.NoEncryption()
1542 )))
1543 self._compute_chksum()
1544
1545 def parse(self, packet):
1546 super(EdDSAPriv, self).parse(packet)

Callers

nothing calls this directly

Calls 6

_compute_chksumMethod · 0.95
PGPErrorClass · 0.85
EllipticCurveOIDClass · 0.85
MPIClass · 0.85
from_valuesMethod · 0.80
bytes_to_intMethod · 0.80

Tested by

no test coverage detected