Danger

This is a “Hazardous Materials” module. You should ONLY use it if you’re 100% absolutely sure that you know what you’re doing because this module is full of land mines, dragons, and dinosaurs with laser guns.

Diffie-Hellman key exchange

Numbers

class cryptography.hazmat.primitives.asymmetric.dh.DHPrivateNumbers(x, public_numbers)

New in version 0.8.

The collection of integers that make up a Diffie-Hellman private key.

public_numbers
Type:DHPublicNumbers

The DHPublicNumbers which makes up the DH public key associated with this DH private key.

x
Type:int

The private value.

class cryptography.hazmat.primitives.asymmetric.dh.DHPublicNumbers(y, parameter_numbers)

New in version 0.8.

The collection of integers that make up a Diffie-Hellman public key.

parameter_numbers
Type:DHParameterNumbers

The parameters for this DH group.

y
Type:int

The public value.

class cryptography.hazmat.primitives.asymmetric.dh.DHParameterNumbers(p, g)

New in version 0.8.

The collection of integers that define a Diffie-Hellman group.

p
Type:int

The prime modulus value.

g
Type:int

The generator value.

Key interfaces

class cryptography.hazmat.primitives.asymmetric.dh.DHParameters

New in version 0.9.

generate_private_key()

New in version 0.9.

Generate a DH private key. This method can be used to generate many new private keys from a single set of parameters.

Returns:A DHPrivateKey provider.
class cryptography.hazmat.primitives.asymmetric.dh.DHParametersWithSerialization

New in version 0.9.

Inherits from DHParameters.

parameter_numbers()

Return the numbers that make up this set of parameters.

Returns:A DHParameterNumbers.
class cryptography.hazmat.primitives.asymmetric.dh.DHPrivateKey

New in version 0.9.

key_size

The bit length of the prime modulus.

public_key()

Return the public key associated with this private key.

Returns:A DHPublicKey.
parameters()

Return the parameters associated with this private key.

Returns:A DHParameters.
class cryptography.hazmat.primitives.asymmetric.dh.DHPrivateKeyWithSerialization

New in version 0.9.

Inherits from DHPrivateKey.

private_numbers()

Return the numbers that make up this private key.

Returns:A DHPrivateNumbers.
class cryptography.hazmat.primitives.asymmetric.dh.DHPublicKey

New in version 0.9.

key_size

The bit length of the prime modulus.

parameters()

Return the parameters associated with this private key.

Returns:A DHParameters.
class cryptography.hazmat.primitives.asymmetric.dh.DHPublicKeyWithSerialization

New in version 0.9.

Inherits from DHPublicKey.

public_numbers()

Return the numbers that make up this public key.

Returns:A DHPublicNumbers.