llarp::Crypto

library crypto configuration

#include <crypto.hpp>

Inherited by llarp::sodium::CryptoLibSodium

Public Functions

Name
virtual ~Crypto() =0
virtual std::optional< AlignedBuffer< 32 > > maybe_decrypt_name(std::string_view ciphertext, SymmNonce nounce, std::string_view name) =0
decrypt cipherText name given the key generated from name
virtual bool xchacha20(const llarp_buffer_t & , const SharedSecret & , const TunnelNonce & ) =0
xchacha symmetric cipher
virtual bool xchacha20_alt(const llarp_buffer_t & , const llarp_buffer_t & , const SharedSecret & , const byte_t * ) =0
xchacha symmetric cipher (multibuffer)
virtual bool dh_client(SharedSecret & , const PubKey & , const SecretKey & , const TunnelNonce & ) =0
path dh creator's side
virtual bool dh_server(SharedSecret & , const PubKey & , const SecretKey & , const TunnelNonce & ) =0
path dh relay side
virtual bool transport_dh_client(SharedSecret & , const PubKey & , const SecretKey & , const TunnelNonce & ) =0
transport dh client side
virtual bool transport_dh_server(SharedSecret & , const PubKey & , const SecretKey & , const TunnelNonce & ) =0
transport dh server side
virtual bool shorthash(ShortHash & , const llarp_buffer_t & ) =0
blake2b 256 bit
virtual bool hmac(byte_t * , const llarp_buffer_t & , const SharedSecret & ) =0
blake2s 256 bit "hmac" (keyed hash)
virtual bool sign(Signature & , const SecretKey & , const llarp_buffer_t & ) =0
ed25519 sign
virtual bool sign(Signature & , const PrivateKey & , const llarp_buffer_t & ) =0
ed25519 sign (custom with derived keys)
virtual bool verify(const PubKey & , const llarp_buffer_t & , const Signature & ) =0
ed25519 verify
virtual bool derive_subkey(PubKey & , const PubKey & , uint64_t , const AlignedBuffer< 32 > * =nullptr) =0
derive sub keys for public keys
virtual bool derive_subkey_private(PrivateKey & , const SecretKey & , uint64_t , const AlignedBuffer< 32 > * =nullptr) =0
derive sub keys for private keys
virtual bool seed_to_secretkey(llarp::SecretKey & , const llarp::IdentitySecret & ) =0
seed to secretkey
virtual void randomize(const llarp_buffer_t & ) =0
randomize buffer
virtual void randbytes(byte_t * , size_t ) =0
randomizer memory
virtual void identity_keygen(SecretKey & ) =0
generate signing keypair
virtual void encryption_keygen(SecretKey & ) =0
generate encryption keypair
virtual void pqe_keygen(PQKeyPair & ) =0
generate post quantum encrytion key
virtual bool pqe_decrypt(const PQCipherBlock & , SharedSecret & , const byte_t * ) =0
post quantum decrypt (buffer, sharedkey_dst, sec)
virtual bool pqe_encrypt(PQCipherBlock & , SharedSecret & , const PQPubKey & ) =0
post quantum encrypt (buffer, sharedkey_dst, pub)
virtual bool check_identity_privkey(const SecretKey & ) =0
virtual bool check_passwd_hash(std::string pwhash, std::string challenge) =0
check if a password hash string matches the challenge

Public Functions Documentation

function ~Crypto

inline virtual ~Crypto() =0

function maybe_decrypt_name

virtual std::optional< AlignedBuffer< 32 > > maybe_decrypt_name(
    std::string_view ciphertext,
    SymmNonce nounce,
    std::string_view name
) =0

decrypt cipherText name given the key generated from name

Reimplemented by: llarp::sodium::CryptoLibSodium::maybe_decrypt_name

function xchacha20

virtual bool xchacha20(
    const llarp_buffer_t & ,
    const SharedSecret & ,
    const TunnelNonce & 
) =0

xchacha symmetric cipher

Reimplemented by: llarp::sodium::CryptoLibSodium::xchacha20

function xchacha20_alt

virtual bool xchacha20_alt(
    const llarp_buffer_t & ,
    const llarp_buffer_t & ,
    const SharedSecret & ,
    const byte_t * 
) =0

xchacha symmetric cipher (multibuffer)

Reimplemented by: llarp::sodium::CryptoLibSodium::xchacha20_alt

function dh_client

virtual bool dh_client(
    SharedSecret & ,
    const PubKey & ,
    const SecretKey & ,
    const TunnelNonce & 
) =0

path dh creator's side

Reimplemented by: llarp::sodium::CryptoLibSodium::dh_client

function dh_server

virtual bool dh_server(
    SharedSecret & ,
    const PubKey & ,
    const SecretKey & ,
    const TunnelNonce & 
) =0

path dh relay side

Reimplemented by: llarp::sodium::CryptoLibSodium::dh_server

function transport_dh_client

virtual bool transport_dh_client(
    SharedSecret & ,
    const PubKey & ,
    const SecretKey & ,
    const TunnelNonce & 
) =0

transport dh client side

Reimplemented by: llarp::sodium::CryptoLibSodium::transport_dh_client

function transport_dh_server

virtual bool transport_dh_server(
    SharedSecret & ,
    const PubKey & ,
    const SecretKey & ,
    const TunnelNonce & 
) =0

transport dh server side

Reimplemented by: llarp::sodium::CryptoLibSodium::transport_dh_server

function shorthash

virtual bool shorthash(
    ShortHash & ,
    const llarp_buffer_t & 
) =0

blake2b 256 bit

Reimplemented by: llarp::sodium::CryptoLibSodium::shorthash

function hmac

virtual bool hmac(
    byte_t * ,
    const llarp_buffer_t & ,
    const SharedSecret & 
) =0

blake2s 256 bit "hmac" (keyed hash)

Reimplemented by: llarp::sodium::CryptoLibSodium::hmac

function sign

virtual bool sign(
    Signature & ,
    const SecretKey & ,
    const llarp_buffer_t & 
) =0

ed25519 sign

Reimplemented by: llarp::sodium::CryptoLibSodium::sign

function sign

virtual bool sign(
    Signature & ,
    const PrivateKey & ,
    const llarp_buffer_t & 
) =0

ed25519 sign (custom with derived keys)

Reimplemented by: llarp::sodium::CryptoLibSodium::sign

function verify

virtual bool verify(
    const PubKey & ,
    const llarp_buffer_t & ,
    const Signature & 
) =0

ed25519 verify

Reimplemented by: llarp::sodium::CryptoLibSodium::verify

function derive_subkey

virtual bool derive_subkey(
    PubKey & ,
    const PubKey & ,
    uint64_t ,
    const AlignedBuffer< 32 > *  =nullptr
) =0

derive sub keys for public keys

Reimplemented by: llarp::sodium::CryptoLibSodium::derive_subkey

function derive_subkey_private

virtual bool derive_subkey_private(
    PrivateKey & ,
    const SecretKey & ,
    uint64_t ,
    const AlignedBuffer< 32 > *  =nullptr
) =0

derive sub keys for private keys

Reimplemented by: llarp::sodium::CryptoLibSodium::derive_subkey_private

function seed_to_secretkey

virtual bool seed_to_secretkey(
    llarp::SecretKey & ,
    const llarp::IdentitySecret & 
) =0

seed to secretkey

Reimplemented by: llarp::sodium::CryptoLibSodium::seed_to_secretkey

function randomize

virtual void randomize(
    const llarp_buffer_t & 
) =0

randomize buffer

Reimplemented by: llarp::sodium::CryptoLibSodium::randomize

function randbytes

virtual void randbytes(
    byte_t * ,
    size_t 
) =0

randomizer memory

Reimplemented by: llarp::sodium::CryptoLibSodium::randbytes

function identity_keygen

virtual void identity_keygen(
    SecretKey & 
) =0

generate signing keypair

Reimplemented by: llarp::sodium::CryptoLibSodium::identity_keygen

function encryption_keygen

virtual void encryption_keygen(
    SecretKey & 
) =0

generate encryption keypair

Reimplemented by: llarp::sodium::CryptoLibSodium::encryption_keygen

function pqe_keygen

virtual void pqe_keygen(
    PQKeyPair & 
) =0

generate post quantum encrytion key

Reimplemented by: llarp::sodium::CryptoLibSodium::pqe_keygen

function pqe_decrypt

virtual bool pqe_decrypt(
    const PQCipherBlock & ,
    SharedSecret & ,
    const byte_t * 
) =0

post quantum decrypt (buffer, sharedkey_dst, sec)

Reimplemented by: llarp::sodium::CryptoLibSodium::pqe_decrypt

function pqe_encrypt

virtual bool pqe_encrypt(
    PQCipherBlock & ,
    SharedSecret & ,
    const PQPubKey & 
) =0

post quantum encrypt (buffer, sharedkey_dst, pub)

Reimplemented by: llarp::sodium::CryptoLibSodium::pqe_encrypt

function check_identity_privkey

virtual bool check_identity_privkey(
    const SecretKey & 
) =0

Reimplemented by: llarp::sodium::CryptoLibSodium::check_identity_privkey

function check_passwd_hash

virtual bool check_passwd_hash(
    std::string pwhash,
    std::string challenge
) =0

check if a password hash string matches the challenge

Reimplemented by: llarp::sodium::CryptoLibSodium::check_passwd_hash


Updated on 2026-01-10 at 22:49:45 +0000