Skip to content

Latest commit

 

History

History
162 lines (109 loc) · 5.35 KB

File metadata and controls

162 lines (109 loc) · 5.35 KB

Ed448 signing

cryptography.hazmat.primitives.asymmetric.ed448

Ed448 is an elliptic curve signing algorithm using EdDSA.

Signing & Verification

>>> from cryptography.hazmat.primitives.asymmetric.ed448 import Ed448PrivateKey >>> private_key = Ed448PrivateKey.generate() >>> signature = private_key.sign(b"my authenticated message") >>> public_key = private_key.public_key() >>> # Raises InvalidSignature if verification fails >>> public_key.verify(signature, b"my authenticated message")

Key interfaces

2.6

generate()

Generate an Ed448 private key.

returns

Ed448PrivateKey

from_private_bytes(data)

param data

57 byte private key.

type data

bytes-like

returns

Ed448PrivateKey

public_key()

returns

Ed448PublicKey

sign(data)

param data

The data to sign.

type data

bytes-like

returns bytes

The 114 byte signature.

private_bytes(encoding, format, encryption_algorithm)

Allows serialization of the key to bytes. Encoding ( ~cryptography.hazmat.primitives.serialization.Encoding.PEM, ~cryptography.hazmat.primitives.serialization.Encoding.DER, or ~cryptography.hazmat.primitives.serialization.Encoding.Raw) and format ( ~cryptography.hazmat.primitives.serialization.PrivateFormat.PKCS8 or ~cryptography.hazmat.primitives.serialization.PrivateFormat.Raw ) are chosen to define the exact serialization.

param encoding

A value from the ~cryptography.hazmat.primitives.serialization.Encoding enum.

param format

A value from the ~cryptography.hazmat.primitives.serialization.PrivateFormat enum. If the encoding is ~cryptography.hazmat.primitives.serialization.Encoding.Raw then format must be ~cryptography.hazmat.primitives.serialization.PrivateFormat.Raw , otherwise it must be ~cryptography.hazmat.primitives.serialization.PrivateFormat.PKCS8.

param encryption_algorithm

An instance of an object conforming to the ~cryptography.hazmat.primitives.serialization.KeySerializationEncryption interface.

return bytes

Serialized key.

private_bytes_raw()

40

Allows serialization of the key to raw bytes. This method is a convenience shortcut for calling private_bytes with ~cryptography.hazmat.primitives.serialization.Encoding.Raw encoding, ~cryptography.hazmat.primitives.serialization.PrivateFormat.Raw format, and ~cryptography.hazmat.primitives.serialization.NoEncryption.

return bytes

Raw key.

2.6

from_public_bytes(data)

param bytes data

57 byte public key.

returns

Ed448PublicKey

public_bytes(encoding, format)

Allows serialization of the key to bytes. Encoding ( ~cryptography.hazmat.primitives.serialization.Encoding.PEM, ~cryptography.hazmat.primitives.serialization.Encoding.DER, or ~cryptography.hazmat.primitives.serialization.Encoding.Raw) and format ( ~cryptography.hazmat.primitives.serialization.PublicFormat.SubjectPublicKeyInfo or ~cryptography.hazmat.primitives.serialization.PublicFormat.Raw ) are chosen to define the exact serialization.

param encoding

A value from the ~cryptography.hazmat.primitives.serialization.Encoding enum.

param format

A value from the ~cryptography.hazmat.primitives.serialization.PublicFormat enum. If the encoding is ~cryptography.hazmat.primitives.serialization.Encoding.Raw then format must be ~cryptography.hazmat.primitives.serialization.PublicFormat.Raw , otherwise it must be ~cryptography.hazmat.primitives.serialization.PublicFormat.SubjectPublicKeyInfo.

returns bytes

The public key bytes.

public_bytes_raw()

40

Allows serialization of the key to raw bytes. This method is a convenience shortcut for calling public_bytes with ~cryptography.hazmat.primitives.serialization.Encoding.Raw encoding and ~cryptography.hazmat.primitives.serialization.PublicFormat.Raw format.

return bytes

Raw key.

verify(signature, data)

param signature

The signature to verify.

type signature

bytes-like

param data

The data to verify.

type data

bytes-like

returns

None

raises cryptography.exceptions.InvalidSignature

Raised when the signature cannot be verified.