Botan 3.4.0
Crypto and TLS for C&
Enumerations | Functions
Botan::Sodium Namespace Reference

Enumerations

enum  Sodium_Constants : size_t {
  SODIUM_SIZE_MAX = 0xFFFFFFFF , crypto_aead_chacha20poly1305_ABYTES = 16 , crypto_aead_chacha20poly1305_KEYBYTES = 32 , crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX ,
  crypto_aead_chacha20poly1305_NPUBBYTES = 8 , crypto_aead_chacha20poly1305_NSECBYTES = 0 , crypto_aead_chacha20poly1305_ietf_ABYTES = 16 , crypto_aead_chacha20poly1305_ietf_KEYBYTES = 32 ,
  crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX , crypto_aead_chacha20poly1305_ietf_NPUBBYTES = 12 , crypto_aead_chacha20poly1305_ietf_NSECBYTES = 0 , crypto_aead_xchacha20poly1305_ietf_ABYTES = 16 ,
  crypto_aead_xchacha20poly1305_ietf_KEYBYTES = 32 , crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX , crypto_aead_xchacha20poly1305_ietf_NPUBBYTES = 24 , crypto_aead_xchacha20poly1305_ietf_NSECBYTES = 0 ,
  crypto_auth_hmacsha256_BYTES = 32 , crypto_auth_hmacsha256_KEYBYTES = 32 , crypto_auth_hmacsha512256_BYTES = 32 , crypto_auth_hmacsha512256_KEYBYTES = 32 ,
  crypto_auth_hmacsha512_BYTES = 64 , crypto_auth_hmacsha512_KEYBYTES = 32 , crypto_auth_BYTES = crypto_auth_hmacsha512256_BYTES , crypto_auth_KEYBYTES = crypto_auth_hmacsha512256_KEYBYTES ,
  crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES = 32 , crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES = 16 , crypto_box_curve25519xsalsa20poly1305_MACBYTES = 16 , crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX ,
  crypto_box_curve25519xsalsa20poly1305_NONCEBYTES = 24 , crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES = 32 , crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES = 32 , crypto_box_curve25519xsalsa20poly1305_SEEDBYTES = 32 ,
  crypto_box_curve25519xsalsa20poly1305_ZEROBYTES , crypto_box_BEFORENMBYTES = crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES , crypto_box_BOXZEROBYTES = crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES , crypto_box_MACBYTES = crypto_box_curve25519xsalsa20poly1305_MACBYTES ,
  crypto_box_MESSAGEBYTES_MAX = crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX , crypto_box_NONCEBYTES = crypto_box_curve25519xsalsa20poly1305_NONCEBYTES , crypto_box_PUBLICKEYBYTES = crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES , crypto_box_SECRETKEYBYTES = crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES ,
  crypto_box_SEEDBYTES = crypto_box_curve25519xsalsa20poly1305_SEEDBYTES , crypto_box_ZEROBYTES = crypto_box_curve25519xsalsa20poly1305_ZEROBYTES , crypto_core_hchacha20_CONSTBYTES = 16 , crypto_core_hchacha20_INPUTBYTES = 16 ,
  crypto_core_hchacha20_KEYBYTES = 32 , crypto_core_hchacha20_OUTPUTBYTES = 32 , crypto_core_hsalsa20_CONSTBYTES = 16 , crypto_core_hsalsa20_INPUTBYTES = 16 ,
  crypto_core_hsalsa20_KEYBYTES = 32 , crypto_core_hsalsa20_OUTPUTBYTES = 32 , crypto_hash_sha256_BYTES = 32 , crypto_hash_sha512_BYTES = 64 ,
  crypto_hash_BYTES = crypto_hash_sha512_BYTES , crypto_onetimeauth_poly1305_BYTES = 16 , crypto_onetimeauth_poly1305_KEYBYTES = 32 , crypto_onetimeauth_BYTES = crypto_onetimeauth_poly1305_BYTES ,
  crypto_onetimeauth_KEYBYTES = crypto_onetimeauth_poly1305_KEYBYTES , crypto_scalarmult_curve25519_BYTES = 32 , crypto_scalarmult_curve25519_SCALARBYTES = 32 , crypto_scalarmult_BYTES = crypto_scalarmult_curve25519_BYTES ,
  crypto_scalarmult_SCALARBYTES = crypto_scalarmult_curve25519_SCALARBYTES , crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES = 16 , crypto_secretbox_xsalsa20poly1305_KEYBYTES = 32 , crypto_secretbox_xsalsa20poly1305_MACBYTES = 16 ,
  crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX , crypto_secretbox_xsalsa20poly1305_NONCEBYTES = 24 , crypto_secretbox_xsalsa20poly1305_ZEROBYTES , crypto_secretbox_BOXZEROBYTES = crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES ,
  crypto_secretbox_KEYBYTES = crypto_secretbox_xsalsa20poly1305_KEYBYTES , crypto_secretbox_MACBYTES = crypto_secretbox_xsalsa20poly1305_MACBYTES , crypto_secretbox_MESSAGEBYTES_MAX = crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX , crypto_secretbox_NONCEBYTES = crypto_secretbox_xsalsa20poly1305_NONCEBYTES ,
  crypto_secretbox_ZEROBYTES = crypto_secretbox_xsalsa20poly1305_ZEROBYTES , crypto_shorthash_siphash24_BYTES = 8 , crypto_shorthash_siphash24_KEYBYTES = 16 , crypto_shorthash_BYTES = crypto_shorthash_siphash24_BYTES ,
  crypto_shorthash_KEYBYTES = crypto_shorthash_siphash24_KEYBYTES , crypto_sign_ed25519_BYTES = 64 , crypto_sign_ed25519_MESSAGEBYTES_MAX = (SODIUM_SIZE_MAX - crypto_sign_ed25519_BYTES) , crypto_sign_ed25519_PUBLICKEYBYTES = 32 ,
  crypto_sign_ed25519_SECRETKEYBYTES = (32 + 32) , crypto_sign_ed25519_SEEDBYTES = 32 , crypto_sign_BYTES = crypto_sign_ed25519_BYTES , crypto_sign_MESSAGEBYTES_MAX = crypto_sign_ed25519_MESSAGEBYTES_MAX ,
  crypto_sign_PUBLICKEYBYTES = crypto_sign_ed25519_PUBLICKEYBYTES , crypto_sign_SECRETKEYBYTES = crypto_sign_ed25519_SECRETKEYBYTES , crypto_sign_SEEDBYTES = crypto_sign_ed25519_SEEDBYTES , crypto_stream_chacha20_KEYBYTES = 32 ,
  crypto_stream_chacha20_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX , crypto_stream_chacha20_NONCEBYTES = 8 , crypto_stream_chacha20_ietf_KEYBYTES = 32 , crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX ,
  crypto_stream_chacha20_ietf_NONCEBYTES = 12 , crypto_stream_salsa20_KEYBYTES = 32 , crypto_stream_salsa20_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX , crypto_stream_salsa20_NONCEBYTES = 8 ,
  crypto_stream_xchacha20_KEYBYTES = 32 , crypto_stream_xchacha20_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX , crypto_stream_xchacha20_NONCEBYTES = 24 , crypto_stream_xsalsa20_KEYBYTES = 32 ,
  crypto_stream_xsalsa20_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX , crypto_stream_xsalsa20_NONCEBYTES = 24 , crypto_stream_KEYBYTES = crypto_stream_xsalsa20_KEYBYTES , crypto_stream_MESSAGEBYTES_MAX = crypto_stream_xsalsa20_MESSAGEBYTES_MAX ,
  crypto_stream_NONCEBYTES = crypto_stream_xsalsa20_NONCEBYTES , crypto_verify_16_BYTES = 16 , crypto_verify_32_BYTES = 32 , crypto_verify_64_BYTES = 64 ,
  randombytes_SEEDBYTES = 32
}
 

Functions

size_t crypto_aead_chacha20poly1305_abytes ()
 
int crypto_aead_chacha20poly1305_decrypt (uint8_t m[], unsigned long long *ptext_len, uint8_t unused_secret_nonce[], const uint8_t ctext[], size_t ctext_len, const uint8_t ad[], size_t ad_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_aead_chacha20poly1305_decrypt_detached (uint8_t m[], uint8_t unused_secret_nonce[], const uint8_t ctext[], size_t ctext_len, const uint8_t mac[], const uint8_t ad[], size_t ad_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_aead_chacha20poly1305_encrypt (uint8_t ctext[], unsigned long long *ctext_len, const uint8_t ptext[], size_t ptext_len, const uint8_t ad[], size_t ad_len, const uint8_t unused_secret_nonce[], const uint8_t nonce[], const uint8_t key[])
 
int crypto_aead_chacha20poly1305_encrypt_detached (uint8_t ctext[], uint8_t mac[], unsigned long long *mac_len, const uint8_t ptext[], size_t ptext_len, const uint8_t ad[], size_t ad_len, const uint8_t unused_secret_nonce[], const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_aead_chacha20poly1305_ietf_abytes ()
 
int crypto_aead_chacha20poly1305_ietf_decrypt (uint8_t ptext[], unsigned long long *ptext_len, uint8_t unused_secret_nonce[], const uint8_t ctext[], size_t ctext_len, const uint8_t ad[], size_t ad_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_aead_chacha20poly1305_ietf_decrypt_detached (uint8_t m[], uint8_t unused_secret_nonce[], const uint8_t ctext[], size_t ctext_len, const uint8_t mac[], const uint8_t ad[], size_t ad_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_aead_chacha20poly1305_ietf_encrypt (uint8_t ctext[], unsigned long long *ctext_len, const uint8_t ptext[], size_t ptext_len, const uint8_t ad[], size_t ad_len, const uint8_t unused_secret_nonce[], const uint8_t nonce[], const uint8_t key[])
 
int crypto_aead_chacha20poly1305_ietf_encrypt_detached (uint8_t ctext[], uint8_t mac[], unsigned long long *mac_len, const uint8_t ptext[], size_t ptext_len, const uint8_t ad[], size_t ad_len, const uint8_t unused_secret_nonce[], const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_aead_chacha20poly1305_ietf_keybytes ()
 
void crypto_aead_chacha20poly1305_ietf_keygen (uint8_t k[32])
 
size_t crypto_aead_chacha20poly1305_ietf_messagebytes_max ()
 
size_t crypto_aead_chacha20poly1305_ietf_npubbytes ()
 
size_t crypto_aead_chacha20poly1305_ietf_nsecbytes ()
 
size_t crypto_aead_chacha20poly1305_keybytes ()
 
void crypto_aead_chacha20poly1305_keygen (uint8_t k[32])
 
size_t crypto_aead_chacha20poly1305_messagebytes_max ()
 
size_t crypto_aead_chacha20poly1305_npubbytes ()
 
size_t crypto_aead_chacha20poly1305_nsecbytes ()
 
size_t crypto_aead_xchacha20poly1305_ietf_abytes ()
 
int crypto_aead_xchacha20poly1305_ietf_decrypt (uint8_t ptext[], unsigned long long *ptext_len, uint8_t unused_secret_nonce[], const uint8_t ctext[], size_t ctext_len, const uint8_t ad[], size_t ad_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_aead_xchacha20poly1305_ietf_decrypt_detached (uint8_t ptext[], uint8_t unused_secret_nonce[], const uint8_t ctext[], size_t ctext_len, const uint8_t mac[], const uint8_t ad[], size_t ad_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_aead_xchacha20poly1305_ietf_encrypt (uint8_t ctext[], unsigned long long *ctext_len, const uint8_t ptext[], size_t ptext_len, const uint8_t ad[], size_t ad_len, const uint8_t unused_secret_nonce[], const uint8_t nonce[], const uint8_t key[])
 
int crypto_aead_xchacha20poly1305_ietf_encrypt_detached (uint8_t ctext[], uint8_t mac[], unsigned long long *mac_len, const uint8_t ptext[], size_t ptext_len, const uint8_t ad[], size_t ad_len, const uint8_t unused_secret_nonce[], const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_aead_xchacha20poly1305_ietf_keybytes ()
 
void crypto_aead_xchacha20poly1305_ietf_keygen (uint8_t k[32])
 
size_t crypto_aead_xchacha20poly1305_ietf_messagebytes_max ()
 
size_t crypto_aead_xchacha20poly1305_ietf_npubbytes ()
 
size_t crypto_aead_xchacha20poly1305_ietf_nsecbytes ()
 
int crypto_auth (uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
size_t crypto_auth_bytes ()
 
int crypto_auth_hmacsha256 (uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
size_t crypto_auth_hmacsha256_bytes ()
 
size_t crypto_auth_hmacsha256_keybytes ()
 
void crypto_auth_hmacsha256_keygen (uint8_t k[32])
 
int crypto_auth_hmacsha256_verify (const uint8_t h[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
int crypto_auth_hmacsha512 (uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
int crypto_auth_hmacsha512256 (uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
size_t crypto_auth_hmacsha512256_bytes ()
 
size_t crypto_auth_hmacsha512256_keybytes ()
 
void crypto_auth_hmacsha512256_keygen (uint8_t k[32])
 
int crypto_auth_hmacsha512256_verify (const uint8_t h[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
size_t crypto_auth_hmacsha512_bytes ()
 
size_t crypto_auth_hmacsha512_keybytes ()
 
void crypto_auth_hmacsha512_keygen (uint8_t k[32])
 
int crypto_auth_hmacsha512_verify (const uint8_t h[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
size_t crypto_auth_keybytes ()
 
void crypto_auth_keygen (uint8_t k[])
 
const char * crypto_auth_primitive ()
 
int crypto_auth_verify (const uint8_t mac[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
int crypto_box (uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])
 
int crypto_box_afternm (uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_box_beforenm (uint8_t key[], const uint8_t pk[32], const uint8_t sk[32])
 
size_t crypto_box_beforenmbytes ()
 
size_t crypto_box_boxzerobytes ()
 
int crypto_box_curve25519xsalsa20poly1305 (uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])
 
int crypto_box_curve25519xsalsa20poly1305_afternm (uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_box_curve25519xsalsa20poly1305_beforenm (uint8_t key[], const uint8_t pk[32], const uint8_t sk[32])
 
size_t crypto_box_curve25519xsalsa20poly1305_beforenmbytes ()
 
size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes ()
 
int crypto_box_curve25519xsalsa20poly1305_keypair (uint8_t pk[32], uint8_t sk[32])
 
size_t crypto_box_curve25519xsalsa20poly1305_macbytes ()
 
size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max ()
 
size_t crypto_box_curve25519xsalsa20poly1305_noncebytes ()
 
int crypto_box_curve25519xsalsa20poly1305_open (uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])
 
int crypto_box_curve25519xsalsa20poly1305_open_afternm (uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_box_curve25519xsalsa20poly1305_publickeybytes ()
 
size_t crypto_box_curve25519xsalsa20poly1305_secretkeybytes ()
 
int crypto_box_curve25519xsalsa20poly1305_seed_keypair (uint8_t pk[32], uint8_t sk[32], const uint8_t seed[32])
 
size_t crypto_box_curve25519xsalsa20poly1305_seedbytes ()
 
size_t crypto_box_curve25519xsalsa20poly1305_zerobytes ()
 
int crypto_box_detached (uint8_t ctext[], uint8_t mac[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])
 
int crypto_box_detached_afternm (uint8_t ctext[], uint8_t mac[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_box_easy (uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])
 
int crypto_box_easy_afternm (uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_box_keypair (uint8_t pk[32], uint8_t sk[32])
 
size_t crypto_box_macbytes ()
 
size_t crypto_box_messagebytes_max ()
 
size_t crypto_box_noncebytes ()
 
int crypto_box_open (uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])
 
int crypto_box_open_afternm (uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_box_open_detached (uint8_t ptext[], const uint8_t ctext[], const uint8_t mac[], size_t ctext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])
 
int crypto_box_open_detached_afternm (uint8_t ptext[], const uint8_t ctext[], const uint8_t mac[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_box_open_easy (uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])
 
int crypto_box_open_easy_afternm (uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
const char * crypto_box_primitive ()
 
size_t crypto_box_publickeybytes ()
 
size_t crypto_box_secretkeybytes ()
 
int crypto_box_seed_keypair (uint8_t pk[32], uint8_t sk[32], const uint8_t seed[])
 
size_t crypto_box_seedbytes ()
 
size_t crypto_box_zerobytes ()
 
int crypto_core_hsalsa20 (uint8_t out[], const uint8_t in[], const uint8_t key[], const uint8_t c[])
 
size_t crypto_core_hsalsa20_constbytes ()
 
size_t crypto_core_hsalsa20_inputbytes ()
 
size_t crypto_core_hsalsa20_keybytes ()
 
size_t crypto_core_hsalsa20_outputbytes ()
 
int crypto_hash (uint8_t out[], const uint8_t in[], size_t in_len)
 
size_t crypto_hash_bytes ()
 
const char * crypto_hash_primitive ()
 
int crypto_hash_sha256 (uint8_t out[], const uint8_t in[], size_t in_len)
 
size_t crypto_hash_sha256_bytes ()
 
int crypto_hash_sha512 (uint8_t out[64], const uint8_t in[], size_t in_len)
 
size_t crypto_hash_sha512_bytes ()
 
int crypto_onetimeauth (uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
size_t crypto_onetimeauth_bytes ()
 
size_t crypto_onetimeauth_keybytes ()
 
void crypto_onetimeauth_keygen (uint8_t k[32])
 
int crypto_onetimeauth_poly1305 (uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
size_t crypto_onetimeauth_poly1305_bytes ()
 
size_t crypto_onetimeauth_poly1305_keybytes ()
 
void crypto_onetimeauth_poly1305_keygen (uint8_t k[32])
 
int crypto_onetimeauth_poly1305_verify (const uint8_t h[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
const char * crypto_onetimeauth_primitive ()
 
int crypto_onetimeauth_verify (const uint8_t h[], const uint8_t in[], size_t in_len, const uint8_t key[])
 
int crypto_scalarmult (uint8_t out[], const uint8_t scalar[], const uint8_t base[])
 
int crypto_scalarmult_base (uint8_t out[], const uint8_t scalar[])
 
size_t crypto_scalarmult_bytes ()
 
int crypto_scalarmult_curve25519 (uint8_t out[32], const uint8_t scalar[32], const uint8_t basepoint[32])
 
int crypto_scalarmult_curve25519_base (uint8_t out[32], const uint8_t scalar[32])
 
size_t crypto_scalarmult_curve25519_bytes ()
 
size_t crypto_scalarmult_curve25519_scalarbytes ()
 
const char * crypto_scalarmult_primitive ()
 
size_t crypto_scalarmult_scalarbytes ()
 
int crypto_secretbox (uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_secretbox_boxzerobytes ()
 
int crypto_secretbox_detached (uint8_t ctext[], uint8_t mac[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_secretbox_easy (uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_secretbox_keybytes ()
 
void crypto_secretbox_keygen (uint8_t k[32])
 
size_t crypto_secretbox_macbytes ()
 
size_t crypto_secretbox_messagebytes_max ()
 
size_t crypto_secretbox_noncebytes ()
 
int crypto_secretbox_open (uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_secretbox_open_detached (uint8_t ptext[], const uint8_t ctext[], const uint8_t mac[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_secretbox_open_easy (uint8_t out[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
const char * crypto_secretbox_primitive ()
 
int crypto_secretbox_xsalsa20poly1305 (uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes ()
 
size_t crypto_secretbox_xsalsa20poly1305_keybytes ()
 
void crypto_secretbox_xsalsa20poly1305_keygen (uint8_t k[32])
 
size_t crypto_secretbox_xsalsa20poly1305_macbytes ()
 
size_t crypto_secretbox_xsalsa20poly1305_messagebytes_max ()
 
size_t crypto_secretbox_xsalsa20poly1305_noncebytes ()
 
int crypto_secretbox_xsalsa20poly1305_open (uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_secretbox_xsalsa20poly1305_zerobytes ()
 
size_t crypto_secretbox_zerobytes ()
 
int crypto_shorthash (uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t k[16])
 
size_t crypto_shorthash_bytes ()
 
size_t crypto_shorthash_keybytes ()
 
void crypto_shorthash_keygen (uint8_t k[16])
 
const char * crypto_shorthash_primitive ()
 
int crypto_shorthash_siphash24 (uint8_t out[8], const uint8_t in[], size_t in_len, const uint8_t key[16])
 
size_t crypto_shorthash_siphash24_bytes ()
 
size_t crypto_shorthash_siphash24_keybytes ()
 
size_t crypto_sign_bytes ()
 
int crypto_sign_detached (uint8_t sig[], unsigned long long *sig_len, const uint8_t msg[], size_t msg_len, const uint8_t sk[32])
 
size_t crypto_sign_ed25519_bytes ()
 
int crypto_sign_ed25519_detached (uint8_t sig[], unsigned long long *sig_len, const uint8_t msg[], size_t msg_len, const uint8_t sk[32])
 
int crypto_sign_ed25519_keypair (uint8_t pk[32], uint8_t sk[64])
 
size_t crypto_sign_ed25519_messagebytes_max ()
 
size_t crypto_sign_ed25519_publickeybytes ()
 
size_t crypto_sign_ed25519_secretkeybytes ()
 
int crypto_sign_ed25519_seed_keypair (uint8_t pk[], uint8_t sk[], const uint8_t seed[])
 
size_t crypto_sign_ed25519_seedbytes ()
 
int crypto_sign_ed25519_verify_detached (const uint8_t sig[], const uint8_t msg[], size_t msg_len, const uint8_t pk[32])
 
int crypto_sign_keypair (uint8_t pk[32], uint8_t sk[32])
 
size_t crypto_sign_messagebytes_max ()
 
const char * crypto_sign_primitive ()
 
size_t crypto_sign_publickeybytes ()
 
size_t crypto_sign_secretkeybytes ()
 
int crypto_sign_seed_keypair (uint8_t pk[32], uint8_t sk[32], const uint8_t seed[])
 
size_t crypto_sign_seedbytes ()
 
int crypto_sign_verify_detached (const uint8_t sig[], const uint8_t in[], size_t in_len, const uint8_t pk[32])
 
int crypto_stream (uint8_t out[], size_t out_len, const uint8_t nonce[24], const uint8_t key[32])
 
int crypto_stream_chacha20 (uint8_t out[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_stream_chacha20_ietf (uint8_t out[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_stream_chacha20_ietf_keybytes ()
 
void crypto_stream_chacha20_ietf_keygen (uint8_t k[32])
 
size_t crypto_stream_chacha20_ietf_messagebytes_max ()
 
size_t crypto_stream_chacha20_ietf_noncebytes ()
 
int crypto_stream_chacha20_ietf_xor (uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_stream_chacha20_ietf_xor_ic (uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], uint32_t ic, const uint8_t key[])
 
size_t crypto_stream_chacha20_keybytes ()
 
void crypto_stream_chacha20_keygen (uint8_t k[32])
 
size_t crypto_stream_chacha20_messagebytes_max ()
 
size_t crypto_stream_chacha20_noncebytes ()
 
int crypto_stream_chacha20_xor (uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_stream_chacha20_xor_ic (uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], uint64_t ic, const uint8_t key[])
 
size_t crypto_stream_keybytes ()
 
void crypto_stream_keygen (uint8_t key[32])
 
size_t crypto_stream_messagebytes_max ()
 
size_t crypto_stream_noncebytes ()
 
const char * crypto_stream_primitive ()
 
int crypto_stream_salsa20 (uint8_t out[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_stream_salsa20_keybytes ()
 
void crypto_stream_salsa20_keygen (uint8_t k[32])
 
size_t crypto_stream_salsa20_messagebytes_max ()
 
size_t crypto_stream_salsa20_noncebytes ()
 
int crypto_stream_salsa20_xor (uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_stream_salsa20_xor_ic (uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], uint64_t ic, const uint8_t key[])
 
int crypto_stream_xchacha20 (uint8_t out[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_stream_xchacha20_keybytes ()
 
void crypto_stream_xchacha20_keygen (uint8_t k[32])
 
size_t crypto_stream_xchacha20_messagebytes_max ()
 
size_t crypto_stream_xchacha20_noncebytes ()
 
int crypto_stream_xchacha20_xor (uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_stream_xchacha20_xor_ic (uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], uint64_t ic, const uint8_t key[])
 
int crypto_stream_xor (uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t nonce[24], const uint8_t key[32])
 
int crypto_stream_xsalsa20 (uint8_t out[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
 
size_t crypto_stream_xsalsa20_keybytes ()
 
void crypto_stream_xsalsa20_keygen (uint8_t k[32])
 
size_t crypto_stream_xsalsa20_messagebytes_max ()
 
size_t crypto_stream_xsalsa20_noncebytes ()
 
int crypto_stream_xsalsa20_xor (uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
 
int crypto_stream_xsalsa20_xor_ic (uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], uint64_t ic, const uint8_t key[])
 
int crypto_verify_16 (const uint8_t x[16], const uint8_t y[16])
 
int crypto_verify_32 (const uint8_t x[32], const uint8_t y[32])
 
int crypto_verify_64 (const uint8_t x[64], const uint8_t y[64])
 
void randombytes (uint8_t buf[], size_t buf_len)
 
void randombytes_buf (void *buf, size_t size)
 
void randombytes_buf_deterministic (void *buf, size_t size, const uint8_t seed[randombytes_SEEDBYTES])
 
int randombytes_close ()
 
const char * randombytes_implementation_name ()
 
uint32_t randombytes_random ()
 
size_t randombytes_seedbytes ()
 
void randombytes_stir ()
 
uint32_t randombytes_uniform (uint32_t upper_bound)
 
void sodium_add (uint8_t a[], const uint8_t b[], size_t len)
 
void * sodium_allocarray (size_t count, size_t size)
 
int sodium_compare (const uint8_t x[], const uint8_t y[], size_t len)
 
void sodium_free (void *ptr)
 
void sodium_increment (uint8_t n[], size_t nlen)
 
int sodium_init ()
 
int sodium_is_zero (const uint8_t nonce[], size_t nlen)
 
int sodium_library_minimal ()
 
int sodium_library_version_major ()
 
int sodium_library_version_minor ()
 
void * sodium_malloc (size_t size)
 
int sodium_memcmp (const void *x, const void *y, size_t len)
 
void sodium_memzero (void *ptr, size_t len)
 
int sodium_mprotect_noaccess (void *ptr)
 
int sodium_mprotect_readwrite (void *ptr)
 
const char * sodium_version_string ()
 

Detailed Description

The Botan::Sodium namespace contains a partial implementation of the libsodium API.

Enumeration Type Documentation

◆ Sodium_Constants

Enumerator
SODIUM_SIZE_MAX 
crypto_aead_chacha20poly1305_ABYTES 
crypto_aead_chacha20poly1305_KEYBYTES 
crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX 
crypto_aead_chacha20poly1305_NPUBBYTES 
crypto_aead_chacha20poly1305_NSECBYTES 
crypto_aead_chacha20poly1305_ietf_ABYTES 
crypto_aead_chacha20poly1305_ietf_KEYBYTES 
crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX 
crypto_aead_chacha20poly1305_ietf_NPUBBYTES 
crypto_aead_chacha20poly1305_ietf_NSECBYTES 
crypto_aead_xchacha20poly1305_ietf_ABYTES 
crypto_aead_xchacha20poly1305_ietf_KEYBYTES 
crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX 
crypto_aead_xchacha20poly1305_ietf_NPUBBYTES 
crypto_aead_xchacha20poly1305_ietf_NSECBYTES 
crypto_auth_hmacsha256_BYTES 
crypto_auth_hmacsha256_KEYBYTES 
crypto_auth_hmacsha512256_BYTES 
crypto_auth_hmacsha512256_KEYBYTES 
crypto_auth_hmacsha512_BYTES 
crypto_auth_hmacsha512_KEYBYTES 
crypto_auth_BYTES 
crypto_auth_KEYBYTES 
crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES 
crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES 
crypto_box_curve25519xsalsa20poly1305_MACBYTES 
crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX 
crypto_box_curve25519xsalsa20poly1305_NONCEBYTES 
crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES 
crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES 
crypto_box_curve25519xsalsa20poly1305_SEEDBYTES 
crypto_box_curve25519xsalsa20poly1305_ZEROBYTES 
crypto_box_BEFORENMBYTES 
crypto_box_BOXZEROBYTES 
crypto_box_MACBYTES 
crypto_box_MESSAGEBYTES_MAX 
crypto_box_NONCEBYTES 
crypto_box_PUBLICKEYBYTES 
crypto_box_SECRETKEYBYTES 
crypto_box_SEEDBYTES 
crypto_box_ZEROBYTES 
crypto_core_hchacha20_CONSTBYTES 
crypto_core_hchacha20_INPUTBYTES 
crypto_core_hchacha20_KEYBYTES 
crypto_core_hchacha20_OUTPUTBYTES 
crypto_core_hsalsa20_CONSTBYTES 
crypto_core_hsalsa20_INPUTBYTES 
crypto_core_hsalsa20_KEYBYTES 
crypto_core_hsalsa20_OUTPUTBYTES 
crypto_hash_sha256_BYTES 
crypto_hash_sha512_BYTES 
crypto_hash_BYTES 
crypto_onetimeauth_poly1305_BYTES 
crypto_onetimeauth_poly1305_KEYBYTES 
crypto_onetimeauth_BYTES 
crypto_onetimeauth_KEYBYTES 
crypto_scalarmult_curve25519_BYTES 
crypto_scalarmult_curve25519_SCALARBYTES 
crypto_scalarmult_BYTES 
crypto_scalarmult_SCALARBYTES 
crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES 
crypto_secretbox_xsalsa20poly1305_KEYBYTES 
crypto_secretbox_xsalsa20poly1305_MACBYTES 
crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX 
crypto_secretbox_xsalsa20poly1305_NONCEBYTES 
crypto_secretbox_xsalsa20poly1305_ZEROBYTES 
crypto_secretbox_BOXZEROBYTES 
crypto_secretbox_KEYBYTES 
crypto_secretbox_MACBYTES 
crypto_secretbox_MESSAGEBYTES_MAX 
crypto_secretbox_NONCEBYTES 
crypto_secretbox_ZEROBYTES 
crypto_shorthash_siphash24_BYTES 
crypto_shorthash_siphash24_KEYBYTES 
crypto_shorthash_BYTES 
crypto_shorthash_KEYBYTES 
crypto_sign_ed25519_BYTES 
crypto_sign_ed25519_MESSAGEBYTES_MAX 
crypto_sign_ed25519_PUBLICKEYBYTES 
crypto_sign_ed25519_SECRETKEYBYTES 
crypto_sign_ed25519_SEEDBYTES 
crypto_sign_BYTES 
crypto_sign_MESSAGEBYTES_MAX 
crypto_sign_PUBLICKEYBYTES 
crypto_sign_SECRETKEYBYTES 
crypto_sign_SEEDBYTES 
crypto_stream_chacha20_KEYBYTES 
crypto_stream_chacha20_MESSAGEBYTES_MAX 
crypto_stream_chacha20_NONCEBYTES 
crypto_stream_chacha20_ietf_KEYBYTES 
crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX 
crypto_stream_chacha20_ietf_NONCEBYTES 
crypto_stream_salsa20_KEYBYTES 
crypto_stream_salsa20_MESSAGEBYTES_MAX 
crypto_stream_salsa20_NONCEBYTES 
crypto_stream_xchacha20_KEYBYTES 
crypto_stream_xchacha20_MESSAGEBYTES_MAX 
crypto_stream_xchacha20_NONCEBYTES 
crypto_stream_xsalsa20_KEYBYTES 
crypto_stream_xsalsa20_MESSAGEBYTES_MAX 
crypto_stream_xsalsa20_NONCEBYTES 
crypto_stream_KEYBYTES 
crypto_stream_MESSAGEBYTES_MAX 
crypto_stream_NONCEBYTES 
crypto_verify_16_BYTES 
crypto_verify_32_BYTES 
crypto_verify_64_BYTES 
randombytes_SEEDBYTES 

Definition at line 19 of file sodium.h.

19 : size_t {
20 SODIUM_SIZE_MAX = 0xFFFFFFFF,
21
27
33
39
46
49
60
70
75
80
84
89
94
102
109
114
117 crypto_sign_ed25519_PUBLICKEYBYTES = 32,
118 crypto_sign_ed25519_SECRETKEYBYTES = (32 + 32),
125
144
148
150};
@ crypto_stream_salsa20_NONCEBYTES
Definition sodium.h:134
@ crypto_stream_MESSAGEBYTES_MAX
Definition sodium.h:142
@ crypto_aead_chacha20poly1305_ietf_NSECBYTES
Definition sodium.h:32
@ crypto_shorthash_KEYBYTES
Definition sodium.h:113
@ crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES
Definition sodium.h:55
@ crypto_scalarmult_SCALARBYTES
Definition sodium.h:93
@ crypto_box_MESSAGEBYTES_MAX
Definition sodium.h:64
@ crypto_box_NONCEBYTES
Definition sodium.h:65
@ crypto_aead_chacha20poly1305_NPUBBYTES
Definition sodium.h:25
@ crypto_sign_ed25519_SECRETKEYBYTES
Definition sodium.h:118
@ crypto_sign_MESSAGEBYTES_MAX
Definition sodium.h:121
@ crypto_scalarmult_curve25519_SCALARBYTES
Definition sodium.h:91
@ crypto_auth_hmacsha256_KEYBYTES
Definition sodium.h:41
@ crypto_auth_BYTES
Definition sodium.h:47
@ crypto_auth_hmacsha256_BYTES
Definition sodium.h:40
@ crypto_aead_xchacha20poly1305_ietf_NSECBYTES
Definition sodium.h:38
@ crypto_sign_BYTES
Definition sodium.h:120
@ crypto_core_hsalsa20_INPUTBYTES
Definition sodium.h:77
@ crypto_onetimeauth_BYTES
Definition sodium.h:87
@ crypto_secretbox_xsalsa20poly1305_NONCEBYTES
Definition sodium.h:99
@ crypto_aead_chacha20poly1305_ietf_ABYTES
Definition sodium.h:28
@ crypto_aead_chacha20poly1305_NSECBYTES
Definition sodium.h:26
@ crypto_verify_16_BYTES
Definition sodium.h:145
@ crypto_shorthash_siphash24_KEYBYTES
Definition sodium.h:111
@ crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES
Definition sodium.h:51
@ crypto_sign_PUBLICKEYBYTES
Definition sodium.h:122
@ crypto_shorthash_BYTES
Definition sodium.h:112
@ crypto_stream_xsalsa20_MESSAGEBYTES_MAX
Definition sodium.h:139
@ crypto_stream_chacha20_ietf_KEYBYTES
Definition sodium.h:129
@ crypto_secretbox_KEYBYTES
Definition sodium.h:104
@ crypto_hash_BYTES
Definition sodium.h:83
@ crypto_aead_chacha20poly1305_ietf_NPUBBYTES
Definition sodium.h:31
@ crypto_secretbox_ZEROBYTES
Definition sodium.h:108
@ crypto_sign_ed25519_PUBLICKEYBYTES
Definition sodium.h:117
@ crypto_box_ZEROBYTES
Definition sodium.h:69
@ crypto_secretbox_xsalsa20poly1305_ZEROBYTES
Definition sodium.h:100
@ crypto_stream_xchacha20_MESSAGEBYTES_MAX
Definition sodium.h:136
@ crypto_onetimeauth_poly1305_KEYBYTES
Definition sodium.h:86
@ crypto_auth_KEYBYTES
Definition sodium.h:48
@ crypto_box_curve25519xsalsa20poly1305_NONCEBYTES
Definition sodium.h:54
@ crypto_core_hchacha20_OUTPUTBYTES
Definition sodium.h:74
@ crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES
Definition sodium.h:56
@ crypto_stream_xsalsa20_KEYBYTES
Definition sodium.h:138
@ crypto_core_hchacha20_CONSTBYTES
Definition sodium.h:71
@ crypto_stream_chacha20_ietf_NONCEBYTES
Definition sodium.h:131
@ crypto_aead_chacha20poly1305_KEYBYTES
Definition sodium.h:23
@ crypto_sign_ed25519_BYTES
Definition sodium.h:115
@ crypto_stream_salsa20_MESSAGEBYTES_MAX
Definition sodium.h:133
@ crypto_stream_xchacha20_KEYBYTES
Definition sodium.h:135
@ crypto_secretbox_xsalsa20poly1305_KEYBYTES
Definition sodium.h:96
@ crypto_aead_xchacha20poly1305_ietf_KEYBYTES
Definition sodium.h:35
@ crypto_sign_ed25519_MESSAGEBYTES_MAX
Definition sodium.h:116
@ crypto_verify_64_BYTES
Definition sodium.h:147
@ crypto_secretbox_MACBYTES
Definition sodium.h:105
@ crypto_stream_chacha20_MESSAGEBYTES_MAX
Definition sodium.h:127
@ crypto_core_hsalsa20_CONSTBYTES
Definition sodium.h:76
@ crypto_aead_chacha20poly1305_ietf_KEYBYTES
Definition sodium.h:29
@ crypto_stream_NONCEBYTES
Definition sodium.h:143
@ crypto_auth_hmacsha512_BYTES
Definition sodium.h:44
@ crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX
Definition sodium.h:130
@ crypto_box_curve25519xsalsa20poly1305_MACBYTES
Definition sodium.h:52
@ crypto_stream_xchacha20_NONCEBYTES
Definition sodium.h:137
@ crypto_scalarmult_curve25519_BYTES
Definition sodium.h:90
@ crypto_aead_chacha20poly1305_ABYTES
Definition sodium.h:22
@ crypto_sign_SECRETKEYBYTES
Definition sodium.h:123
@ crypto_box_BEFORENMBYTES
Definition sodium.h:61
@ crypto_box_BOXZEROBYTES
Definition sodium.h:62
@ crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX
Definition sodium.h:30
@ crypto_box_curve25519xsalsa20poly1305_ZEROBYTES
Definition sodium.h:58
@ randombytes_SEEDBYTES
Definition sodium.h:149
@ crypto_sign_ed25519_SEEDBYTES
Definition sodium.h:119
@ crypto_stream_chacha20_NONCEBYTES
Definition sodium.h:128
@ crypto_stream_chacha20_KEYBYTES
Definition sodium.h:126
@ crypto_stream_KEYBYTES
Definition sodium.h:141
@ crypto_box_PUBLICKEYBYTES
Definition sodium.h:66
@ crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX
Definition sodium.h:53
@ crypto_scalarmult_BYTES
Definition sodium.h:92
@ crypto_secretbox_NONCEBYTES
Definition sodium.h:107
@ crypto_core_hsalsa20_OUTPUTBYTES
Definition sodium.h:79
@ crypto_box_MACBYTES
Definition sodium.h:63
@ crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES
Definition sodium.h:95
@ crypto_hash_sha512_BYTES
Definition sodium.h:82
@ crypto_onetimeauth_poly1305_BYTES
Definition sodium.h:85
@ crypto_box_SEEDBYTES
Definition sodium.h:68
@ crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX
Definition sodium.h:24
@ crypto_verify_32_BYTES
Definition sodium.h:146
@ crypto_box_SECRETKEYBYTES
Definition sodium.h:67
@ crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX
Definition sodium.h:98
@ crypto_auth_hmacsha512256_KEYBYTES
Definition sodium.h:43
@ crypto_sign_SEEDBYTES
Definition sodium.h:124
@ crypto_aead_xchacha20poly1305_ietf_ABYTES
Definition sodium.h:34
@ crypto_auth_hmacsha512_KEYBYTES
Definition sodium.h:45
@ crypto_core_hchacha20_KEYBYTES
Definition sodium.h:73
@ crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
Definition sodium.h:37
@ crypto_onetimeauth_KEYBYTES
Definition sodium.h:88
@ crypto_auth_hmacsha512256_BYTES
Definition sodium.h:42
@ crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES
Definition sodium.h:50
@ crypto_stream_xsalsa20_NONCEBYTES
Definition sodium.h:140
@ crypto_core_hsalsa20_KEYBYTES
Definition sodium.h:78
@ crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX
Definition sodium.h:36
@ crypto_secretbox_xsalsa20poly1305_MACBYTES
Definition sodium.h:97
@ crypto_hash_sha256_BYTES
Definition sodium.h:81
@ SODIUM_SIZE_MAX
Definition sodium.h:20
@ crypto_stream_salsa20_KEYBYTES
Definition sodium.h:132
@ crypto_secretbox_BOXZEROBYTES
Definition sodium.h:103
@ crypto_secretbox_MESSAGEBYTES_MAX
Definition sodium.h:106
@ crypto_shorthash_siphash24_BYTES
Definition sodium.h:110
@ crypto_core_hchacha20_INPUTBYTES
Definition sodium.h:72
@ crypto_box_curve25519xsalsa20poly1305_SEEDBYTES
Definition sodium.h:57

Function Documentation

◆ crypto_aead_chacha20poly1305_abytes()

size_t Botan::Sodium::crypto_aead_chacha20poly1305_abytes ( )
inline

Definition at line 444 of file sodium.h.

444 {
446}

References crypto_aead_chacha20poly1305_ABYTES.

◆ crypto_aead_chacha20poly1305_decrypt()

int Botan::Sodium::crypto_aead_chacha20poly1305_decrypt ( uint8_t m[],
unsigned long long * ptext_len,
uint8_t unused_secret_nonce[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t ad[],
size_t ad_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 221 of file sodium_aead.cpp.

229 {
230 BOTAN_UNUSED(unused_secret_nonce);
231 return sodium_aead_chacha20poly1305_decrypt(
232 ptext, ptext_len, ctext, ctext_len, ad, ad_len, nonce, crypto_aead_chacha20poly1305_npubbytes(), key);
233}
#define BOTAN_UNUSED
Definition assert.h:118
size_t crypto_aead_chacha20poly1305_npubbytes()
Definition sodium.h:440

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_npubbytes().

◆ crypto_aead_chacha20poly1305_decrypt_detached()

int Botan::Sodium::crypto_aead_chacha20poly1305_decrypt_detached ( uint8_t m[],
uint8_t unused_secret_nonce[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t mac[],
const uint8_t ad[],
size_t ad_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 254 of file sodium_aead.cpp.

262 {
263 BOTAN_UNUSED(unused_secret_nonce);
264
265 return sodium_aead_chacha20poly1305_decrypt_detached(
266 ptext, ctext, ctext_len, mac, ad, ad_len, nonce, crypto_aead_chacha20poly1305_npubbytes(), key);
267}

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_npubbytes().

◆ crypto_aead_chacha20poly1305_encrypt()

int Botan::Sodium::crypto_aead_chacha20poly1305_encrypt ( uint8_t ctext[],
unsigned long long * ctext_len,
const uint8_t ptext[],
size_t ptext_len,
const uint8_t ad[],
size_t ad_len,
const uint8_t unused_secret_nonce[],
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 207 of file sodium_aead.cpp.

215 {
216 BOTAN_UNUSED(unused_secret_nonce);
217 return sodium_aead_chacha20poly1305_encrypt(
218 ctext, ctext_len, ptext, ptext_len, ad, ad_len, nonce, crypto_aead_chacha20poly1305_npubbytes(), key);
219}

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_npubbytes().

◆ crypto_aead_chacha20poly1305_encrypt_detached()

int Botan::Sodium::crypto_aead_chacha20poly1305_encrypt_detached ( uint8_t ctext[],
uint8_t mac[],
unsigned long long * mac_len,
const uint8_t ptext[],
size_t ptext_len,
const uint8_t ad[],
size_t ad_len,
const uint8_t unused_secret_nonce[],
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 235 of file sodium_aead.cpp.

244 {
245 BOTAN_UNUSED(unused_secret_nonce);
246 if(mac_len) {
247 *mac_len = 16;
248 }
249
250 return sodium_aead_chacha20poly1305_encrypt_detached(
251 ctext, mac, ptext, ptext_len, ad, ad_len, nonce, crypto_aead_chacha20poly1305_npubbytes(), key);
252}

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_npubbytes().

◆ crypto_aead_chacha20poly1305_ietf_abytes()

size_t Botan::Sodium::crypto_aead_chacha20poly1305_ietf_abytes ( )
inline

Definition at line 375 of file sodium.h.

References crypto_aead_chacha20poly1305_ietf_ABYTES.

◆ crypto_aead_chacha20poly1305_ietf_decrypt()

int Botan::Sodium::crypto_aead_chacha20poly1305_ietf_decrypt ( uint8_t ptext[],
unsigned long long * ptext_len,
uint8_t unused_secret_nonce[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t ad[],
size_t ad_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 157 of file sodium_aead.cpp.

165 {
166 BOTAN_UNUSED(unused_secret_nonce);
167
168 return sodium_aead_chacha20poly1305_decrypt(
169 ptext, ptext_len, ctext, ctext_len, ad, ad_len, nonce, crypto_aead_chacha20poly1305_ietf_npubbytes(), key);
170}
size_t crypto_aead_chacha20poly1305_ietf_npubbytes()
Definition sodium.h:371

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_ietf_npubbytes().

◆ crypto_aead_chacha20poly1305_ietf_decrypt_detached()

int Botan::Sodium::crypto_aead_chacha20poly1305_ietf_decrypt_detached ( uint8_t m[],
uint8_t unused_secret_nonce[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t mac[],
const uint8_t ad[],
size_t ad_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 192 of file sodium_aead.cpp.

200 {
201 BOTAN_UNUSED(unused_secret_nonce);
202
203 return sodium_aead_chacha20poly1305_decrypt_detached(
204 ptext, ctext, ctext_len, mac, ad, ad_len, nonce, crypto_aead_chacha20poly1305_ietf_npubbytes(), key);
205}

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_ietf_npubbytes().

◆ crypto_aead_chacha20poly1305_ietf_encrypt()

int Botan::Sodium::crypto_aead_chacha20poly1305_ietf_encrypt ( uint8_t ctext[],
unsigned long long * ctext_len,
const uint8_t ptext[],
size_t ptext_len,
const uint8_t ad[],
size_t ad_len,
const uint8_t unused_secret_nonce[],
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 142 of file sodium_aead.cpp.

150 {
151 BOTAN_UNUSED(unused_secret_nonce);
152
153 return sodium_aead_chacha20poly1305_encrypt(
154 ctext, ctext_len, ptext, ptext_len, ad, ad_len, nonce, crypto_aead_chacha20poly1305_ietf_npubbytes(), key);
155}

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_ietf_npubbytes().

◆ crypto_aead_chacha20poly1305_ietf_encrypt_detached()

int Botan::Sodium::crypto_aead_chacha20poly1305_ietf_encrypt_detached ( uint8_t ctext[],
uint8_t mac[],
unsigned long long * mac_len,
const uint8_t ptext[],
size_t ptext_len,
const uint8_t ad[],
size_t ad_len,
const uint8_t unused_secret_nonce[],
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 172 of file sodium_aead.cpp.

181 {
182 BOTAN_UNUSED(unused_secret_nonce);
183
184 if(mac_len) {
185 *mac_len = 16;
186 }
187
188 return sodium_aead_chacha20poly1305_encrypt_detached(
189 ctext, mac, ptext, ptext_len, ad, ad_len, nonce, crypto_aead_chacha20poly1305_ietf_npubbytes(), key);
190}

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_ietf_npubbytes().

◆ crypto_aead_chacha20poly1305_ietf_keybytes()

size_t Botan::Sodium::crypto_aead_chacha20poly1305_ietf_keybytes ( )
inline

Definition at line 363 of file sodium.h.

References crypto_aead_chacha20poly1305_ietf_KEYBYTES.

◆ crypto_aead_chacha20poly1305_ietf_keygen()

void Botan::Sodium::crypto_aead_chacha20poly1305_ietf_keygen ( uint8_t k[32])
inline

Definition at line 428 of file sodium.h.

428 {
429 return randombytes_buf(k, crypto_aead_chacha20poly1305_ietf_KEYBYTES);
430}
void randombytes_buf(void *buf, size_t size)

References crypto_aead_chacha20poly1305_ietf_KEYBYTES, and randombytes_buf().

◆ crypto_aead_chacha20poly1305_ietf_messagebytes_max()

size_t Botan::Sodium::crypto_aead_chacha20poly1305_ietf_messagebytes_max ( )
inline

◆ crypto_aead_chacha20poly1305_ietf_npubbytes()

size_t Botan::Sodium::crypto_aead_chacha20poly1305_ietf_npubbytes ( )
inline

◆ crypto_aead_chacha20poly1305_ietf_nsecbytes()

size_t Botan::Sodium::crypto_aead_chacha20poly1305_ietf_nsecbytes ( )
inline

Definition at line 367 of file sodium.h.

References crypto_aead_chacha20poly1305_ietf_NSECBYTES.

◆ crypto_aead_chacha20poly1305_keybytes()

size_t Botan::Sodium::crypto_aead_chacha20poly1305_keybytes ( )
inline

Definition at line 432 of file sodium.h.

432 {
434}

References crypto_aead_chacha20poly1305_KEYBYTES.

◆ crypto_aead_chacha20poly1305_keygen()

void Botan::Sodium::crypto_aead_chacha20poly1305_keygen ( uint8_t k[32])
inline

Definition at line 497 of file sodium.h.

497 {
498 randombytes_buf(k, 32);
499}

References randombytes_buf().

◆ crypto_aead_chacha20poly1305_messagebytes_max()

size_t Botan::Sodium::crypto_aead_chacha20poly1305_messagebytes_max ( )
inline

Definition at line 448 of file sodium.h.

References crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX.

◆ crypto_aead_chacha20poly1305_npubbytes()

size_t Botan::Sodium::crypto_aead_chacha20poly1305_npubbytes ( )
inline

◆ crypto_aead_chacha20poly1305_nsecbytes()

size_t Botan::Sodium::crypto_aead_chacha20poly1305_nsecbytes ( )
inline

Definition at line 436 of file sodium.h.

References crypto_aead_chacha20poly1305_NSECBYTES.

◆ crypto_aead_xchacha20poly1305_ietf_abytes()

size_t Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_abytes ( )
inline

Definition at line 515 of file sodium.h.

References crypto_aead_xchacha20poly1305_ietf_ABYTES.

◆ crypto_aead_xchacha20poly1305_ietf_decrypt()

int Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_decrypt ( uint8_t ptext[],
unsigned long long * ptext_len,
uint8_t unused_secret_nonce[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t ad[],
size_t ad_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 284 of file sodium_aead.cpp.

292 {
293 BOTAN_UNUSED(unused_secret_nonce);
294
295 return sodium_aead_chacha20poly1305_decrypt(
296 ptext, ptext_len, ctext, ctext_len, ad, ad_len, nonce, crypto_aead_xchacha20poly1305_ietf_npubbytes(), key);
297}
size_t crypto_aead_xchacha20poly1305_ietf_npubbytes()
Definition sodium.h:511

References BOTAN_UNUSED, and crypto_aead_xchacha20poly1305_ietf_npubbytes().

◆ crypto_aead_xchacha20poly1305_ietf_decrypt_detached()

int Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_decrypt_detached ( uint8_t ptext[],
uint8_t unused_secret_nonce[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t mac[],
const uint8_t ad[],
size_t ad_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 318 of file sodium_aead.cpp.

326 {
327 BOTAN_UNUSED(unused_secret_nonce);
328 return sodium_aead_chacha20poly1305_decrypt_detached(
329 ptext, ctext, ctext_len, mac, ad, ad_len, nonce, crypto_aead_xchacha20poly1305_ietf_npubbytes(), key);
330}

References BOTAN_UNUSED, and crypto_aead_xchacha20poly1305_ietf_npubbytes().

◆ crypto_aead_xchacha20poly1305_ietf_encrypt()

int Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_encrypt ( uint8_t ctext[],
unsigned long long * ctext_len,
const uint8_t ptext[],
size_t ptext_len,
const uint8_t ad[],
size_t ad_len,
const uint8_t unused_secret_nonce[],
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 269 of file sodium_aead.cpp.

277 {
278 BOTAN_UNUSED(unused_secret_nonce);
279
280 return sodium_aead_chacha20poly1305_encrypt(
281 ctext, ctext_len, ptext, ptext_len, ad, ad_len, nonce, crypto_aead_xchacha20poly1305_ietf_npubbytes(), key);
282}

References BOTAN_UNUSED, and crypto_aead_xchacha20poly1305_ietf_npubbytes().

◆ crypto_aead_xchacha20poly1305_ietf_encrypt_detached()

int Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_encrypt_detached ( uint8_t ctext[],
uint8_t mac[],
unsigned long long * mac_len,
const uint8_t ptext[],
size_t ptext_len,
const uint8_t ad[],
size_t ad_len,
const uint8_t unused_secret_nonce[],
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 299 of file sodium_aead.cpp.

308 {
309 BOTAN_UNUSED(unused_secret_nonce);
310 if(mac_len) {
311 *mac_len = 16;
312 }
313
314 return sodium_aead_chacha20poly1305_encrypt_detached(
315 ctext, mac, ptext, ptext_len, ad, ad_len, nonce, crypto_aead_xchacha20poly1305_ietf_npubbytes(), key);
316}

References BOTAN_UNUSED, and crypto_aead_xchacha20poly1305_ietf_npubbytes().

◆ crypto_aead_xchacha20poly1305_ietf_keybytes()

size_t Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_keybytes ( )
inline

Definition at line 503 of file sodium.h.

References crypto_aead_xchacha20poly1305_ietf_KEYBYTES.

◆ crypto_aead_xchacha20poly1305_ietf_keygen()

void Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_keygen ( uint8_t k[32])
inline

Definition at line 568 of file sodium.h.

568 {
569 return randombytes_buf(k, 32);
570}

References randombytes_buf().

◆ crypto_aead_xchacha20poly1305_ietf_messagebytes_max()

size_t Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_messagebytes_max ( )
inline

◆ crypto_aead_xchacha20poly1305_ietf_npubbytes()

size_t Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_npubbytes ( )
inline

◆ crypto_aead_xchacha20poly1305_ietf_nsecbytes()

size_t Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_nsecbytes ( )
inline

Definition at line 507 of file sodium.h.

References crypto_aead_xchacha20poly1305_ietf_NSECBYTES.

◆ crypto_auth()

int Botan::Sodium::crypto_auth ( uint8_t out[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )
inline

Definition at line 864 of file sodium.h.

864 {
865 return crypto_auth_hmacsha512256(out, in, in_len, key);
866}
int crypto_auth_hmacsha512256(uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])

References crypto_auth_hmacsha512256().

◆ crypto_auth_bytes()

size_t Botan::Sodium::crypto_auth_bytes ( )
inline

Definition at line 852 of file sodium.h.

852 {
853 return crypto_auth_BYTES;
854}

References crypto_auth_BYTES.

◆ crypto_auth_hmacsha256()

int Botan::Sodium::crypto_auth_hmacsha256 ( uint8_t out[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )

Definition at line 88 of file sodium_auth.cpp.

88 {
89 auto mac = MessageAuthenticationCode::create_or_throw("HMAC(SHA-256)");
90 mac->set_key(key, crypto_auth_hmacsha256_KEYBYTES);
91 mac->update(in, in_len);
92 mac->final(out);
93 return 0;
94}

References Botan::MessageAuthenticationCode::create_or_throw(), and crypto_auth_hmacsha256_KEYBYTES.

Referenced by crypto_auth_hmacsha256_verify().

◆ crypto_auth_hmacsha256_bytes()

size_t Botan::Sodium::crypto_auth_hmacsha256_bytes ( )
inline

Definition at line 887 of file sodium.h.

887 {
889}

References crypto_auth_hmacsha256_BYTES.

◆ crypto_auth_hmacsha256_keybytes()

size_t Botan::Sodium::crypto_auth_hmacsha256_keybytes ( )
inline

Definition at line 891 of file sodium.h.

891 {
893}

References crypto_auth_hmacsha256_KEYBYTES.

◆ crypto_auth_hmacsha256_keygen()

void Botan::Sodium::crypto_auth_hmacsha256_keygen ( uint8_t k[32])
inline

Definition at line 901 of file sodium.h.

901 {
902 return randombytes_buf(k, 32);
903}

References randombytes_buf().

◆ crypto_auth_hmacsha256_verify()

int Botan::Sodium::crypto_auth_hmacsha256_verify ( const uint8_t h[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )

Definition at line 96 of file sodium_auth.cpp.

96 {
97 secure_vector<uint8_t> computed(crypto_auth_hmacsha256_BYTES);
98 crypto_auth_hmacsha256(computed.data(), in, in_len, key);
99 return crypto_verify_32(computed.data(), mac) ? 0 : -1;
100}
int crypto_verify_32(const uint8_t x[32], const uint8_t y[32])
int crypto_auth_hmacsha256(uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61

References crypto_auth_hmacsha256(), crypto_auth_hmacsha256_BYTES, and crypto_verify_32().

◆ crypto_auth_hmacsha512()

int Botan::Sodium::crypto_auth_hmacsha512 ( uint8_t out[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )

Definition at line 53 of file sodium_auth.cpp.

53 {
54 auto mac = MessageAuthenticationCode::create_or_throw("HMAC(SHA-512)");
55 mac->set_key(key, crypto_auth_hmacsha512_KEYBYTES);
56 mac->update(in, in_len);
57 mac->final(out);
58 return 0;
59}

References Botan::MessageAuthenticationCode::create_or_throw(), and crypto_auth_hmacsha512_KEYBYTES.

Referenced by crypto_auth_hmacsha512_verify().

◆ crypto_auth_hmacsha512256()

int Botan::Sodium::crypto_auth_hmacsha512256 ( uint8_t out[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )

Definition at line 67 of file sodium_auth.cpp.

67 {
68 auto mac = MessageAuthenticationCode::create_or_throw("HMAC(SHA-512)");
69 mac->set_key(key, crypto_auth_hmacsha512256_KEYBYTES);
70 mac->update(in, in_len);
71
73 mac->final(buf);
74
75 copy_mem(out, buf.data(), crypto_auth_hmacsha512256_BYTES);
76 return 0;
77}
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:146

References Botan::copy_mem(), Botan::MessageAuthenticationCode::create_or_throw(), crypto_auth_hmacsha512256_BYTES, and crypto_auth_hmacsha512256_KEYBYTES.

Referenced by crypto_auth(), and crypto_auth_hmacsha512256_verify().

◆ crypto_auth_hmacsha512256_bytes()

size_t Botan::Sodium::crypto_auth_hmacsha512256_bytes ( )
inline

Definition at line 832 of file sodium.h.

832 {
834}

References crypto_auth_hmacsha512256_BYTES.

◆ crypto_auth_hmacsha512256_keybytes()

size_t Botan::Sodium::crypto_auth_hmacsha512256_keybytes ( )
inline

Definition at line 836 of file sodium.h.

836 {
838}

References crypto_auth_hmacsha512256_KEYBYTES.

◆ crypto_auth_hmacsha512256_keygen()

void Botan::Sodium::crypto_auth_hmacsha512256_keygen ( uint8_t k[32])
inline

Definition at line 846 of file sodium.h.

846 {
847 return randombytes_buf(k, 32);
848}

References randombytes_buf().

◆ crypto_auth_hmacsha512256_verify()

int Botan::Sodium::crypto_auth_hmacsha512256_verify ( const uint8_t h[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )

Definition at line 79 of file sodium_auth.cpp.

82 {
83 secure_vector<uint8_t> computed(crypto_auth_hmacsha512256_BYTES);
84 crypto_auth_hmacsha512256(computed.data(), in, in_len, key);
85 return crypto_verify_32(computed.data(), mac) ? 0 : -1;
86}

References crypto_auth_hmacsha512256(), crypto_auth_hmacsha512256_BYTES, and crypto_verify_32().

Referenced by crypto_auth_verify().

◆ crypto_auth_hmacsha512_bytes()

size_t Botan::Sodium::crypto_auth_hmacsha512_bytes ( )
inline

Definition at line 812 of file sodium.h.

812 {
814}

References crypto_auth_hmacsha512_BYTES.

◆ crypto_auth_hmacsha512_keybytes()

size_t Botan::Sodium::crypto_auth_hmacsha512_keybytes ( )
inline

Definition at line 816 of file sodium.h.

816 {
818}

References crypto_auth_hmacsha512_KEYBYTES.

◆ crypto_auth_hmacsha512_keygen()

void Botan::Sodium::crypto_auth_hmacsha512_keygen ( uint8_t k[32])
inline

Definition at line 826 of file sodium.h.

826 {
827 return randombytes_buf(k, 32);
828}

References randombytes_buf().

◆ crypto_auth_hmacsha512_verify()

int Botan::Sodium::crypto_auth_hmacsha512_verify ( const uint8_t h[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )

Definition at line 61 of file sodium_auth.cpp.

61 {
62 secure_vector<uint8_t> computed(crypto_auth_hmacsha512_BYTES);
63 crypto_auth_hmacsha512(computed.data(), in, in_len, key);
64 return crypto_verify_64(computed.data(), mac) ? 0 : -1;
65}
int crypto_auth_hmacsha512(uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
int crypto_verify_64(const uint8_t x[64], const uint8_t y[64])

References crypto_auth_hmacsha512(), crypto_auth_hmacsha512_BYTES, and crypto_verify_64().

◆ crypto_auth_keybytes()

size_t Botan::Sodium::crypto_auth_keybytes ( )
inline

Definition at line 856 of file sodium.h.

856 {
858}

References crypto_auth_KEYBYTES.

◆ crypto_auth_keygen()

void Botan::Sodium::crypto_auth_keygen ( uint8_t k[])
inline

Definition at line 872 of file sodium.h.

872 {
873 return randombytes_buf(k, crypto_auth_KEYBYTES);
874}

References crypto_auth_KEYBYTES, and randombytes_buf().

◆ crypto_auth_primitive()

const char * Botan::Sodium::crypto_auth_primitive ( )
inline

Definition at line 860 of file sodium.h.

860 {
861 return "hmacsha512256";
862}

◆ crypto_auth_verify()

int Botan::Sodium::crypto_auth_verify ( const uint8_t mac[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )
inline

Definition at line 868 of file sodium.h.

868 {
869 return crypto_auth_hmacsha512256_verify(mac, in, in_len, key);
870}
int crypto_auth_hmacsha512256_verify(const uint8_t h[], const uint8_t in[], size_t in_len, const uint8_t key[])

References crypto_auth_hmacsha512256_verify().

◆ crypto_box()

int Botan::Sodium::crypto_box ( uint8_t ctext[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t pk[32],
const uint8_t sk[32] )
inline

Definition at line 783 of file sodium.h.

788 {
789 return crypto_box_curve25519xsalsa20poly1305(ctext, ptext, ptext_len, nonce, pk, sk);
790}
int crypto_box_curve25519xsalsa20poly1305(uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])

References crypto_box_curve25519xsalsa20poly1305().

◆ crypto_box_afternm()

int Botan::Sodium::crypto_box_afternm ( uint8_t ctext[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 732 of file sodium.h.

733 {
734 return crypto_box_curve25519xsalsa20poly1305_afternm(ctext, ptext, ptext_len, nonce, key);
735}
int crypto_box_curve25519xsalsa20poly1305_afternm(uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
Definition sodium.h:635

References crypto_box_curve25519xsalsa20poly1305_afternm().

◆ crypto_box_beforenm()

int Botan::Sodium::crypto_box_beforenm ( uint8_t key[],
const uint8_t pk[32],
const uint8_t sk[32] )
inline

Definition at line 728 of file sodium.h.

728 {
730}
int crypto_box_curve25519xsalsa20poly1305_beforenm(uint8_t key[], const uint8_t pk[32], const uint8_t sk[32])

References crypto_box_curve25519xsalsa20poly1305_beforenm().

Referenced by crypto_box_detached(), and crypto_box_open_detached().

◆ crypto_box_beforenmbytes()

size_t Botan::Sodium::crypto_box_beforenmbytes ( )
inline

Definition at line 671 of file sodium.h.

671 {
673}

References crypto_box_BEFORENMBYTES.

◆ crypto_box_boxzerobytes()

size_t Botan::Sodium::crypto_box_boxzerobytes ( )
inline

Definition at line 779 of file sodium.h.

779 {
781}

References crypto_box_BOXZEROBYTES.

◆ crypto_box_curve25519xsalsa20poly1305()

int Botan::Sodium::crypto_box_curve25519xsalsa20poly1305 ( uint8_t ctext[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t pk[32],
const uint8_t sk[32] )

Definition at line 37 of file sodium_box.cpp.

42 {
43 secure_vector<uint8_t> shared(32);
44
45 if(crypto_box_curve25519xsalsa20poly1305_beforenm(shared.data(), pk, sk) != 0) {
46 return -1;
47 }
48
49 return crypto_box_curve25519xsalsa20poly1305_afternm(ctext, ptext, ptext_len, nonce, shared.data());
50}

References crypto_box_curve25519xsalsa20poly1305_afternm(), and crypto_box_curve25519xsalsa20poly1305_beforenm().

Referenced by crypto_box().

◆ crypto_box_curve25519xsalsa20poly1305_afternm()

int Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_afternm ( uint8_t ctext[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 635 of file sodium.h.

636 {
637 return crypto_secretbox_xsalsa20poly1305(ctext, ptext, ptext_len, nonce, key);
638}
int crypto_secretbox_xsalsa20poly1305(uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])

References crypto_secretbox_xsalsa20poly1305().

Referenced by crypto_box_afternm(), and crypto_box_curve25519xsalsa20poly1305().

◆ crypto_box_curve25519xsalsa20poly1305_beforenm()

int Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_beforenm ( uint8_t key[],
const uint8_t pk[32],
const uint8_t sk[32] )

Definition at line 26 of file sodium_box.cpp.

26 {
27 const uint8_t zero[16] = {0};
28 secure_vector<uint8_t> shared(32);
29
30 if(crypto_scalarmult_curve25519(shared.data(), sk, pk) != 0) {
31 return -1;
32 }
33
34 return crypto_core_hsalsa20(key, zero, shared.data(), nullptr);
35}

References crypto_core_hsalsa20(), and crypto_scalarmult_curve25519().

Referenced by crypto_box_beforenm(), crypto_box_curve25519xsalsa20poly1305(), and crypto_box_curve25519xsalsa20poly1305_open().

◆ crypto_box_curve25519xsalsa20poly1305_beforenmbytes()

size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_beforenmbytes ( )
inline

◆ crypto_box_curve25519xsalsa20poly1305_boxzerobytes()

size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_boxzerobytes ( )
inline

◆ crypto_box_curve25519xsalsa20poly1305_keypair()

int Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_keypair ( uint8_t pk[32],
uint8_t sk[32] )

Definition at line 21 of file sodium_box.cpp.

21 {
22 randombytes_buf(sk, 32);
24}
int crypto_scalarmult_curve25519_base(uint8_t out[32], const uint8_t scalar[32])

References crypto_scalarmult_curve25519_base(), and randombytes_buf().

Referenced by crypto_box_keypair().

◆ crypto_box_curve25519xsalsa20poly1305_macbytes()

size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_macbytes ( )
inline

◆ crypto_box_curve25519xsalsa20poly1305_messagebytes_max()

size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_messagebytes_max ( )
inline

◆ crypto_box_curve25519xsalsa20poly1305_noncebytes()

size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_noncebytes ( )
inline

◆ crypto_box_curve25519xsalsa20poly1305_open()

int Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_open ( uint8_t ptext[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t pk[32],
const uint8_t sk[32] )

Definition at line 52 of file sodium_box.cpp.

57 {
58 secure_vector<uint8_t> shared(32);
59
60 if(crypto_box_curve25519xsalsa20poly1305_beforenm(shared.data(), pk, sk) != 0) {
61 return -1;
62 }
63
64 return crypto_box_curve25519xsalsa20poly1305_open_afternm(ptext, ctext, ctext_len, nonce, shared.data());
65}

References crypto_box_curve25519xsalsa20poly1305_beforenm(), and crypto_box_curve25519xsalsa20poly1305_open_afternm().

Referenced by crypto_box_open().

◆ crypto_box_curve25519xsalsa20poly1305_open_afternm()

int Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_open_afternm ( uint8_t ptext[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 640 of file sodium.h.

641 {
642 return crypto_secretbox_xsalsa20poly1305_open(ptext, ctext, ctext_len, nonce, key);
643}
int crypto_secretbox_xsalsa20poly1305_open(uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])

References crypto_secretbox_xsalsa20poly1305_open().

Referenced by crypto_box_curve25519xsalsa20poly1305_open(), and crypto_box_open_afternm().

◆ crypto_box_curve25519xsalsa20poly1305_publickeybytes()

size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_publickeybytes ( )
inline

◆ crypto_box_curve25519xsalsa20poly1305_secretkeybytes()

size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_secretkeybytes ( )
inline

◆ crypto_box_curve25519xsalsa20poly1305_seed_keypair()

int Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_seed_keypair ( uint8_t pk[32],
uint8_t sk[32],
const uint8_t seed[32] )

Definition at line 14 of file sodium_box.cpp.

14 {
15 secure_vector<uint8_t> digest(64);
16 crypto_hash_sha512(digest.data(), seed, 32);
17 copy_mem(sk, digest.data(), 32);
19}
int crypto_hash_sha512(uint8_t out[64], const uint8_t in[], size_t in_len)

References Botan::copy_mem(), crypto_hash_sha512(), and crypto_scalarmult_curve25519_base().

Referenced by crypto_box_seed_keypair().

◆ crypto_box_curve25519xsalsa20poly1305_seedbytes()

size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_seedbytes ( )
inline

◆ crypto_box_curve25519xsalsa20poly1305_zerobytes()

size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_zerobytes ( )
inline

◆ crypto_box_detached()

int Botan::Sodium::crypto_box_detached ( uint8_t ctext[],
uint8_t mac[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t pk[32],
const uint8_t sk[32] )

Definition at line 67 of file sodium_box.cpp.

73 {
74 secure_vector<uint8_t> shared(32);
75
76 if(crypto_box_beforenm(shared.data(), pk, sk) != 0) {
77 return -1;
78 }
79
80 return crypto_box_detached_afternm(ctext, mac, ptext, ptext_len, nonce, shared.data());
81}
int crypto_box_beforenm(uint8_t key[], const uint8_t pk[32], const uint8_t sk[32])
Definition sodium.h:728

References crypto_box_beforenm(), and crypto_box_detached_afternm().

Referenced by crypto_box_easy().

◆ crypto_box_detached_afternm()

int Botan::Sodium::crypto_box_detached_afternm ( uint8_t ctext[],
uint8_t mac[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 761 of file sodium.h.

766 {
767 return crypto_secretbox_detached(ctext, mac, ptext, ptext_len, nonce, key);
768}
int crypto_secretbox_detached(uint8_t ctext[], uint8_t mac[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])

References crypto_secretbox_detached().

Referenced by crypto_box_detached(), and crypto_box_easy_afternm().

◆ crypto_box_easy()

int Botan::Sodium::crypto_box_easy ( uint8_t ctext[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t pk[32],
const uint8_t sk[32] )
inline

Definition at line 705 of file sodium.h.

710 {
711 return crypto_box_detached(ctext + crypto_box_MACBYTES, ctext, ptext, ptext_len, nonce, pk, sk);
712}
int crypto_box_detached(uint8_t ctext[], uint8_t mac[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])

References crypto_box_detached(), and crypto_box_MACBYTES.

◆ crypto_box_easy_afternm()

int Botan::Sodium::crypto_box_easy_afternm ( uint8_t ctext[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 770 of file sodium.h.

771 {
772 return crypto_box_detached_afternm(ctext + crypto_box_MACBYTES, ctext, ptext, ptext_len, nonce, key);
773}
int crypto_box_detached_afternm(uint8_t ctext[], uint8_t mac[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
Definition sodium.h:761

References crypto_box_detached_afternm(), and crypto_box_MACBYTES.

◆ crypto_box_keypair()

int Botan::Sodium::crypto_box_keypair ( uint8_t pk[32],
uint8_t sk[32] )
inline

Definition at line 683 of file sodium.h.

683 {
685}
int crypto_box_curve25519xsalsa20poly1305_keypair(uint8_t pk[32], uint8_t sk[32])

References crypto_box_curve25519xsalsa20poly1305_keypair().

◆ crypto_box_macbytes()

size_t Botan::Sodium::crypto_box_macbytes ( )
inline

Definition at line 663 of file sodium.h.

663 {
664 return crypto_box_MACBYTES;
665}

References crypto_box_MACBYTES.

◆ crypto_box_messagebytes_max()

size_t Botan::Sodium::crypto_box_messagebytes_max ( )
inline

Definition at line 667 of file sodium.h.

667 {
669}

References crypto_box_MESSAGEBYTES_MAX.

◆ crypto_box_noncebytes()

size_t Botan::Sodium::crypto_box_noncebytes ( )
inline

Definition at line 659 of file sodium.h.

659 {
661}

References crypto_box_NONCEBYTES.

◆ crypto_box_open()

int Botan::Sodium::crypto_box_open ( uint8_t ptext[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t pk[32],
const uint8_t sk[32] )
inline

Definition at line 792 of file sodium.h.

797 {
798 return crypto_box_curve25519xsalsa20poly1305_open(ptext, ctext, ctext_len, nonce, pk, sk);
799}
int crypto_box_curve25519xsalsa20poly1305_open(uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t pk[32], const uint8_t sk[32])

References crypto_box_curve25519xsalsa20poly1305_open().

◆ crypto_box_open_afternm()

int Botan::Sodium::crypto_box_open_afternm ( uint8_t ptext[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 737 of file sodium.h.

738 {
739 return crypto_box_curve25519xsalsa20poly1305_open_afternm(ptext, ctext, ctext_len, nonce, key);
740}
int crypto_box_curve25519xsalsa20poly1305_open_afternm(uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
Definition sodium.h:640

References crypto_box_curve25519xsalsa20poly1305_open_afternm().

◆ crypto_box_open_detached()

int Botan::Sodium::crypto_box_open_detached ( uint8_t ptext[],
const uint8_t ctext[],
const uint8_t mac[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t pk[32],
const uint8_t sk[32] )

Definition at line 83 of file sodium_box.cpp.

89 {
90 secure_vector<uint8_t> shared(32);
91
92 if(crypto_box_beforenm(shared.data(), pk, sk) != 0) {
93 return -1;
94 }
95
96 return crypto_box_open_detached_afternm(ptext, ctext, mac, ctext_len, nonce, shared.data());
97}

References crypto_box_beforenm(), and crypto_box_open_detached_afternm().

Referenced by crypto_box_open_easy().

◆ crypto_box_open_detached_afternm()

int Botan::Sodium::crypto_box_open_detached_afternm ( uint8_t ptext[],
const uint8_t ctext[],
const uint8_t mac[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 742 of file sodium.h.

747 {
748 return crypto_secretbox_open_detached(ptext, ctext, mac, ctext_len, nonce, key);
749}
int crypto_secretbox_open_detached(uint8_t ptext[], const uint8_t ctext[], const uint8_t mac[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])

References crypto_secretbox_open_detached().

Referenced by crypto_box_open_detached(), and crypto_box_open_easy_afternm().

◆ crypto_box_open_easy()

int Botan::Sodium::crypto_box_open_easy ( uint8_t ptext[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t pk[32],
const uint8_t sk[32] )
inline

Definition at line 714 of file sodium.h.

719 {
720 if(ctext_len < crypto_box_MACBYTES) {
721 return -1;
722 }
723
724 return crypto_box_open_detached(
725 ptext, ctext + crypto_box_MACBYTES, ctext, ctext_len - crypto_box_MACBYTES, nonce, pk, sk);
726}

References crypto_box_MACBYTES, and crypto_box_open_detached().

◆ crypto_box_open_easy_afternm()

int Botan::Sodium::crypto_box_open_easy_afternm ( uint8_t ptext[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 751 of file sodium.h.

752 {
753 if(ctext_len < crypto_box_MACBYTES) {
754 return -1;
755 }
756
757 return crypto_box_open_detached_afternm(
758 ptext, ctext + crypto_box_MACBYTES, ctext, ctext_len - crypto_box_MACBYTES, nonce, key);
759}

References crypto_box_MACBYTES, and crypto_box_open_detached_afternm().

◆ crypto_box_primitive()

const char * Botan::Sodium::crypto_box_primitive ( )
inline

Definition at line 675 of file sodium.h.

675 {
676 return "curve25519xsalsa20poly1305";
677}

◆ crypto_box_publickeybytes()

size_t Botan::Sodium::crypto_box_publickeybytes ( )
inline

Definition at line 651 of file sodium.h.

651 {
653}

References crypto_box_PUBLICKEYBYTES.

◆ crypto_box_secretkeybytes()

size_t Botan::Sodium::crypto_box_secretkeybytes ( )
inline

Definition at line 655 of file sodium.h.

655 {
657}

References crypto_box_SECRETKEYBYTES.

◆ crypto_box_seed_keypair()

int Botan::Sodium::crypto_box_seed_keypair ( uint8_t pk[32],
uint8_t sk[32],
const uint8_t seed[] )
inline

Definition at line 679 of file sodium.h.

679 {
681}
int crypto_box_curve25519xsalsa20poly1305_seed_keypair(uint8_t pk[32], uint8_t sk[32], const uint8_t seed[32])

References crypto_box_curve25519xsalsa20poly1305_seed_keypair().

◆ crypto_box_seedbytes()

size_t Botan::Sodium::crypto_box_seedbytes ( )
inline

Definition at line 647 of file sodium.h.

647 {
649}

References crypto_box_SEEDBYTES.

◆ crypto_box_zerobytes()

size_t Botan::Sodium::crypto_box_zerobytes ( )
inline

Definition at line 775 of file sodium.h.

775 {
777}

References crypto_box_ZEROBYTES.

◆ crypto_core_hsalsa20()

int Botan::Sodium::crypto_core_hsalsa20 ( uint8_t out[],
const uint8_t in[],
const uint8_t key[],
const uint8_t c[] )

Definition at line 14 of file sodium_salsa.cpp.

14 {
15 uint32_t in32[16] = {0};
16
17 static const uint32_t SIGMA[] = {0x61707865, 0x3320646e, 0x79622d32, 0x6b206574};
18
19 if(c == nullptr) {
20 in32[0] = SIGMA[0];
21 in32[5] = SIGMA[1];
22 in32[10] = SIGMA[2];
23 in32[15] = SIGMA[3];
24 } else {
25 in32[0] = load_le<uint32_t>(c, 0);
26 in32[5] = load_le<uint32_t>(c, 1);
27 in32[10] = load_le<uint32_t>(c, 2);
28 in32[15] = load_le<uint32_t>(c, 3);
29 }
30
31 in32[1] = load_le<uint32_t>(key, 0);
32 in32[2] = load_le<uint32_t>(key, 1);
33 in32[3] = load_le<uint32_t>(key, 2);
34 in32[4] = load_le<uint32_t>(key, 3);
35
36 in32[6] = load_le<uint32_t>(in, 0);
37 in32[7] = load_le<uint32_t>(in, 1);
38 in32[8] = load_le<uint32_t>(in, 2);
39 in32[9] = load_le<uint32_t>(in, 3);
40
41 in32[11] = load_le<uint32_t>(key, 4);
42 in32[12] = load_le<uint32_t>(key, 5);
43 in32[13] = load_le<uint32_t>(key, 6);
44 in32[14] = load_le<uint32_t>(key, 7);
45
46 uint32_t out32[8] = {0};
47 Salsa20::hsalsa20(out32, in32);
48 store_le(std::span<uint8_t, 32>(out, 32), out32);
49 return 0;
50}
constexpr auto store_le(ParamTs &&... params)
Definition loadstor.h:702

References Botan::Salsa20::hsalsa20(), and Botan::store_le().

Referenced by crypto_box_curve25519xsalsa20poly1305_beforenm().

◆ crypto_core_hsalsa20_constbytes()

size_t Botan::Sodium::crypto_core_hsalsa20_constbytes ( )
inline

Definition at line 948 of file sodium.h.

948 {
950}

References crypto_core_hsalsa20_CONSTBYTES.

◆ crypto_core_hsalsa20_inputbytes()

size_t Botan::Sodium::crypto_core_hsalsa20_inputbytes ( )
inline

Definition at line 940 of file sodium.h.

940 {
942}

References crypto_core_hsalsa20_INPUTBYTES.

◆ crypto_core_hsalsa20_keybytes()

size_t Botan::Sodium::crypto_core_hsalsa20_keybytes ( )
inline

Definition at line 944 of file sodium.h.

944 {
946}

References crypto_core_hsalsa20_KEYBYTES.

◆ crypto_core_hsalsa20_outputbytes()

size_t Botan::Sodium::crypto_core_hsalsa20_outputbytes ( )
inline

Definition at line 936 of file sodium.h.

936 {
938}

References crypto_core_hsalsa20_OUTPUTBYTES.

◆ crypto_hash()

int Botan::Sodium::crypto_hash ( uint8_t out[],
const uint8_t in[],
size_t in_len )
inline

Definition at line 961 of file sodium.h.

961 {
962 return crypto_hash_sha512(out, in, in_len);
963}

References crypto_hash_sha512().

◆ crypto_hash_bytes()

size_t Botan::Sodium::crypto_hash_bytes ( )
inline

Definition at line 957 of file sodium.h.

957 {
958 return crypto_hash_BYTES;
959}

References crypto_hash_BYTES.

◆ crypto_hash_primitive()

const char * Botan::Sodium::crypto_hash_primitive ( )
inline

Definition at line 965 of file sodium.h.

965 {
966 return "sha512";
967}

◆ crypto_hash_sha256()

int Botan::Sodium::crypto_hash_sha256 ( uint8_t out[],
const uint8_t in[],
size_t in_len )

Definition at line 21 of file sodium_auth.cpp.

21 {
22 auto sha256 = HashFunction::create_or_throw("SHA-256");
23 sha256->update(in, in_len);
24 sha256->final(out);
25 return 0;
26}

References Botan::HashFunction::create_or_throw().

◆ crypto_hash_sha256_bytes()

size_t Botan::Sodium::crypto_hash_sha256_bytes ( )
inline

Definition at line 878 of file sodium.h.

878 {
880}

References crypto_hash_sha256_BYTES.

◆ crypto_hash_sha512()

int Botan::Sodium::crypto_hash_sha512 ( uint8_t out[64],
const uint8_t in[],
size_t in_len )

Definition at line 14 of file sodium_auth.cpp.

14 {
15 auto sha512 = HashFunction::create_or_throw("SHA-512");
16 sha512->update(in, in_len);
17 sha512->final(out);
18 return 0;
19}

References Botan::HashFunction::create_or_throw().

Referenced by crypto_box_curve25519xsalsa20poly1305_seed_keypair(), and crypto_hash().

◆ crypto_hash_sha512_bytes()

size_t Botan::Sodium::crypto_hash_sha512_bytes ( )
inline

Definition at line 803 of file sodium.h.

803 {
805}

References crypto_hash_sha512_BYTES.

◆ crypto_onetimeauth()

int Botan::Sodium::crypto_onetimeauth ( uint8_t out[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )
inline

Definition at line 1003 of file sodium.h.

1003 {
1004 return crypto_onetimeauth_poly1305(out, in, in_len, key);
1005}
int crypto_onetimeauth_poly1305(uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])

References crypto_onetimeauth_poly1305().

◆ crypto_onetimeauth_bytes()

size_t Botan::Sodium::crypto_onetimeauth_bytes ( )
inline

Definition at line 991 of file sodium.h.

991 {
993}

References crypto_onetimeauth_BYTES.

◆ crypto_onetimeauth_keybytes()

size_t Botan::Sodium::crypto_onetimeauth_keybytes ( )
inline

Definition at line 995 of file sodium.h.

995 {
997}

References crypto_onetimeauth_KEYBYTES.

◆ crypto_onetimeauth_keygen()

void Botan::Sodium::crypto_onetimeauth_keygen ( uint8_t k[32])
inline

Definition at line 1011 of file sodium.h.

1011 {
1013}
void crypto_onetimeauth_poly1305_keygen(uint8_t k[32])
Definition sodium.h:985

References crypto_onetimeauth_poly1305_keygen().

◆ crypto_onetimeauth_poly1305()

int Botan::Sodium::crypto_onetimeauth_poly1305 ( uint8_t out[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )

Definition at line 36 of file sodium_auth.cpp.

36 {
37 auto mac = MessageAuthenticationCode::create_or_throw("Poly1305");
38 mac->set_key(key, crypto_onetimeauth_poly1305_KEYBYTES);
39 mac->update(in, in_len);
40 mac->final(out);
41 return 0;
42}

References Botan::MessageAuthenticationCode::create_or_throw(), and crypto_onetimeauth_poly1305_KEYBYTES.

Referenced by crypto_onetimeauth(), and crypto_onetimeauth_poly1305_verify().

◆ crypto_onetimeauth_poly1305_bytes()

size_t Botan::Sodium::crypto_onetimeauth_poly1305_bytes ( )
inline

Definition at line 971 of file sodium.h.

971 {
973}

References crypto_onetimeauth_poly1305_BYTES.

◆ crypto_onetimeauth_poly1305_keybytes()

size_t Botan::Sodium::crypto_onetimeauth_poly1305_keybytes ( )
inline

Definition at line 975 of file sodium.h.

975 {
977}

References crypto_onetimeauth_poly1305_KEYBYTES.

◆ crypto_onetimeauth_poly1305_keygen()

void Botan::Sodium::crypto_onetimeauth_poly1305_keygen ( uint8_t k[32])
inline

Definition at line 985 of file sodium.h.

985 {
986 return randombytes_buf(k, 32);
987}

References randombytes_buf().

Referenced by crypto_onetimeauth_keygen().

◆ crypto_onetimeauth_poly1305_verify()

int Botan::Sodium::crypto_onetimeauth_poly1305_verify ( const uint8_t h[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )

Definition at line 44 of file sodium_auth.cpp.

47 {
48 secure_vector<uint8_t> computed(crypto_onetimeauth_poly1305_BYTES);
49 crypto_onetimeauth_poly1305(computed.data(), in, in_len, key);
50 return crypto_verify_16(computed.data(), mac) ? 0 : -1;
51}
int crypto_verify_16(const uint8_t x[16], const uint8_t y[16])

References crypto_onetimeauth_poly1305(), crypto_onetimeauth_poly1305_BYTES, and crypto_verify_16().

Referenced by crypto_onetimeauth_verify().

◆ crypto_onetimeauth_primitive()

const char * Botan::Sodium::crypto_onetimeauth_primitive ( )
inline

Definition at line 999 of file sodium.h.

999 {
1000 return "poly1305";
1001}

◆ crypto_onetimeauth_verify()

int Botan::Sodium::crypto_onetimeauth_verify ( const uint8_t h[],
const uint8_t in[],
size_t in_len,
const uint8_t key[] )
inline

Definition at line 1007 of file sodium.h.

1007 {
1008 return crypto_onetimeauth_poly1305_verify(h, in, in_len, key);
1009}
int crypto_onetimeauth_poly1305_verify(const uint8_t h[], const uint8_t in[], size_t in_len, const uint8_t key[])

References crypto_onetimeauth_poly1305_verify().

◆ crypto_scalarmult()

int Botan::Sodium::crypto_scalarmult ( uint8_t out[],
const uint8_t scalar[],
const uint8_t base[] )
inline

Definition at line 1049 of file sodium.h.

1049 {
1050 return crypto_scalarmult_curve25519(out, scalar, base);
1051}
int crypto_scalarmult_curve25519(uint8_t out[32], const uint8_t scalar[32], const uint8_t basepoint[32])

References crypto_scalarmult_curve25519().

◆ crypto_scalarmult_base()

int Botan::Sodium::crypto_scalarmult_base ( uint8_t out[],
const uint8_t scalar[] )
inline

Definition at line 1045 of file sodium.h.

1045 {
1046 return crypto_scalarmult_curve25519_base(out, scalar);
1047}

References crypto_scalarmult_curve25519_base().

◆ crypto_scalarmult_bytes()

size_t Botan::Sodium::crypto_scalarmult_bytes ( )
inline

Definition at line 1033 of file sodium.h.

1033 {
1035}
size_t crypto_scalarmult_curve25519_bytes()
Definition sodium.h:1017

References crypto_scalarmult_curve25519_bytes().

◆ crypto_scalarmult_curve25519()

int Botan::Sodium::crypto_scalarmult_curve25519 ( uint8_t out[32],
const uint8_t scalar[32],
const uint8_t basepoint[32] )

Definition at line 14 of file sodium_25519.cpp.

14 {
15 curve25519_donna(out, scalar, point);
16 return 0;
17}
void curve25519_donna(uint8_t mypublic[32], const uint8_t secret[32], const uint8_t basepoint[32])
Definition donna.cpp:454

References Botan::curve25519_donna().

Referenced by crypto_box_curve25519xsalsa20poly1305_beforenm(), and crypto_scalarmult().

◆ crypto_scalarmult_curve25519_base()

int Botan::Sodium::crypto_scalarmult_curve25519_base ( uint8_t out[32],
const uint8_t scalar[32] )

Definition at line 19 of file sodium_25519.cpp.

19 {
20 curve25519_basepoint(out, scalar);
21 return 0;
22}
void curve25519_basepoint(uint8_t mypublic[32], const uint8_t secret[32])

References Botan::curve25519_basepoint().

Referenced by crypto_box_curve25519xsalsa20poly1305_keypair(), crypto_box_curve25519xsalsa20poly1305_seed_keypair(), and crypto_scalarmult_base().

◆ crypto_scalarmult_curve25519_bytes()

size_t Botan::Sodium::crypto_scalarmult_curve25519_bytes ( )
inline

Definition at line 1017 of file sodium.h.

1017 {
1019}

References crypto_scalarmult_curve25519_BYTES.

Referenced by crypto_scalarmult_bytes().

◆ crypto_scalarmult_curve25519_scalarbytes()

size_t Botan::Sodium::crypto_scalarmult_curve25519_scalarbytes ( )
inline

Definition at line 1021 of file sodium.h.

1021 {
1023}

References crypto_scalarmult_curve25519_SCALARBYTES.

Referenced by crypto_scalarmult_scalarbytes().

◆ crypto_scalarmult_primitive()

const char * Botan::Sodium::crypto_scalarmult_primitive ( )
inline

Definition at line 1041 of file sodium.h.

1041 {
1042 return "curve25519";
1043}

◆ crypto_scalarmult_scalarbytes()

size_t Botan::Sodium::crypto_scalarmult_scalarbytes ( )
inline

Definition at line 1037 of file sodium.h.

1037 {
1039}
size_t crypto_scalarmult_curve25519_scalarbytes()
Definition sodium.h:1021

References crypto_scalarmult_curve25519_scalarbytes().

◆ crypto_secretbox()

int Botan::Sodium::crypto_secretbox ( uint8_t ctext[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 351 of file sodium.h.

352 {
353 return crypto_secretbox_xsalsa20poly1305(ctext, ptext, ptext_len, nonce, key);
354}

References crypto_secretbox_xsalsa20poly1305().

◆ crypto_secretbox_boxzerobytes()

size_t Botan::Sodium::crypto_secretbox_boxzerobytes ( )
inline

Definition at line 347 of file sodium.h.

347 {
349}

References crypto_secretbox_BOXZEROBYTES.

◆ crypto_secretbox_detached()

int Botan::Sodium::crypto_secretbox_detached ( uint8_t ctext[],
uint8_t mac[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 68 of file sodium_secretbox.cpp.

73 {
74 auto salsa = StreamCipher::create_or_throw("Salsa20");
75 salsa->set_key(key, crypto_secretbox_KEYBYTES);
76 salsa->set_iv(nonce, crypto_secretbox_NONCEBYTES);
77
78 secure_vector<uint8_t> auth_key(32);
79 salsa->write_keystream(auth_key.data(), auth_key.size());
80
81 salsa->cipher(ptext, ctext, ptext_len);
82
83 auto poly1305 = MessageAuthenticationCode::create_or_throw("Poly1305");
84 poly1305->set_key(auth_key);
85 poly1305->update(ctext, ptext_len);
86 poly1305->final(mac);
87
88 return 0;
89}

References Botan::MessageAuthenticationCode::create_or_throw(), Botan::StreamCipher::create_or_throw(), crypto_secretbox_KEYBYTES, and crypto_secretbox_NONCEBYTES.

Referenced by crypto_box_detached_afternm(), and crypto_secretbox_easy().

◆ crypto_secretbox_easy()

int Botan::Sodium::crypto_secretbox_easy ( uint8_t ctext[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 324 of file sodium.h.

325 {
326 return crypto_secretbox_detached(ctext + crypto_secretbox_MACBYTES, ctext, ptext, ptext_len, nonce, key);
327}

References crypto_secretbox_detached(), and crypto_secretbox_MACBYTES.

◆ crypto_secretbox_keybytes()

size_t Botan::Sodium::crypto_secretbox_keybytes ( )
inline

Definition at line 292 of file sodium.h.

292 {
294}

References crypto_secretbox_KEYBYTES.

◆ crypto_secretbox_keygen()

void Botan::Sodium::crypto_secretbox_keygen ( uint8_t k[32])
inline

Definition at line 339 of file sodium.h.

339 {
340 return randombytes_buf(k, 32);
341}

References randombytes_buf().

◆ crypto_secretbox_macbytes()

size_t Botan::Sodium::crypto_secretbox_macbytes ( )
inline

Definition at line 300 of file sodium.h.

300 {
302}

References crypto_secretbox_MACBYTES.

◆ crypto_secretbox_messagebytes_max()

size_t Botan::Sodium::crypto_secretbox_messagebytes_max ( )
inline

◆ crypto_secretbox_noncebytes()

size_t Botan::Sodium::crypto_secretbox_noncebytes ( )
inline

Definition at line 296 of file sodium.h.

296 {
298}

References crypto_secretbox_NONCEBYTES.

◆ crypto_secretbox_open()

int Botan::Sodium::crypto_secretbox_open ( uint8_t ptext[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 356 of file sodium.h.

357 {
358 return crypto_secretbox_xsalsa20poly1305_open(ptext, ctext, ctext_len, nonce, key);
359}

References crypto_secretbox_xsalsa20poly1305_open().

◆ crypto_secretbox_open_detached()

int Botan::Sodium::crypto_secretbox_open_detached ( uint8_t ptext[],
const uint8_t ctext[],
const uint8_t mac[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 91 of file sodium_secretbox.cpp.

96 {
97 auto salsa = StreamCipher::create_or_throw("Salsa20");
98 salsa->set_key(key, crypto_secretbox_KEYBYTES);
99 salsa->set_iv(nonce, crypto_secretbox_NONCEBYTES);
100
101 secure_vector<uint8_t> auth_key(32);
102 salsa->write_keystream(auth_key.data(), auth_key.size());
103
104 auto poly1305 = MessageAuthenticationCode::create_or_throw("Poly1305");
105 poly1305->set_key(auth_key);
106 poly1305->update(ctext, ctext_len);
107 secure_vector<uint8_t> computed_mac = poly1305->final();
108
109 if(!CT::is_equal(mac, computed_mac.data(), computed_mac.size()).as_bool()) {
110 return -1;
111 }
112
113 salsa->cipher(ctext, ptext, ctext_len);
114
115 return 0;
116}

References Botan::MessageAuthenticationCode::create_or_throw(), Botan::StreamCipher::create_or_throw(), crypto_secretbox_KEYBYTES, crypto_secretbox_NONCEBYTES, and Botan::CT::is_equal().

Referenced by crypto_box_open_detached_afternm(), and crypto_secretbox_open_easy().

◆ crypto_secretbox_open_easy()

int Botan::Sodium::crypto_secretbox_open_easy ( uint8_t out[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )
inline

Definition at line 329 of file sodium.h.

330 {
331 if(ctext_len < crypto_secretbox_MACBYTES) {
332 return -1;
333 }
334
335 return crypto_secretbox_open_detached(
336 out, ctext + crypto_secretbox_MACBYTES, ctext, ctext_len - crypto_secretbox_MACBYTES, nonce, key);
337}

References crypto_secretbox_MACBYTES, and crypto_secretbox_open_detached().

◆ crypto_secretbox_primitive()

const char * Botan::Sodium::crypto_secretbox_primitive ( )
inline

Definition at line 308 of file sodium.h.

308 {
309 return "xsalsa20poly1305";
310}

◆ crypto_secretbox_xsalsa20poly1305()

int Botan::Sodium::crypto_secretbox_xsalsa20poly1305 ( uint8_t ctext[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 16 of file sodium_secretbox.cpp.

17 {
18 if(ptext_len < 32) {
19 return -1;
20 }
21
22 auto salsa = StreamCipher::create_or_throw("Salsa20");
23 salsa->set_key(key, crypto_secretbox_KEYBYTES);
24 salsa->set_iv(nonce, crypto_secretbox_NONCEBYTES);
25
26 secure_vector<uint8_t> auth_key(32);
27 salsa->write_keystream(auth_key.data(), auth_key.size());
28
29 salsa->cipher(ptext + 32, ctext + 32, ptext_len - 32);
30
31 auto poly1305 = MessageAuthenticationCode::create_or_throw("Poly1305");
32 poly1305->set_key(auth_key);
33 poly1305->update(ctext + 32, ptext_len - 32);
34 poly1305->final(ctext + 16);
35
36 clear_mem(ctext, 16);
37 return 0;
38}
constexpr void clear_mem(T *ptr, size_t n)
Definition mem_ops.h:120

References Botan::clear_mem(), Botan::MessageAuthenticationCode::create_or_throw(), Botan::StreamCipher::create_or_throw(), crypto_secretbox_KEYBYTES, and crypto_secretbox_NONCEBYTES.

Referenced by crypto_box_curve25519xsalsa20poly1305_afternm(), and crypto_secretbox().

◆ crypto_secretbox_xsalsa20poly1305_boxzerobytes()

size_t Botan::Sodium::crypto_secretbox_xsalsa20poly1305_boxzerobytes ( )
inline

◆ crypto_secretbox_xsalsa20poly1305_keybytes()

size_t Botan::Sodium::crypto_secretbox_xsalsa20poly1305_keybytes ( )
inline

Definition at line 254 of file sodium.h.

References crypto_secretbox_xsalsa20poly1305_KEYBYTES.

◆ crypto_secretbox_xsalsa20poly1305_keygen()

void Botan::Sodium::crypto_secretbox_xsalsa20poly1305_keygen ( uint8_t k[32])
inline

Definition at line 278 of file sodium.h.

278 {
279 return randombytes_buf(k, 32);
280}

References randombytes_buf().

◆ crypto_secretbox_xsalsa20poly1305_macbytes()

size_t Botan::Sodium::crypto_secretbox_xsalsa20poly1305_macbytes ( )
inline

Definition at line 262 of file sodium.h.

References crypto_secretbox_xsalsa20poly1305_MACBYTES.

◆ crypto_secretbox_xsalsa20poly1305_messagebytes_max()

size_t Botan::Sodium::crypto_secretbox_xsalsa20poly1305_messagebytes_max ( )
inline

◆ crypto_secretbox_xsalsa20poly1305_noncebytes()

size_t Botan::Sodium::crypto_secretbox_xsalsa20poly1305_noncebytes ( )
inline

Definition at line 258 of file sodium.h.

References crypto_secretbox_xsalsa20poly1305_NONCEBYTES.

◆ crypto_secretbox_xsalsa20poly1305_open()

int Botan::Sodium::crypto_secretbox_xsalsa20poly1305_open ( uint8_t ptext[],
const uint8_t ctext[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 40 of file sodium_secretbox.cpp.

41 {
42 if(ctext_len < crypto_box_curve25519xsalsa20poly1305_ZEROBYTES) {
43 return -1;
44 }
45
46 auto salsa = StreamCipher::create_or_throw("Salsa20");
47 salsa->set_key(key, crypto_secretbox_KEYBYTES);
48 salsa->set_iv(nonce, crypto_secretbox_NONCEBYTES);
49
50 secure_vector<uint8_t> auth_key(32);
51 salsa->write_keystream(auth_key.data(), auth_key.size());
52
53 auto poly1305 = MessageAuthenticationCode::create_or_throw("Poly1305");
54 poly1305->set_key(auth_key);
55 poly1305->update(ctext + 32, ctext_len - 32);
56 secure_vector<uint8_t> computed = poly1305->final();
57
58 if(CT::is_not_equal(computed.data(), ctext + 16, 16).as_bool()) {
59 return -1;
60 }
61
62 salsa->cipher(ctext + 32, ptext + 32, ctext_len - 32);
63
64 clear_mem(ptext, 32);
65 return 0;
66}

References Botan::clear_mem(), Botan::MessageAuthenticationCode::create_or_throw(), Botan::StreamCipher::create_or_throw(), crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, crypto_secretbox_KEYBYTES, crypto_secretbox_NONCEBYTES, and Botan::CT::is_not_equal().

Referenced by crypto_box_curve25519xsalsa20poly1305_open_afternm(), and crypto_secretbox_open().

◆ crypto_secretbox_xsalsa20poly1305_zerobytes()

size_t Botan::Sodium::crypto_secretbox_xsalsa20poly1305_zerobytes ( )
inline

Definition at line 286 of file sodium.h.

References crypto_secretbox_xsalsa20poly1305_ZEROBYTES.

◆ crypto_secretbox_zerobytes()

size_t Botan::Sodium::crypto_secretbox_zerobytes ( )
inline

Definition at line 343 of file sodium.h.

343 {
345}

References crypto_secretbox_ZEROBYTES.

◆ crypto_shorthash()

int Botan::Sodium::crypto_shorthash ( uint8_t out[],
const uint8_t in[],
size_t in_len,
const uint8_t k[16] )
inline

Definition at line 1225 of file sodium.h.

1225 {
1226 return crypto_shorthash_siphash24(out, in, in_len, k);
1227}
int crypto_shorthash_siphash24(uint8_t out[8], const uint8_t in[], size_t in_len, const uint8_t key[16])

References crypto_shorthash_siphash24().

◆ crypto_shorthash_bytes()

size_t Botan::Sodium::crypto_shorthash_bytes ( )
inline

Definition at line 1213 of file sodium.h.

1213 {
1215}
size_t crypto_shorthash_siphash24_bytes()
Definition sodium.h:1200

References crypto_shorthash_siphash24_bytes().

◆ crypto_shorthash_keybytes()

size_t Botan::Sodium::crypto_shorthash_keybytes ( )
inline

Definition at line 1217 of file sodium.h.

1217 {
1219}
size_t crypto_shorthash_siphash24_keybytes()
Definition sodium.h:1204

References crypto_shorthash_siphash24_keybytes().

◆ crypto_shorthash_keygen()

void Botan::Sodium::crypto_shorthash_keygen ( uint8_t k[16])
inline

Definition at line 1229 of file sodium.h.

1229 {
1230 randombytes_buf(k, crypto_shorthash_siphash24_KEYBYTES);
1231}

References crypto_shorthash_siphash24_KEYBYTES, and randombytes_buf().

◆ crypto_shorthash_primitive()

const char * Botan::Sodium::crypto_shorthash_primitive ( )
inline

Definition at line 1221 of file sodium.h.

1221 {
1222 return "siphash24";
1223}

◆ crypto_shorthash_siphash24()

int Botan::Sodium::crypto_shorthash_siphash24 ( uint8_t out[8],
const uint8_t in[],
size_t in_len,
const uint8_t key[16] )

Definition at line 28 of file sodium_auth.cpp.

28 {
29 auto mac = MessageAuthenticationCode::create_or_throw("SipHash(2,4)");
30 mac->set_key(key, crypto_shorthash_siphash24_KEYBYTES);
31 mac->update(in, in_len);
32 mac->final(out);
33 return 0;
34}

References Botan::MessageAuthenticationCode::create_or_throw(), and crypto_shorthash_siphash24_KEYBYTES.

Referenced by crypto_shorthash().

◆ crypto_shorthash_siphash24_bytes()

size_t Botan::Sodium::crypto_shorthash_siphash24_bytes ( )
inline

Definition at line 1200 of file sodium.h.

1200 {
1202}

References crypto_shorthash_siphash24_BYTES.

Referenced by crypto_shorthash_bytes().

◆ crypto_shorthash_siphash24_keybytes()

size_t Botan::Sodium::crypto_shorthash_siphash24_keybytes ( )
inline

Definition at line 1204 of file sodium.h.

1204 {
1206}

References crypto_shorthash_siphash24_KEYBYTES.

Referenced by crypto_shorthash_keybytes().

◆ crypto_sign_bytes()

size_t Botan::Sodium::crypto_sign_bytes ( )
inline

Definition at line 1270 of file sodium.h.

1270 {
1271 return crypto_sign_BYTES;
1272}

References crypto_sign_BYTES.

◆ crypto_sign_detached()

int Botan::Sodium::crypto_sign_detached ( uint8_t sig[],
unsigned long long * sig_len,
const uint8_t msg[],
size_t msg_len,
const uint8_t sk[32] )
inline

Definition at line 1302 of file sodium.h.

1303 {
1304 return crypto_sign_ed25519_detached(sig, sig_len, msg, msg_len, sk);
1305}
int crypto_sign_ed25519_detached(uint8_t sig[], unsigned long long *sig_len, const uint8_t msg[], size_t msg_len, const uint8_t sk[32])

References crypto_sign_ed25519_detached().

◆ crypto_sign_ed25519_bytes()

size_t Botan::Sodium::crypto_sign_ed25519_bytes ( )
inline

Definition at line 1235 of file sodium.h.

1235 {
1237}

References crypto_sign_ed25519_BYTES.

◆ crypto_sign_ed25519_detached()

int Botan::Sodium::crypto_sign_ed25519_detached ( uint8_t sig[],
unsigned long long * sig_len,
const uint8_t msg[],
size_t msg_len,
const uint8_t sk[32] )

Definition at line 24 of file sodium_25519.cpp.

25 {
26 ed25519_sign(sig, msg, msg_len, sk, nullptr, 0);
27
28 if(sig_len) {
29 *sig_len = 64;
30 }
31 return 0;
32}
void ed25519_sign(uint8_t sig[64], const uint8_t m[], size_t mlen, const uint8_t sk[64], const uint8_t domain_sep[], size_t domain_sep_len)
Definition ed25519.cpp:37

References Botan::ed25519_sign().

Referenced by crypto_sign_detached().

◆ crypto_sign_ed25519_keypair()

int Botan::Sodium::crypto_sign_ed25519_keypair ( uint8_t pk[32],
uint8_t sk[64] )

Definition at line 42 of file sodium_25519.cpp.

42 {
44 randombytes_buf(seed.data(), seed.size());
45 return crypto_sign_ed25519_seed_keypair(pk, sk, seed.data());
46}
int crypto_sign_ed25519_seed_keypair(uint8_t pk[], uint8_t sk[], const uint8_t seed[])

References crypto_sign_ed25519_seed_keypair(), and randombytes_buf().

Referenced by crypto_sign_keypair().

◆ crypto_sign_ed25519_messagebytes_max()

size_t Botan::Sodium::crypto_sign_ed25519_messagebytes_max ( )
inline

Definition at line 1251 of file sodium.h.

1251 {
1253}

References crypto_sign_ed25519_MESSAGEBYTES_MAX.

◆ crypto_sign_ed25519_publickeybytes()

size_t Botan::Sodium::crypto_sign_ed25519_publickeybytes ( )
inline

Definition at line 1243 of file sodium.h.

1243 {
1245}

References crypto_sign_ed25519_PUBLICKEYBYTES.

◆ crypto_sign_ed25519_secretkeybytes()

size_t Botan::Sodium::crypto_sign_ed25519_secretkeybytes ( )
inline

Definition at line 1247 of file sodium.h.

1247 {
1249}

References crypto_sign_ed25519_SECRETKEYBYTES.

◆ crypto_sign_ed25519_seed_keypair()

int Botan::Sodium::crypto_sign_ed25519_seed_keypair ( uint8_t pk[],
uint8_t sk[],
const uint8_t seed[] )

Definition at line 48 of file sodium_25519.cpp.

48 {
49 ed25519_gen_keypair(pk, sk, seed);
50 return 0;
51}
void ed25519_gen_keypair(uint8_t *pk, uint8_t *sk, const uint8_t seed[32])
Definition ed25519.cpp:20

References Botan::ed25519_gen_keypair().

Referenced by crypto_sign_ed25519_keypair(), and crypto_sign_seed_keypair().

◆ crypto_sign_ed25519_seedbytes()

size_t Botan::Sodium::crypto_sign_ed25519_seedbytes ( )
inline

Definition at line 1239 of file sodium.h.

1239 {
1241}

References crypto_sign_ed25519_SEEDBYTES.

◆ crypto_sign_ed25519_verify_detached()

int Botan::Sodium::crypto_sign_ed25519_verify_detached ( const uint8_t sig[],
const uint8_t msg[],
size_t msg_len,
const uint8_t pk[32] )

Definition at line 34 of file sodium_25519.cpp.

37 {
38 const bool ok = ed25519_verify(msg, msg_len, sig, pk, nullptr, 0);
39 return ok ? 0 : -1;
40}
bool ed25519_verify(const uint8_t *m, size_t mlen, const uint8_t sig[64], const uint8_t *pk, const uint8_t domain_sep[], size_t domain_sep_len)
Definition ed25519.cpp:73

References Botan::ed25519_verify().

Referenced by crypto_sign_verify_detached().

◆ crypto_sign_keypair()

int Botan::Sodium::crypto_sign_keypair ( uint8_t pk[32],
uint8_t sk[32] )
inline

Definition at line 1298 of file sodium.h.

1298 {
1299 return crypto_sign_ed25519_keypair(pk, sk);
1300}
int crypto_sign_ed25519_keypair(uint8_t pk[32], uint8_t sk[64])

References crypto_sign_ed25519_keypair().

◆ crypto_sign_messagebytes_max()

size_t Botan::Sodium::crypto_sign_messagebytes_max ( )
inline

Definition at line 1286 of file sodium.h.

1286 {
1288}

References crypto_sign_MESSAGEBYTES_MAX.

◆ crypto_sign_primitive()

const char * Botan::Sodium::crypto_sign_primitive ( )
inline

Definition at line 1290 of file sodium.h.

1290 {
1291 return "ed25519";
1292}

◆ crypto_sign_publickeybytes()

size_t Botan::Sodium::crypto_sign_publickeybytes ( )
inline

Definition at line 1278 of file sodium.h.

1278 {
1280}

References crypto_sign_PUBLICKEYBYTES.

◆ crypto_sign_secretkeybytes()

size_t Botan::Sodium::crypto_sign_secretkeybytes ( )
inline

Definition at line 1282 of file sodium.h.

1282 {
1284}

References crypto_sign_SECRETKEYBYTES.

◆ crypto_sign_seed_keypair()

int Botan::Sodium::crypto_sign_seed_keypair ( uint8_t pk[32],
uint8_t sk[32],
const uint8_t seed[] )
inline

Definition at line 1294 of file sodium.h.

1294 {
1295 return crypto_sign_ed25519_seed_keypair(pk, sk, seed);
1296}

References crypto_sign_ed25519_seed_keypair().

◆ crypto_sign_seedbytes()

size_t Botan::Sodium::crypto_sign_seedbytes ( )
inline

Definition at line 1274 of file sodium.h.

1274 {
1275 return crypto_sign_SEEDBYTES;
1276}

References crypto_sign_SEEDBYTES.

◆ crypto_sign_verify_detached()

int Botan::Sodium::crypto_sign_verify_detached ( const uint8_t sig[],
const uint8_t in[],
size_t in_len,
const uint8_t pk[32] )
inline

Definition at line 1307 of file sodium.h.

1307 {
1308 return crypto_sign_ed25519_verify_detached(sig, in, in_len, pk);
1309}
int crypto_sign_ed25519_verify_detached(const uint8_t sig[], const uint8_t msg[], size_t msg_len, const uint8_t pk[32])

References crypto_sign_ed25519_verify_detached().

◆ crypto_stream()

int Botan::Sodium::crypto_stream ( uint8_t out[],
size_t out_len,
const uint8_t nonce[24],
const uint8_t key[32] )
inline

Definition at line 1185 of file sodium.h.

1185 {
1186 return crypto_stream_xsalsa20(out, out_len, nonce, key);
1187}
int crypto_stream_xsalsa20(uint8_t out[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])

References crypto_stream_xsalsa20().

◆ crypto_stream_chacha20()

int Botan::Sodium::crypto_stream_chacha20 ( uint8_t out[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 13 of file sodium_chacha.cpp.

13 {
14 auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
15 chacha->set_key(key, crypto_stream_chacha20_KEYBYTES);
16 chacha->set_iv(nonce, crypto_stream_chacha20_NONCEBYTES);
17 chacha->write_keystream(out, out_len);
18 return 0;
19}

References Botan::StreamCipher::create_or_throw(), crypto_stream_chacha20_KEYBYTES, and crypto_stream_chacha20_NONCEBYTES.

◆ crypto_stream_chacha20_ietf()

int Botan::Sodium::crypto_stream_chacha20_ietf ( uint8_t out[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 40 of file sodium_chacha.cpp.

40 {
41 auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
42 chacha->set_key(key, crypto_stream_chacha20_ietf_KEYBYTES);
43 chacha->set_iv(nonce, crypto_stream_chacha20_ietf_NONCEBYTES);
44 chacha->write_keystream(out, out_len);
45 return 0;
46}

References Botan::StreamCipher::create_or_throw(), crypto_stream_chacha20_ietf_KEYBYTES, and crypto_stream_chacha20_ietf_NONCEBYTES.

◆ crypto_stream_chacha20_ietf_keybytes()

size_t Botan::Sodium::crypto_stream_chacha20_ietf_keybytes ( )
inline

Definition at line 1082 of file sodium.h.

1082 {
1084}

References crypto_stream_chacha20_ietf_KEYBYTES.

◆ crypto_stream_chacha20_ietf_keygen()

void Botan::Sodium::crypto_stream_chacha20_ietf_keygen ( uint8_t k[32])
inline

Definition at line 1105 of file sodium.h.

1105 {
1106 return randombytes_buf(k, 32);
1107}

References randombytes_buf().

◆ crypto_stream_chacha20_ietf_messagebytes_max()

size_t Botan::Sodium::crypto_stream_chacha20_ietf_messagebytes_max ( )
inline

Definition at line 1090 of file sodium.h.

References crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX.

◆ crypto_stream_chacha20_ietf_noncebytes()

size_t Botan::Sodium::crypto_stream_chacha20_ietf_noncebytes ( )
inline

Definition at line 1086 of file sodium.h.

1086 {
1088}

References crypto_stream_chacha20_ietf_NONCEBYTES.

◆ crypto_stream_chacha20_ietf_xor()

int Botan::Sodium::crypto_stream_chacha20_ietf_xor ( uint8_t out[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 48 of file sodium_chacha.cpp.

49 {
50 return crypto_stream_chacha20_ietf_xor_ic(out, in, in_len, nonce, 0, key);
51}
int crypto_stream_chacha20_ietf_xor_ic(uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], uint32_t ic, const uint8_t key[])

References crypto_stream_chacha20_ietf_xor_ic().

◆ crypto_stream_chacha20_ietf_xor_ic()

int Botan::Sodium::crypto_stream_chacha20_ietf_xor_ic ( uint8_t out[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
uint32_t ic,
const uint8_t key[] )

Definition at line 53 of file sodium_chacha.cpp.

54 {
55 auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
56 chacha->set_key(key, crypto_stream_chacha20_ietf_KEYBYTES);
57 chacha->set_iv(nonce, crypto_stream_chacha20_ietf_NONCEBYTES);
58 chacha->seek(static_cast<uint64_t>(ic) * 64);
59 chacha->cipher(in, out, in_len);
60 return 0;
61}

References Botan::StreamCipher::create_or_throw(), crypto_stream_chacha20_ietf_KEYBYTES, and crypto_stream_chacha20_ietf_NONCEBYTES.

Referenced by crypto_stream_chacha20_ietf_xor().

◆ crypto_stream_chacha20_keybytes()

size_t Botan::Sodium::crypto_stream_chacha20_keybytes ( )
inline

Definition at line 1055 of file sodium.h.

1055 {
1057}

References crypto_stream_chacha20_KEYBYTES.

◆ crypto_stream_chacha20_keygen()

void Botan::Sodium::crypto_stream_chacha20_keygen ( uint8_t k[32])
inline

Definition at line 1078 of file sodium.h.

1078 {
1079 return randombytes_buf(k, 32);
1080}

References randombytes_buf().

◆ crypto_stream_chacha20_messagebytes_max()

size_t Botan::Sodium::crypto_stream_chacha20_messagebytes_max ( )
inline

Definition at line 1063 of file sodium.h.

1063 {
1065}

References crypto_stream_chacha20_MESSAGEBYTES_MAX.

◆ crypto_stream_chacha20_noncebytes()

size_t Botan::Sodium::crypto_stream_chacha20_noncebytes ( )
inline

Definition at line 1059 of file sodium.h.

1059 {
1061}

References crypto_stream_chacha20_NONCEBYTES.

◆ crypto_stream_chacha20_xor()

int Botan::Sodium::crypto_stream_chacha20_xor ( uint8_t out[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 21 of file sodium_chacha.cpp.

22 {
23 return crypto_stream_chacha20_xor_ic(out, in, in_len, nonce, 0, key);
24}
int crypto_stream_chacha20_xor_ic(uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], uint64_t ic, const uint8_t key[])

References crypto_stream_chacha20_xor_ic().

◆ crypto_stream_chacha20_xor_ic()

int Botan::Sodium::crypto_stream_chacha20_xor_ic ( uint8_t out[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
uint64_t ic,
const uint8_t key[] )

Definition at line 26 of file sodium_chacha.cpp.

27 {
28 if((ic >> 6) != 0) { // otherwise multiply overflows
29 return -1;
30 }
31
32 auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
33 chacha->set_key(key, crypto_stream_chacha20_KEYBYTES);
34 chacha->set_iv(nonce, crypto_stream_chacha20_NONCEBYTES);
35 chacha->seek(ic * 64);
36 chacha->cipher(in, out, in_len);
37 return 0;
38}

References Botan::StreamCipher::create_or_throw(), crypto_stream_chacha20_KEYBYTES, and crypto_stream_chacha20_NONCEBYTES.

Referenced by crypto_stream_chacha20_xor().

◆ crypto_stream_keybytes()

size_t Botan::Sodium::crypto_stream_keybytes ( )
inline

Definition at line 1169 of file sodium.h.

1169 {
1171}
size_t crypto_stream_xsalsa20_keybytes()
Definition sodium.h:907

References crypto_stream_xsalsa20_keybytes().

◆ crypto_stream_keygen()

void Botan::Sodium::crypto_stream_keygen ( uint8_t key[32])
inline

Definition at line 1194 of file sodium.h.

1194 {
1195 return randombytes_buf(key, 32);
1196}

References randombytes_buf().

◆ crypto_stream_messagebytes_max()

size_t Botan::Sodium::crypto_stream_messagebytes_max ( )
inline

Definition at line 1177 of file sodium.h.

1177 {
1179}

References crypto_stream_MESSAGEBYTES_MAX.

◆ crypto_stream_noncebytes()

size_t Botan::Sodium::crypto_stream_noncebytes ( )
inline

Definition at line 1173 of file sodium.h.

1173 {
1175}
size_t crypto_stream_xsalsa20_noncebytes()
Definition sodium.h:911

References crypto_stream_xsalsa20_noncebytes().

◆ crypto_stream_primitive()

const char * Botan::Sodium::crypto_stream_primitive ( )
inline

Definition at line 1181 of file sodium.h.

1181 {
1182 return "xsalsa20";
1183}

◆ crypto_stream_salsa20()

int Botan::Sodium::crypto_stream_salsa20 ( uint8_t out[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 52 of file sodium_salsa.cpp.

52 {
53 Salsa20 salsa;
54 salsa.set_key(key, crypto_stream_salsa20_KEYBYTES);
55 salsa.set_iv(nonce, crypto_stream_salsa20_NONCEBYTES);
56 salsa.write_keystream(out, out_len);
57 return 0;
58}
void set_iv(const uint8_t iv[], size_t iv_len)
void write_keystream(uint8_t out[], size_t len)
void set_key(const SymmetricKey &key)
Definition sym_algo.h:113

References crypto_stream_salsa20_KEYBYTES, crypto_stream_salsa20_NONCEBYTES, Botan::StreamCipher::set_iv(), Botan::SymmetricAlgorithm::set_key(), and Botan::StreamCipher::write_keystream().

◆ crypto_stream_salsa20_keybytes()

size_t Botan::Sodium::crypto_stream_salsa20_keybytes ( )
inline

Definition at line 1140 of file sodium.h.

1140 {
1142}

References crypto_stream_xsalsa20_KEYBYTES.

◆ crypto_stream_salsa20_keygen()

void Botan::Sodium::crypto_stream_salsa20_keygen ( uint8_t k[32])
inline

Definition at line 1163 of file sodium.h.

1163 {
1164 return randombytes_buf(k, 32);
1165}

References randombytes_buf().

◆ crypto_stream_salsa20_messagebytes_max()

size_t Botan::Sodium::crypto_stream_salsa20_messagebytes_max ( )
inline

Definition at line 1148 of file sodium.h.

1148 {
1150}

References crypto_stream_salsa20_MESSAGEBYTES_MAX.

◆ crypto_stream_salsa20_noncebytes()

size_t Botan::Sodium::crypto_stream_salsa20_noncebytes ( )
inline

Definition at line 1144 of file sodium.h.

1144 {
1146}

References crypto_stream_salsa20_NONCEBYTES.

◆ crypto_stream_salsa20_xor()

int Botan::Sodium::crypto_stream_salsa20_xor ( uint8_t out[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 60 of file sodium_salsa.cpp.

61 {
62 return crypto_stream_salsa20_xor_ic(out, in, in_len, nonce, 0, key);
63}
int crypto_stream_salsa20_xor_ic(uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], uint64_t ic, const uint8_t key[])

References crypto_stream_salsa20_xor_ic().

◆ crypto_stream_salsa20_xor_ic()

int Botan::Sodium::crypto_stream_salsa20_xor_ic ( uint8_t out[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
uint64_t ic,
const uint8_t key[] )

Definition at line 65 of file sodium_salsa.cpp.

66 {
67 if((ic >> 6) != 0) { // otherwise multiply overflows
68 return -1;
69 }
70
71 Salsa20 salsa;
72 salsa.set_key(key, crypto_stream_salsa20_KEYBYTES);
73 salsa.set_iv(nonce, crypto_stream_salsa20_NONCEBYTES);
74 salsa.seek(ic * 64);
75 salsa.cipher(in, out, in_len);
76 return 0;
77}
void seek(uint64_t offset) override
Definition salsa20.cpp:267
void cipher(const uint8_t in[], uint8_t out[], size_t len)

References Botan::StreamCipher::cipher(), crypto_stream_salsa20_KEYBYTES, crypto_stream_salsa20_NONCEBYTES, Botan::Salsa20::seek(), Botan::StreamCipher::set_iv(), and Botan::SymmetricAlgorithm::set_key().

Referenced by crypto_stream_salsa20_xor().

◆ crypto_stream_xchacha20()

int Botan::Sodium::crypto_stream_xchacha20 ( uint8_t out[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 63 of file sodium_chacha.cpp.

63 {
64 auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
65 chacha->set_key(key, crypto_stream_xchacha20_KEYBYTES);
66 chacha->set_iv(nonce, crypto_stream_xchacha20_NONCEBYTES);
67 chacha->write_keystream(out, out_len);
68 return 0;
69}

References Botan::StreamCipher::create_or_throw(), crypto_stream_xchacha20_KEYBYTES, and crypto_stream_xchacha20_NONCEBYTES.

◆ crypto_stream_xchacha20_keybytes()

size_t Botan::Sodium::crypto_stream_xchacha20_keybytes ( )
inline

Definition at line 1111 of file sodium.h.

1111 {
1113}

References crypto_stream_xchacha20_KEYBYTES.

◆ crypto_stream_xchacha20_keygen()

void Botan::Sodium::crypto_stream_xchacha20_keygen ( uint8_t k[32])
inline

Definition at line 1134 of file sodium.h.

1134 {
1135 return randombytes_buf(k, crypto_stream_xchacha20_KEYBYTES);
1136}

References crypto_stream_xchacha20_KEYBYTES, and randombytes_buf().

◆ crypto_stream_xchacha20_messagebytes_max()

size_t Botan::Sodium::crypto_stream_xchacha20_messagebytes_max ( )
inline

Definition at line 1119 of file sodium.h.

1119 {
1121}

References crypto_stream_xchacha20_MESSAGEBYTES_MAX.

◆ crypto_stream_xchacha20_noncebytes()

size_t Botan::Sodium::crypto_stream_xchacha20_noncebytes ( )
inline

Definition at line 1115 of file sodium.h.

1115 {
1117}

References crypto_stream_xchacha20_NONCEBYTES.

◆ crypto_stream_xchacha20_xor()

int Botan::Sodium::crypto_stream_xchacha20_xor ( uint8_t out[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 71 of file sodium_chacha.cpp.

72 {
73 return crypto_stream_xchacha20_xor_ic(out, in, in_len, nonce, 0, key);
74}
int crypto_stream_xchacha20_xor_ic(uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], uint64_t ic, const uint8_t key[])

References crypto_stream_xchacha20_xor_ic().

◆ crypto_stream_xchacha20_xor_ic()

int Botan::Sodium::crypto_stream_xchacha20_xor_ic ( uint8_t out[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
uint64_t ic,
const uint8_t key[] )

Definition at line 76 of file sodium_chacha.cpp.

77 {
78 if((ic >> 6) != 0) { // otherwise multiply overflows
79 return -1;
80 }
81
82 auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
83 chacha->set_key(key, crypto_stream_xchacha20_KEYBYTES);
84 chacha->set_iv(nonce, crypto_stream_xchacha20_NONCEBYTES);
85 chacha->seek(ic * 64);
86 chacha->cipher(in, out, in_len);
87 return 0;
88}

References Botan::StreamCipher::create_or_throw(), crypto_stream_xchacha20_KEYBYTES, and crypto_stream_xchacha20_NONCEBYTES.

Referenced by crypto_stream_xchacha20_xor().

◆ crypto_stream_xor()

int Botan::Sodium::crypto_stream_xor ( uint8_t out[],
const uint8_t in[],
size_t in_len,
const uint8_t nonce[24],
const uint8_t key[32] )
inline

Definition at line 1189 of file sodium.h.

1190 {
1191 return crypto_stream_xsalsa20_xor(out, in, in_len, nonce, key);
1192}
int crypto_stream_xsalsa20_xor(uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])

References crypto_stream_xsalsa20_xor().

◆ crypto_stream_xsalsa20()

int Botan::Sodium::crypto_stream_xsalsa20 ( uint8_t out[],
size_t ctext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 79 of file sodium_salsa.cpp.

79 {
80 Salsa20 salsa;
81 salsa.set_key(key, crypto_stream_xsalsa20_KEYBYTES);
82 salsa.set_iv(nonce, crypto_stream_xsalsa20_NONCEBYTES);
83 salsa.write_keystream(out, out_len);
84 return 0;
85}

References crypto_stream_xsalsa20_KEYBYTES, crypto_stream_xsalsa20_NONCEBYTES, Botan::StreamCipher::set_iv(), Botan::SymmetricAlgorithm::set_key(), and Botan::StreamCipher::write_keystream().

Referenced by crypto_stream().

◆ crypto_stream_xsalsa20_keybytes()

size_t Botan::Sodium::crypto_stream_xsalsa20_keybytes ( )
inline

Definition at line 907 of file sodium.h.

907 {
909}

References crypto_stream_xsalsa20_KEYBYTES.

Referenced by crypto_stream_keybytes().

◆ crypto_stream_xsalsa20_keygen()

void Botan::Sodium::crypto_stream_xsalsa20_keygen ( uint8_t k[32])
inline

Definition at line 930 of file sodium.h.

930 {
931 return randombytes_buf(k, 32);
932}

References randombytes_buf().

◆ crypto_stream_xsalsa20_messagebytes_max()

size_t Botan::Sodium::crypto_stream_xsalsa20_messagebytes_max ( )
inline

Definition at line 915 of file sodium.h.

References crypto_stream_xsalsa20_MESSAGEBYTES_MAX.

◆ crypto_stream_xsalsa20_noncebytes()

size_t Botan::Sodium::crypto_stream_xsalsa20_noncebytes ( )
inline

Definition at line 911 of file sodium.h.

911 {
913}

References crypto_stream_xsalsa20_NONCEBYTES.

Referenced by crypto_stream_noncebytes().

◆ crypto_stream_xsalsa20_xor()

int Botan::Sodium::crypto_stream_xsalsa20_xor ( uint8_t out[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
const uint8_t key[] )

Definition at line 87 of file sodium_salsa.cpp.

88 {
89 return crypto_stream_xsalsa20_xor_ic(out, in, in_len, nonce, 0, key);
90}
int crypto_stream_xsalsa20_xor_ic(uint8_t out[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], uint64_t ic, const uint8_t key[])

References crypto_stream_xsalsa20_xor_ic().

Referenced by crypto_stream_xor().

◆ crypto_stream_xsalsa20_xor_ic()

int Botan::Sodium::crypto_stream_xsalsa20_xor_ic ( uint8_t out[],
const uint8_t ptext[],
size_t ptext_len,
const uint8_t nonce[],
uint64_t ic,
const uint8_t key[] )

Definition at line 92 of file sodium_salsa.cpp.

93 {
94 if((ic >> 6) != 0) { // otherwise multiply overflows
95 return -1;
96 }
97
98 Salsa20 salsa;
99 salsa.set_key(key, crypto_stream_xsalsa20_KEYBYTES);
100 salsa.set_iv(nonce, crypto_stream_xsalsa20_NONCEBYTES);
101 salsa.seek(ic * 64);
102 salsa.cipher(in, out, in_len);
103 return 0;
104}

References Botan::StreamCipher::cipher(), crypto_stream_xsalsa20_KEYBYTES, crypto_stream_xsalsa20_NONCEBYTES, Botan::Salsa20::seek(), Botan::StreamCipher::set_iv(), and Botan::SymmetricAlgorithm::set_key().

Referenced by crypto_stream_xsalsa20_xor().

◆ crypto_verify_16()

int Botan::Sodium::crypto_verify_16 ( const uint8_t x[16],
const uint8_t y[16] )

Definition at line 43 of file sodium_utils.cpp.

43 {
44 return static_cast<int>(CT::is_equal(x, y, 16).select(1, 0));
45}

References Botan::CT::is_equal().

Referenced by crypto_onetimeauth_poly1305_verify().

◆ crypto_verify_32()

int Botan::Sodium::crypto_verify_32 ( const uint8_t x[32],
const uint8_t y[32] )

Definition at line 47 of file sodium_utils.cpp.

47 {
48 return static_cast<int>(CT::is_equal(x, y, 32).select(1, 0));
49}

References Botan::CT::is_equal().

Referenced by crypto_auth_hmacsha256_verify(), and crypto_auth_hmacsha512256_verify().

◆ crypto_verify_64()

int Botan::Sodium::crypto_verify_64 ( const uint8_t x[64],
const uint8_t y[64] )

Definition at line 51 of file sodium_utils.cpp.

51 {
52 return static_cast<int>(CT::is_equal(x, y, 64).select(1, 0));
53}

References Botan::CT::is_equal().

Referenced by crypto_auth_hmacsha512_verify().

◆ randombytes()

void Botan::Sodium::randombytes ( uint8_t buf[],
size_t buf_len )
inline

Definition at line 248 of file sodium.h.

248 {
249 return randombytes_buf(buf, buf_len);
250}

References randombytes_buf().

◆ randombytes_buf()

void Botan::Sodium::randombytes_buf ( void * buf,
size_t size )

◆ randombytes_buf_deterministic()

void Botan::Sodium::randombytes_buf_deterministic ( void * buf,
size_t size,
const uint8_t seed[randombytes_SEEDBYTES] )

Definition at line 34 of file sodium_utils.cpp.

34 {
35 const unsigned char nonce[12] = {'L', 'i', 'b', 's', 'o', 'd', 'i', 'u', 'm', 'D', 'R', 'G'};
36
37 ChaCha chacha(20);
38 chacha.set_key(seed, randombytes_SEEDBYTES);
39 chacha.set_iv(nonce, sizeof(nonce));
40 chacha.write_keystream(static_cast<uint8_t*>(buf), size);
41}

References randombytes_SEEDBYTES, Botan::StreamCipher::set_iv(), Botan::SymmetricAlgorithm::set_key(), and Botan::StreamCipher::write_keystream().

◆ randombytes_close()

int Botan::Sodium::randombytes_close ( )
inline

Definition at line 240 of file sodium.h.

240 {
241 return 0;
242}

◆ randombytes_implementation_name()

const char * Botan::Sodium::randombytes_implementation_name ( )
inline

Definition at line 244 of file sodium.h.

244 {
245 return "botan";
246}

◆ randombytes_random()

uint32_t Botan::Sodium::randombytes_random ( )
inline

Definition at line 232 of file sodium.h.

232 {
233 uint32_t x = 0;
234 randombytes_buf(&x, 4);
235 return x;
236}

References randombytes_buf().

◆ randombytes_seedbytes()

size_t Botan::Sodium::randombytes_seedbytes ( )
inline

Definition at line 219 of file sodium.h.

219 {
221}

References randombytes_SEEDBYTES.

◆ randombytes_stir()

void Botan::Sodium::randombytes_stir ( )
inline

Definition at line 238 of file sodium.h.

238{}

◆ randombytes_uniform()

uint32_t Botan::Sodium::randombytes_uniform ( uint32_t upper_bound)

Definition at line 23 of file sodium_utils.cpp.

23 {
24 if(upper_bound <= 1) {
25 return 0;
26 }
27
28 // Not completely uniform
29 uint64_t x;
30 randombytes_buf(&x, sizeof(x));
31 return x % upper_bound;
32}

References randombytes_buf().

◆ sodium_add()

void Botan::Sodium::sodium_add ( uint8_t a[],
const uint8_t b[],
size_t len )

Definition at line 97 of file sodium_utils.cpp.

97 {
98 uint8_t carry = 0;
99 for(size_t i = 0; i != len; ++i) {
100 a[i] += b[i] + carry;
101 carry = (a[i] < b[i]);
102 }
103}
void carry(int64_t &h0, int64_t &h1)

References Botan::carry().

◆ sodium_allocarray()

void * Botan::Sodium::sodium_allocarray ( size_t count,
size_t size )

Definition at line 130 of file sodium_utils.cpp.

130 {
131 const size_t bytes = count * size;
132 if(bytes < count || bytes < size) {
133 return nullptr;
134 }
135 return sodium_malloc(bytes);
136}

References sodium_malloc().

◆ sodium_compare()

int Botan::Sodium::sodium_compare ( const uint8_t x[],
const uint8_t y[],
size_t len )

Definition at line 65 of file sodium_utils.cpp.

65 {
66 const uint8_t LT = static_cast<uint8_t>(-1);
67 const uint8_t EQ = 0;
68 const uint8_t GT = 1;
69
70 uint8_t result = EQ; // until found otherwise
71
72 for(size_t i = 0; i != len; ++i) {
73 const auto is_eq = CT::Mask<uint8_t>::is_equal(x[i], y[i]);
74 const auto is_lt = CT::Mask<uint8_t>::is_lt(x[i], y[i]);
75 result = is_eq.select(result, is_lt.select(LT, GT));
76 }
77
78 return static_cast<int8_t>(result);
79}

References Botan::CT::Mask< T >::is_equal(), and Botan::CT::Mask< T >::is_lt().

◆ sodium_free()

void Botan::Sodium::sodium_free ( void * ptr)

Definition at line 118 of file sodium_utils.cpp.

118 {
119 if(ptr == nullptr) {
120 return;
121 }
122
123 uint8_t* p = static_cast<uint8_t*>(ptr) - 8;
124 const uint64_t len = load_le<uint64_t>(p, 0);
125 secure_scrub_memory(ptr, static_cast<size_t>(len));
126 // NOLINTNEXTLINE(*-no-malloc)
127 std::free(p);
128}
void secure_scrub_memory(void *ptr, size_t n)
Definition os_utils.cpp:87

References Botan::secure_scrub_memory().

◆ sodium_increment()

void Botan::Sodium::sodium_increment ( uint8_t n[],
size_t nlen )

Definition at line 89 of file sodium_utils.cpp.

89 {
90 uint8_t carry = 1;
91 for(size_t i = 0; i != len; ++i) {
92 b[i] += carry;
93 carry &= (b[i] == 0);
94 }
95}

References Botan::carry().

◆ sodium_init()

int Botan::Sodium::sodium_init ( )
inline

Definition at line 168 of file sodium.h.

168 {
169 return 0;
170}

◆ sodium_is_zero()

int Botan::Sodium::sodium_is_zero ( const uint8_t nonce[],
size_t nlen )

Definition at line 81 of file sodium_utils.cpp.

81 {
82 uint8_t sum = 0;
83 for(size_t i = 0; i != len; ++i) {
84 sum |= b[i];
85 }
86 return static_cast<int>(CT::Mask<uint8_t>::expand(sum).if_not_set_return(1));
87}
constexpr T if_not_set_return(T x) const
Definition ct_utils.h:229

References Botan::CT::Mask< T >::expand().

◆ sodium_library_minimal()

int Botan::Sodium::sodium_library_minimal ( )
inline

Definition at line 164 of file sodium.h.

164 {
165 return 0;
166}

◆ sodium_library_version_major()

int Botan::Sodium::sodium_library_version_major ( )
inline

Definition at line 156 of file sodium.h.

156 {
157 return 0;
158}

◆ sodium_library_version_minor()

int Botan::Sodium::sodium_library_version_minor ( )
inline

Definition at line 160 of file sodium.h.

160 {
161 return 0;
162}

◆ sodium_malloc()

void * Botan::Sodium::sodium_malloc ( size_t size)

Definition at line 105 of file sodium_utils.cpp.

105 {
106 const uint64_t len = size;
107
108 if(size + sizeof(len) < size) {
109 return nullptr;
110 }
111
112 // NOLINTNEXTLINE(*-no-malloc)
113 uint8_t* p = static_cast<uint8_t*>(std::calloc(size + sizeof(len), 1));
114 store_le(len, p);
115 return p + 8;
116}

References Botan::store_le().

Referenced by sodium_allocarray().

◆ sodium_memcmp()

int Botan::Sodium::sodium_memcmp ( const void * x,
const void * y,
size_t len )

Definition at line 59 of file sodium_utils.cpp.

59 {
60 const auto same = CT::is_equal(static_cast<const uint8_t*>(x), static_cast<const uint8_t*>(y), len);
61 // Return 0 if same or -1 if differing
62 return static_cast<int>(same.select(1, 0)) - 1;
63}

References Botan::CT::is_equal().

◆ sodium_memzero()

void Botan::Sodium::sodium_memzero ( void * ptr,
size_t len )

Definition at line 55 of file sodium_utils.cpp.

55 {
56 secure_scrub_memory(ptr, len);
57}

References Botan::secure_scrub_memory().

◆ sodium_mprotect_noaccess()

int Botan::Sodium::sodium_mprotect_noaccess ( void * ptr)

Definition at line 138 of file sodium_utils.cpp.

138 {
139 OS::page_prohibit_access(ptr);
140 return 0;
141}

References Botan::OS::page_prohibit_access().

◆ sodium_mprotect_readwrite()

int Botan::Sodium::sodium_mprotect_readwrite ( void * ptr)

Definition at line 143 of file sodium_utils.cpp.

143 {
144 OS::page_allow_access(ptr);
145 return 0;
146}

References Botan::OS::page_allow_access().

◆ sodium_version_string()

const char * Botan::Sodium::sodium_version_string ( )
inline

Definition at line 152 of file sodium.h.

152 {
153 return "Botan Sodium Compat";
154}