Apero.Crypto.Key (Apero v3.1.0)

Copy Markdown View Source

Key derivation and asymmetric key generation utilities.

Provides:

  • Key derivation: PBKDF2, Argon2id
  • Key exchange: ECDH (X25519)
  • Asymmetric: RSA key generation

Summary

Functions

Derives a key using Argon2id (requires optional argon2_elixir dependency).

Computes a shared secret from your private key and peer's public key.

Generates an X25519 key pair. Returns {private_key, public_key} (both raw binary).

Generates an RSA key pair (2048-bit). Returns {private_der, public_der}.

Derives a key using PBKDF2-HMAC-SHA256.

Functions

argon2id(password, salt, opts \\ [])

@spec argon2id(binary(), binary(), keyword()) :: {:ok, binary()} | {:error, term()}

Derives a key using Argon2id (requires optional argon2_elixir dependency).

compute_ecdh_secret(my_private, peer_public)

@spec compute_ecdh_secret(binary(), binary()) :: {:ok, binary()} | :error

Computes a shared secret from your private key and peer's public key.

generate_ecdh_keypair()

@spec generate_ecdh_keypair() :: {binary(), binary()}

Generates an X25519 key pair. Returns {private_key, public_key} (both raw binary).

generate_rsa_keypair()

@spec generate_rsa_keypair() :: {:ok, {binary(), binary()}} | {:error, term()}

Generates an RSA key pair (2048-bit). Returns {private_der, public_der}.

pbkdf2(password, salt, opts \\ [])

@spec pbkdf2(binary(), binary(), keyword()) :: binary()

Derives a key using PBKDF2-HMAC-SHA256.