openssh_key.key_params.rsa.RSAPrivateKeyParams

class openssh_key.key_params.rsa.RSAPrivateKeyParams(params)

Bases: openssh_key.key_params.common.PrivateKeyParams, openssh_key.key_params.rsa.RSAPublicKeyParams

The parameters comprising a private key in the Rivest-Shamir-Adleman (RSA) cryptosystem.

The names and iteration order of parameters of a private RSA key is:

  • n: The public composite modulus (int).

  • e: The public exponent (int; NB order of n and e are

    reversed relative to RSAPublicKeyParams).

  • d: The private exponent (int).

  • iqmp: q^-1 mod p (int).

  • p: First prime comprising n (int).

  • q: Second prime comprising n (int).

Parameters

params (Mapping[str, Any]) – The values with which to initialize this parameters object. All given values are saved, even those that do not exist in the format instructions for this key type.

Raises

UserWarning – A parameter value from the above list is missing from params or does not have the correct type.

__init__(params)

Methods

__init__(params)

check_params_are_valid()

Checks whether the values within this parameters object conform to the format instructions.

clear()

conversion_functions()

Conversion functions for key objects of the following types:

convert_from(key_object)

Constructs and initializes a parameters object for this key type from attributes contained in the given object.

convert_to(destination_class)

Creates and initializes an object of the given type containing the values of this parameters object.

copy()

fromkeys(iterable[, value])

generate_private_params(**kwargs)

Constructs and initializes an RSA private key parameters object with generated values.

get(k[,d])

get_format_instructions_dict()

The Pascal-style byte stream format instructions for the parameters of a key of this type.

get_key_size()

The value 4096, the default key size, in bits, of an RSA key.

get_public_exponent()

The value 65537, the default public exponent of an RSA key.

items()

keys()

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[,d])

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()

Attributes

FORMAT_INSTRUCTIONS_DICT

The Pascal-style byte stream format instructions for the parameters of a key of this type.

KEY_SIZE

The value 4096, the default key size, in bits, of an RSA key.

PUBLIC_EXPONENT

The value 65537, the default public exponent of an RSA key.

KEY_SIZE = 4096

The value 4096, the default key size, in bits, of an RSA key.

PUBLIC_EXPONENT = 65537

The value 65537, the default public exponent of an RSA key.

check_params_are_valid()

Checks whether the values within this parameters object conform to the format instructions.

Raises

UserWarning – A parameter value is missing or does not have a type that matches the format instructions for this key type.

Return type

None

clear() None.  Remove all items from D.
classmethod conversion_functions()

Conversion functions for key objects of the following types:

Return type

Mapping[Type[Any], ConversionFunctions]

Returns

A typing.Mapping from the above types of key objects to functions that take key objects of these types and return parameter values.

classmethod convert_from(key_object)

Constructs and initializes a parameters object for this key type from attributes contained in the given object.

This classmethod searches conversion_functions for a class that is a superclass of key_object. If one is found, it returns the parameters object from the typing.Mapping returned by the corresponding object_to_mapping function. Otherwise, it searches its subclasses’ conversion_functions, traversing pre-order.

Parameters

key_object (Any) – An object containing key parameter values.

Raises

NotImplementedErrorkey_object is not of a supported type, or it does not contain the attributes necessary to construct a parameters object of this class.

Return type

PublicKeyParams

convert_to(destination_class)

Creates and initializes an object of the given type containing the values of this parameters object.

This method searches conversion_functions for a class that is a subclass of key_object. If one is found, it passes this parameters object to the corresponding mapping_to_object. Otherwise, it searches its superclasses’ conversion_functions in the same way, in method resolution order, up to and including PublicKeyParams.

Parameters

destination_class (Type[Any]) – The type of the object to which the values of this parameters object are to be converted.

Raises
  • ValueErrordestination_class is not a class.

  • ImportErrordestination_class cannot be imported.

  • NotImplementedError – Converting this parameters object to an object of type destination_class is not supported.

Return type

Any

classmethod generate_private_params(**kwargs)

Constructs and initializes an RSA private key parameters object with generated values.

Parameters

kwargs (Any) – Keyword arguments consumed to generate parameter values.

Return type

TypeVar(RSAPrivateKeyParamsTypeVar, bound= RSAPrivateKeyParams)

Returns

A private key parameters object with generated values valid for an RSA private key. Following OpenSSH, if kwargs['e'] is not given, a public exponent of 65537 is used, and if kwargs['key_size'] is not given, a key of length 4096 is generated.

get(k[, d]) D[k] if k in D, else d.  d defaults to None.
classmethod get_format_instructions_dict()

The Pascal-style byte stream format instructions for the parameters of a key of this type.

Return type

Mapping[str, Union[str, PascalStyleFormatInstruction, PascalStyleFormatInstructionStringLengthSize]]

static get_key_size()

The value 4096, the default key size, in bits, of an RSA key.

Return type

int

static get_public_exponent()

The value 65537, the default public exponent of an RSA key.

Return type

int

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() an object providing a view on D's values