Function ring::agreement::agree_ephemeral [−][src]
pub fn agree_ephemeral<F, R, E>(
my_private_key: EphemeralPrivateKey,
peer_public_key_alg: &Algorithm,
peer_public_key: Input,
error_value: E,
kdf: F
) -> Result<R, E> where
F: FnOnce(&[u8]) -> Result<R, E>,
Performs a key agreement with an ephemeral private key and the given public key.
my_private_key is the ephemeral private key to use. Since it is moved, it
will not be usable after calling agree_ephemeral, thus guaranteeing that
the key is used for only one key agreement.
peer_public_key_alg is the algorithm/curve for the peer's public key
point; agree_ephemeral will return Err(error_value) if it does not
match my_private_key's algorithm/curve.
peer_public_key is the peer's public key. agree_ephemeral verifies that
it is encoded in the standard form for the algorithm and that the key is
valid; see the algorithm's documentation for details on how keys are to
be encoded and what constitutes a valid key for that algorithm.
error_value is the value to return if an error occurs before kdf is
called, e.g. when decoding of the peer's public key fails or when the public
key is otherwise invalid.
After the key agreement is done, agree_ephemeral calls kdf with the raw
key material from the key agreement operation and then returns what kdf
returns.
C analogs: EC_POINT_oct2point + ECDH_compute_key, X25519.