[][src]Function devolutions_crypto::key::derive_keypair

pub fn derive_keypair(
    password: &[u8],
    parameters: &Argon2Parameters,
    version: KeyVersion
) -> Result<KeyPair, Error>

Derive a KeyPair from a password and parameters to use in a key exchange or to encrypt data.

Arguments

  • password - The password to derive.
  • parameters - The derivation parameters to use. You should use Argon2Parameters::default() for each new key to generate and reuse the same parameters(including the salt) to regenerate the full key.
  • version - Version of the key scheme to use. Use KeyVersion::Latest if you're not dealing with shared data.

Returns

Returns a KeyPair containing the private key and the public key.

Example

use devolutions_crypto::Argon2Parameters;
use devolutions_crypto::key::{KeyVersion, KeyPair, derive_keypair};

let parameters: Argon2Parameters = Default::default();
let keypair: KeyPair = derive_keypair(b"thisisapassword", &parameters, KeyVersion::Latest).expect("derivation should not fail");