openssh_key.key.Key¶
- class openssh_key.key.Key(header, params, footer, clear=None)¶
Bases:
Generic[openssh_key.key_params.common.PublicKeyParamsTypeVar],abc.ABCA container for a
PublicKeyParams, an encoded header and footer, and cleartext key details.- Parameters
header (
Mapping[str,Any]) – Atyping.Mappingwith the contents of the encoded header.params (
Mapping[str,Any]) – Atyping.Mappingwith the parameter values.footer (
Mapping[str,Any]) – Atyping.Mappingwith the contents of the encoded header.clear (
Optional[Mapping[str,Any]]) – Atyping.Mappingwith cleartext key details, if any.
- __init__(header, params, footer, clear=None)¶
Methods
__init__(header, params, footer[, clear])create_key_params(key_type, key_params_dict)Converts a
typing.Mappingof parameter values to aPublicKeyParamsobject of a given key type.create_key_params_dict(key_type, byte_stream)Reads parameter values from a given bytestream for a given key type.
from_byte_stream(byte_stream[, clear])Reads parameter values, encoded header, and encoded footer from a given bytestream.
from_bytes(byte_string[, clear])Parses parameter values, encoded header, and encoded footer from a given byte string.
from_string(string)Parses parameter values, encoded header, encoded footer, and cleartext key details from a given string in OpenSSH public key format.
The Pascal-style byte stream format instructions for the encoded footer.
The Pascal-style byte stream format instructions for the encoded header.
Packs the public parameter values, encoded header, and encoded footer into a byte string.
pack_public_string([use_footer_comment, ...])Packs the parameter values, encoded header, encoded footer, and cleartext key details into a string in OpenSSH public key format.
Attributes
The Pascal-style byte stream format instructions for the encoded footer.
The Pascal-style byte stream format instructions for the encoded header.
- FOOTER_FORMAT_INSTRUCTIONS_DICT = mappingproxy({})¶
The Pascal-style byte stream format instructions for the encoded footer.
- HEADER_FORMAT_INSTRUCTIONS_DICT = mappingproxy({})¶
The Pascal-style byte stream format instructions for the encoded header.
- abstract static create_key_params(key_type, key_params_dict)¶
Converts a
typing.Mappingof parameter values to aPublicKeyParamsobject of a given key type.- Parameters
- Return type
TypeVar(PublicKeyParamsTypeVar, bound=PublicKeyParams)- Returns
A
PublicKeyParamscontaining the parameter values inkey_params_dict.
- static create_key_params_dict(key_type, byte_stream)¶
Reads parameter values from a given bytestream for a given key type.
- Parameters
key_type (
str) – The key type name.byte_stream (
PascalStyleByteStream) – The bytestream from which to read.
- Return type
- Returns
A
typing.Mappingcontaining the read parameter values.
- classmethod from_byte_stream(byte_stream, clear=None)¶
Reads parameter values, encoded header, and encoded footer from a given bytestream.
- classmethod from_bytes(byte_string, clear=None)¶
Parses parameter values, encoded header, and encoded footer from a given byte string.
- Parameters
- Return type
- Returns
A
Keyobject containing the parameter values, encoded header, encoded footer, and cleartext key details.- Raises
UserWarning – There are additional bytes in the encoded key than would be expected from the key count.
- classmethod from_string(string)¶
Parses parameter values, encoded header, encoded footer, and cleartext key details from a given string in OpenSSH public key format.
- Parameters
string (
str) – The string from which to parse.- Return type
- Returns
A
Keyobject containing the parameter values, encoded header, encoded footer, and cleartext key details.- Raises
UserWarning – The cleartext key type and the encoded key type do not match, or there are additional bytes in the encoded key than would be expected from the key count.
The Pascal-style byte stream format instructions for the encoded footer.
- abstract static get_header_format_instructions_dict()¶
The Pascal-style byte stream format instructions for the encoded header.
- pack_public_bytes()¶
Packs the public parameter values, encoded header, and encoded footer into a byte string.
- Return type
- Returns
A byte string containing the public parameter values, encoded header, and encoded footer.
- pack_public_string(use_footer_comment=True, use_clear_comment=True)¶
Packs the parameter values, encoded header, encoded footer, and cleartext key details into a string in OpenSSH public key format.
- Parameters
- Return type
- Returns
A string containing the parameter values, encoded header, encoded footer, and cleartext key details.