openssh_key.kdf_options.common.KDFOptions

class openssh_key.kdf_options.common.KDFOptions(dict=None, /, **kwargs)

Bases: collections.UserDict, abc.ABC

The parameters of a password-based key derivation function.

Used to obtain a pseudorandom symmetric key by cryptographically hashing a potentially low-entropy passphrase given certain parameters, such as a work factor, memory factor, or salt.

__init__(dict=None, /, **kwargs)

Methods

__init__([dict])

clear()

copy()

derive_key(passphrase, length)

Derives a key derivation function result from a given passphrase and parameters.

fromkeys(iterable[, value])

generate_options(**kwargs)

Generates parameters to be consumed by a key derivation function.

get(k[,d])

get_options_format_instructions_dict()

The Pascal-style byte stream format instructions for the parameters to a key derivation function.

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

OPTIONS_FORMAT_INSTRUCTIONS_DICT

The Pascal-style byte stream format instructions for the parameters to a key derivation function.

OPTIONS_FORMAT_INSTRUCTIONS_DICT

The Pascal-style byte stream format instructions for the parameters to a key derivation function.

clear() None.  Remove all items from D.
abstract derive_key(passphrase, length)

Derives a key derivation function result from a given passphrase and parameters.

Parameters
  • options – Key derivation function parameters.

  • passphrase (str) – Passphrase from which to derive key.

Return type

bytes

Returns

Key derivation function result.

abstract classmethod generate_options(**kwargs)

Generates parameters to be consumed by a key derivation function.

Parameters

kwargs (Any) – Keyword arguments using which to generate parameters.

Return type

TypeVar(KDFOptionsTypeVar, bound= KDFOptions)

Returns

Generated key generation function parameters.

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

The Pascal-style byte stream format instructions for the parameters to a key derivation function.

Return type

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

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