pub struct PkeyCtx<T>(_, _);
Expand description

A context object which can perform asymmetric cryptography operations.

Implementations

Creates a new pkey context using the provided key.

This corresponds to EVP_PKEY_CTX_new.

Creates a new pkey context for the specified algorithm ID.

This corresponds to EVP_PKEY_new_id.

Methods from Deref<Target = PkeyCtxRef<T>>

Prepares the context for encryption using the public key.

This corresponds to EVP_PKEY_encrypt_init.

Prepares the context for signature verification using the public key.

This corresponds to EVP_PKEY_verify_init.

Encrypts data using the public key.

If to is set to None, an upper bound on the number of bytes required for the output buffer will be returned.

This corresponds to EVP_PKEY_encrypt.

Like Self::encrypt but appends ciphertext to a Vec.

Verifies the signature of data using the public key.

Returns Ok(true) if the signature is valid, Ok(false) if the signature is invalid, and Err if an error occurred.

Note

This verifies the signature of the raw data. It is more common to compute and verify the signature of the cryptographic hash of an arbitrary amount of data. The MdCtx type can be used to do that.

This corresponds to EVP_PKEY_verify.

Prepares the context for decryption using the private key.

This corresponds to EVP_PKEY_decrypt_init.

Prepares the context for signing using the private key.

This corresponds to EVP_PKEY_sign_init.

Sets the peer key used for secret derivation.

This corresponds to EVP_PKEY_derive_set_peer.

Decrypts data using the private key.

If to is set to None, an upper bound on the number of bytes required for the output buffer will be returned.

This corresponds to EVP_PKEY_decrypt.

Like Self::decrypt but appends plaintext to a Vec.

Signs the contents of data.

If sig is set to None, an upper bound on the number of bytes required for the output buffer will be returned.

Note

This computes the signature of the raw bytes of data. It is more common to sign the cryptographic hash of an arbitrary amount of data. The MdCtx type can be used to do that.

This corresponds to EVP_PKEY_sign.

Like Self::sign but appends the signature to a Vec.

Prepares the context for shared secret derivation.

This corresponds to EVP_PKEY_derive_init.

Prepares the context for key generation.

This corresponds to EVP_PKEY_keygen_init.

Returns the RSA padding mode in use.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_get_rsa_padding.

Sets the RSA padding mode.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set_rsa_padding.

Sets the RSA MGF1 algorithm.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set_rsa_mgf1_md.

Sets the RSA OAEP algorithm.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set_rsa_oaep_md.

Sets the RSA OAEP label.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set0_rsa_oaep_label.

Sets the cipher used during key generation.

This corresponds to EVP_PKEY_CTX_ctrl.

Sets the key MAC key used during key generation.

This corresponds to EVP_PKEY_CTX_ctrl.

Sets the digest used for HKDF derivation.

Requires OpenSSL 1.1.0 or newer.

This corresponds to EVP_PKEY_CTX_set_hkdf_md.

Sets the HKDF mode of operation.

Defaults to HkdfMode::EXTRACT_THEN_EXPAND.

WARNING: Although this API calls it a “mode”, HKDF-Extract and HKDF-Expand are distinct operations with distinct inputs and distinct kinds of keys. Callers should not pass input secrets for one operation into the other.

Requires OpenSSL 1.1.1 or newer.

This corresponds to EVP_PKEY_CTX_set_hkdf_mode.

Sets the input material for HKDF generation as the “key”.

Which input is the key depends on the “mode” (see set_hkdf_mode). If HkdfMode::EXTRACT_THEN_EXPAND or HkdfMode::EXTRACT_ONLY, this function specifies the input keying material (IKM) for HKDF-Extract. If HkdfMode::EXPAND_ONLY, it instead specifies the pseudorandom key (PRK) for HKDF-Expand.

Requires OpenSSL 1.1.0 or newer.

This corresponds to EVP_PKEY_CTX_set1_hkdf_key.

Sets the salt value for HKDF generation.

If performing HKDF-Expand only, this parameter is ignored.

Requires OpenSSL 1.1.0 or newer.

This corresponds to EVP_PKEY_CTX_set1_hkdf_salt.

Appends info bytes for HKDF generation.

If performing HKDF-Extract only, this parameter is ignored.

Requires OpenSSL 1.1.0 or newer.

This corresponds to EVP_PKEY_CTX_add1_hkdf_info.

Derives a shared secret between two keys.

If buf is set to None, an upper bound on the number of bytes required for the buffer will be returned.

This corresponds to EVP_PKEY_derive.

Like Self::derive but appends the secret to a Vec.

Generates a new public/private keypair.

This corresponds to EVP_PKEY_keygen.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.
Immutably borrows from an owned value. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Executes the destructor for this type. Read more
The raw C type.
The type representing a reference to this type.
Constructs an instance of this type from its raw type.
Returns a raw pointer to the wrapped value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.