Botan  2.19.1
Crypto and TLS for C++11
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_curve25519xsalsa20poly1305_BOXZEROBYTES + crypto_box_curve25519xsalsa20poly1305_MACBYTES, 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_xsalsa20poly1305_BOXZEROBYTES + crypto_secretbox_xsalsa20poly1305_MACBYTES, 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 Sodium namespace contains a partial implementation of the libsodium API.

Enumeration Type Documentation

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 21 of file sodium.h.

21  : size_t {
22  SODIUM_SIZE_MAX = 0xFFFFFFFF,
23 
29 
35 
41 
48 
51 
61 
71 
76 
81 
85 
90 
95 
101  crypto_secretbox_xsalsa20poly1305_ZEROBYTES = crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES + crypto_secretbox_xsalsa20poly1305_MACBYTES,
102 
109 
114 
125 
144 
148 
150 };

Function Documentation

size_t Botan::Sodium::crypto_aead_chacha20poly1305_abytes ( )
inline
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 236 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_npubbytes().

245  {
246  BOTAN_UNUSED(unused_secret_nonce);
247  return sodium_aead_chacha20poly1305_decrypt(
248  ptext, ptext_len, ctext, ctext_len,
249  ad, ad_len, nonce, crypto_aead_chacha20poly1305_npubbytes(), key);
250  }
size_t crypto_aead_chacha20poly1305_npubbytes()
Definition: sodium.h:457
#define BOTAN_UNUSED(...)
Definition: assert.h:142
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 272 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_npubbytes().

281  {
282  BOTAN_UNUSED(unused_secret_nonce);
283 
284  return sodium_aead_chacha20poly1305_decrypt_detached(
285  ptext, ctext, ctext_len, mac,
286  ad, ad_len, nonce, crypto_aead_chacha20poly1305_npubbytes(), key);
287  }
size_t crypto_aead_chacha20poly1305_npubbytes()
Definition: sodium.h:457
#define BOTAN_UNUSED(...)
Definition: assert.h:142
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 220 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_npubbytes().

229  {
230  BOTAN_UNUSED(unused_secret_nonce);
231  return sodium_aead_chacha20poly1305_encrypt(
232  ctext, ctext_len, ptext, ptext_len,
233  ad, ad_len, nonce, crypto_aead_chacha20poly1305_npubbytes(), key);
234  }
size_t crypto_aead_chacha20poly1305_npubbytes()
Definition: sodium.h:457
#define BOTAN_UNUSED(...)
Definition: assert.h:142
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 252 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_npubbytes().

262  {
263  BOTAN_UNUSED(unused_secret_nonce);
264  if(mac_len)
265  *mac_len = 16;
266 
267  return sodium_aead_chacha20poly1305_encrypt_detached(
268  ctext, mac, ptext, ptext_len,
269  ad, ad_len, nonce, crypto_aead_chacha20poly1305_npubbytes(), key);
270  }
size_t crypto_aead_chacha20poly1305_npubbytes()
Definition: sodium.h:457
#define BOTAN_UNUSED(...)
Definition: assert.h:142
size_t Botan::Sodium::crypto_aead_chacha20poly1305_ietf_abytes ( )
inline
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 165 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_ietf_npubbytes().

174  {
175  BOTAN_UNUSED(unused_secret_nonce);
176 
177  return sodium_aead_chacha20poly1305_decrypt(
178  ptext, ptext_len, ctext, ctext_len,
179  ad, ad_len, nonce, crypto_aead_chacha20poly1305_ietf_npubbytes(), key);
180  }
size_t crypto_aead_chacha20poly1305_ietf_npubbytes()
Definition: sodium.h:382
#define BOTAN_UNUSED(...)
Definition: assert.h:142
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 203 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_ietf_npubbytes().

212  {
213  BOTAN_UNUSED(unused_secret_nonce);
214 
215  return sodium_aead_chacha20poly1305_decrypt_detached(
216  ptext, ctext, ctext_len, mac,
217  ad, ad_len, nonce, crypto_aead_chacha20poly1305_ietf_npubbytes(), key);
218  }
size_t crypto_aead_chacha20poly1305_ietf_npubbytes()
Definition: sodium.h:382
#define BOTAN_UNUSED(...)
Definition: assert.h:142
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 148 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_ietf_npubbytes().

157  {
158  BOTAN_UNUSED(unused_secret_nonce);
159 
160  return sodium_aead_chacha20poly1305_encrypt(
161  ctext, ctext_len, ptext, ptext_len,
162  ad, ad_len, nonce, crypto_aead_chacha20poly1305_ietf_npubbytes(), key);
163  }
size_t crypto_aead_chacha20poly1305_ietf_npubbytes()
Definition: sodium.h:382
#define BOTAN_UNUSED(...)
Definition: assert.h:142
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 182 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_chacha20poly1305_ietf_npubbytes().

192  {
193  BOTAN_UNUSED(unused_secret_nonce);
194 
195  if(mac_len)
196  *mac_len = 16;
197 
198  return sodium_aead_chacha20poly1305_encrypt_detached(
199  ctext, mac, ptext, ptext_len,
200  ad, ad_len, nonce, crypto_aead_chacha20poly1305_ietf_npubbytes(), key);
201  }
size_t crypto_aead_chacha20poly1305_ietf_npubbytes()
Definition: sodium.h:382
#define BOTAN_UNUSED(...)
Definition: assert.h:142
size_t Botan::Sodium::crypto_aead_chacha20poly1305_ietf_keybytes ( )
inline
void Botan::Sodium::crypto_aead_chacha20poly1305_ietf_keygen ( uint8_t  k[32])
inline
size_t Botan::Sodium::crypto_aead_chacha20poly1305_ietf_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_aead_chacha20poly1305_ietf_npubbytes ( )
inline
size_t Botan::Sodium::crypto_aead_chacha20poly1305_ietf_nsecbytes ( )
inline
size_t Botan::Sodium::crypto_aead_chacha20poly1305_keybytes ( )
inline
void Botan::Sodium::crypto_aead_chacha20poly1305_keygen ( uint8_t  k[32])
inline

Definition at line 517 of file sodium.h.

References randombytes_buf().

518  {
519  randombytes_buf(k, 32);
520  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_aead_chacha20poly1305_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_aead_chacha20poly1305_npubbytes ( )
inline
size_t Botan::Sodium::crypto_aead_chacha20poly1305_nsecbytes ( )
inline
size_t Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_abytes ( )
inline
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 306 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_xchacha20poly1305_ietf_npubbytes().

315  {
316  BOTAN_UNUSED(unused_secret_nonce);
317 
318  return sodium_aead_chacha20poly1305_decrypt(
319  ptext, ptext_len, ctext, ctext_len,
320  ad, ad_len, nonce, crypto_aead_xchacha20poly1305_ietf_npubbytes(), key);
321  }
#define BOTAN_UNUSED(...)
Definition: assert.h:142
size_t crypto_aead_xchacha20poly1305_ietf_npubbytes()
Definition: sodium.h:534
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 343 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_xchacha20poly1305_ietf_npubbytes().

352  {
353  BOTAN_UNUSED(unused_secret_nonce);
354  return sodium_aead_chacha20poly1305_decrypt_detached(
355  ptext, ctext, ctext_len, mac,
356  ad, ad_len, nonce, crypto_aead_xchacha20poly1305_ietf_npubbytes(), key);
357  }
#define BOTAN_UNUSED(...)
Definition: assert.h:142
size_t crypto_aead_xchacha20poly1305_ietf_npubbytes()
Definition: sodium.h:534
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 289 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_xchacha20poly1305_ietf_npubbytes().

298  {
299  BOTAN_UNUSED(unused_secret_nonce);
300 
301  return sodium_aead_chacha20poly1305_encrypt(
302  ctext, ctext_len, ptext, ptext_len,
303  ad, ad_len, nonce, crypto_aead_xchacha20poly1305_ietf_npubbytes(), key);
304  }
#define BOTAN_UNUSED(...)
Definition: assert.h:142
size_t crypto_aead_xchacha20poly1305_ietf_npubbytes()
Definition: sodium.h:534
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 323 of file sodium_aead.cpp.

References BOTAN_UNUSED, and crypto_aead_xchacha20poly1305_ietf_npubbytes().

333  {
334  BOTAN_UNUSED(unused_secret_nonce);
335  if(mac_len)
336  *mac_len = 16;
337 
338  return sodium_aead_chacha20poly1305_encrypt_detached(
339  ctext, mac, ptext, ptext_len,
340  ad, ad_len, nonce, crypto_aead_xchacha20poly1305_ietf_npubbytes(), key);
341  }
#define BOTAN_UNUSED(...)
Definition: assert.h:142
size_t crypto_aead_xchacha20poly1305_ietf_npubbytes()
Definition: sodium.h:534
size_t Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_keybytes ( )
inline
void Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_keygen ( uint8_t  k[32])
inline

Definition at line 594 of file sodium.h.

References randombytes_buf().

595  {
596  return randombytes_buf(k, 32);
597  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_npubbytes ( )
inline
size_t Botan::Sodium::crypto_aead_xchacha20poly1305_ietf_nsecbytes ( )
inline
int Botan::Sodium::crypto_auth ( uint8_t  out[],
const uint8_t  in[],
size_t  in_len,
const uint8_t  key[] 
)
inline

Definition at line 920 of file sodium.h.

References crypto_auth_hmacsha512256().

922  {
923  return crypto_auth_hmacsha512256(out, in, in_len, key);
924  }
int crypto_auth_hmacsha512256(uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
Definition: sodium_auth.cpp:83
size_t Botan::Sodium::crypto_auth_bytes ( )
inline

Definition at line 914 of file sodium.h.

References crypto_auth_BYTES.

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

Definition at line 109 of file sodium_auth.cpp.

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

Referenced by crypto_auth_hmacsha256_verify().

113  {
114  auto mac = MessageAuthenticationCode::create_or_throw("HMAC(SHA-256)");
115  mac->set_key(key, crypto_auth_hmacsha256_KEYBYTES);
116  mac->update(in, in_len);
117  mac->final(out);
118  return 0;
119  }
size_t Botan::Sodium::crypto_auth_hmacsha256_bytes ( )
inline

Definition at line 949 of file sodium.h.

References crypto_auth_hmacsha256_BYTES.

size_t Botan::Sodium::crypto_auth_hmacsha256_keybytes ( )
inline

Definition at line 954 of file sodium.h.

References crypto_auth_hmacsha256_KEYBYTES.

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

Definition at line 971 of file sodium.h.

References randombytes_buf().

972  {
973  return randombytes_buf(k, 32);
974  }
void randombytes_buf(void *buf, size_t size)
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 121 of file sodium_auth.cpp.

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

125  {
126  secure_vector<uint8_t> computed(crypto_auth_hmacsha256_BYTES);
127  crypto_auth_hmacsha256(computed.data(), in, in_len, key);
128  return crypto_verify_32(computed.data(), mac) ? 0 : -1;
129  }
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[])
int Botan::Sodium::crypto_auth_hmacsha512 ( uint8_t  out[],
const uint8_t  in[],
size_t  in_len,
const uint8_t  key[] 
)

Definition at line 61 of file sodium_auth.cpp.

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

Referenced by crypto_auth_hmacsha512_verify().

65  {
66  auto mac = MessageAuthenticationCode::create_or_throw("HMAC(SHA-512)");
67  mac->set_key(key, crypto_auth_hmacsha512_KEYBYTES);
68  mac->update(in, in_len);
69  mac->final(out);
70  return 0;
71  }
int Botan::Sodium::crypto_auth_hmacsha512256 ( uint8_t  out[],
const uint8_t  in[],
size_t  in_len,
const uint8_t  key[] 
)

Definition at line 83 of file sodium_auth.cpp.

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().

87  {
88  auto mac = MessageAuthenticationCode::create_or_throw("HMAC(SHA-512)");
89  mac->set_key(key, crypto_auth_hmacsha512256_KEYBYTES);
90  mac->update(in, in_len);
91 
92  secure_vector<uint8_t> buf(64);
93  mac->final(buf);
94 
95  copy_mem(out, buf.data(), crypto_auth_hmacsha512256_BYTES);
96  return 0;
97  }
void copy_mem(T *out, const T *in, size_t n)
Definition: mem_ops.h:133
size_t Botan::Sodium::crypto_auth_hmacsha512256_bytes ( )
inline

Definition at line 885 of file sodium.h.

References crypto_auth_hmacsha512256_BYTES.

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

Definition at line 907 of file sodium.h.

References randombytes_buf().

908  {
909  return randombytes_buf(k, 32);
910  }
void randombytes_buf(void *buf, size_t size)
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 99 of file sodium_auth.cpp.

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

Referenced by crypto_auth_verify().

103  {
104  secure_vector<uint8_t> computed(crypto_auth_hmacsha512256_BYTES);
105  crypto_auth_hmacsha512256(computed.data(), in, in_len, key);
106  return crypto_verify_32(computed.data(), mac) ? 0 : -1;
107  }
int crypto_auth_hmacsha512256(uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
Definition: sodium_auth.cpp:83
int crypto_verify_32(const uint8_t x[32], const uint8_t y[32])
size_t Botan::Sodium::crypto_auth_hmacsha512_bytes ( )
inline
size_t Botan::Sodium::crypto_auth_hmacsha512_keybytes ( )
inline
void Botan::Sodium::crypto_auth_hmacsha512_keygen ( uint8_t  k[32])
inline

Definition at line 878 of file sodium.h.

References randombytes_buf().

879  {
880  return randombytes_buf(k, 32);
881  }
void randombytes_buf(void *buf, size_t size)
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 73 of file sodium_auth.cpp.

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

77  {
78  secure_vector<uint8_t> computed(crypto_auth_hmacsha512_BYTES);
79  crypto_auth_hmacsha512(computed.data(), in, in_len, key);
80  return crypto_verify_64(computed.data(), mac) ? 0 : -1;
81  }
int crypto_auth_hmacsha512(uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
Definition: sodium_auth.cpp:61
int crypto_verify_64(const uint8_t x[64], const uint8_t y[64])
size_t Botan::Sodium::crypto_auth_keybytes ( )
inline

Definition at line 916 of file sodium.h.

References crypto_auth_KEYBYTES.

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

Definition at line 932 of file sodium.h.

References crypto_auth_KEYBYTES, and randombytes_buf().

933  {
935  }
void randombytes_buf(void *buf, size_t size)
const char* Botan::Sodium::crypto_auth_primitive ( )
inline

Definition at line 918 of file sodium.h.

918 { return "hmacsha512256"; }
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 926 of file sodium.h.

References crypto_auth_hmacsha512256_verify().

928  {
929  return crypto_auth_hmacsha512256_verify(mac, in, in_len, key);
930  }
int crypto_auth_hmacsha512256_verify(const uint8_t h[], const uint8_t in[], size_t in_len, const uint8_t key[])
Definition: sodium_auth.cpp:99
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 839 of file sodium.h.

References crypto_box_curve25519xsalsa20poly1305().

842  {
843  return crypto_box_curve25519xsalsa20poly1305(ctext, ptext, ptext_len, nonce, pk, sk);
844  }
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])
Definition: sodium_box.cpp:42
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 785 of file sodium.h.

References crypto_box_curve25519xsalsa20poly1305_afternm().

788  {
789  return crypto_box_curve25519xsalsa20poly1305_afternm(ctext, ptext, ptext_len, nonce, key);
790  }
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:676
int Botan::Sodium::crypto_box_beforenm ( uint8_t  key[],
const uint8_t  pk[32],
const uint8_t  sk[32] 
)
inline

Definition at line 779 of file sodium.h.

References crypto_box_curve25519xsalsa20poly1305_beforenm().

Referenced by crypto_box_detached(), and crypto_box_open_detached().

781  {
783  }
int crypto_box_curve25519xsalsa20poly1305_beforenm(uint8_t key[], const uint8_t pk[32], const uint8_t sk[32])
Definition: sodium_box.cpp:29
size_t Botan::Sodium::crypto_box_beforenmbytes ( )
inline

Definition at line 726 of file sodium.h.

References crypto_box_BEFORENMBYTES.

size_t Botan::Sodium::crypto_box_boxzerobytes ( )
inline

Definition at line 837 of file sodium.h.

References crypto_box_BOXZEROBYTES.

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 42 of file sodium_box.cpp.

References crypto_box_curve25519xsalsa20poly1305_afternm(), and crypto_box_curve25519xsalsa20poly1305_beforenm().

Referenced by crypto_box().

48  {
49  secure_vector<uint8_t> shared(32);
50 
51  if(crypto_box_curve25519xsalsa20poly1305_beforenm(shared.data(), pk, sk) != 0)
52  return -1;
53 
54  return crypto_box_curve25519xsalsa20poly1305_afternm(ctext, ptext, ptext_len, nonce, shared.data());
55  }
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:676
int crypto_box_curve25519xsalsa20poly1305_beforenm(uint8_t key[], const uint8_t pk[32], const uint8_t sk[32])
Definition: sodium_box.cpp:29
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 676 of file sodium.h.

References crypto_secretbox_xsalsa20poly1305().

Referenced by crypto_box_afternm(), and crypto_box_curve25519xsalsa20poly1305().

681  {
682  return crypto_secretbox_xsalsa20poly1305(ctext, ptext, ptext_len, nonce, key);
683  }
int crypto_secretbox_xsalsa20poly1305(uint8_t ctext[], const uint8_t ptext[], size_t ptext_len, const uint8_t nonce[], const uint8_t key[])
int Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_beforenm ( uint8_t  key[],
const uint8_t  pk[32],
const uint8_t  sk[32] 
)

Definition at line 29 of file sodium_box.cpp.

References crypto_core_hsalsa20(), and crypto_scalarmult_curve25519().

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

32  {
33  const uint8_t zero[16] = { 0 };
34  secure_vector<uint8_t> shared(32);
35 
36  if(crypto_scalarmult_curve25519(shared.data(), sk, pk) != 0)
37  return -1;
38 
39  return crypto_core_hsalsa20(key, zero, shared.data(), nullptr);
40  }
int crypto_core_hsalsa20(uint8_t out[], const uint8_t in[], const uint8_t key[], const uint8_t c[])
int crypto_scalarmult_curve25519(uint8_t out[32], const uint8_t scalar[32], const uint8_t basepoint[32])
size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_beforenmbytes ( )
inline
size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_boxzerobytes ( )
inline
int Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_keypair ( uint8_t  pk[32],
uint8_t  sk[32] 
)

Definition at line 22 of file sodium_box.cpp.

References crypto_scalarmult_curve25519_base(), and randombytes_buf().

Referenced by crypto_box_keypair().

24  {
25  randombytes_buf(sk, 32);
26  return crypto_scalarmult_curve25519_base(pk, sk);
27  }
int crypto_scalarmult_curve25519_base(uint8_t out[32], const uint8_t scalar[32])
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_macbytes ( )
inline
size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_noncebytes ( )
inline
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 57 of file sodium_box.cpp.

References crypto_box_curve25519xsalsa20poly1305_beforenm(), and crypto_box_curve25519xsalsa20poly1305_open_afternm().

Referenced by crypto_box_open().

63  {
64  secure_vector<uint8_t> shared(32);
65 
66  if(crypto_box_curve25519xsalsa20poly1305_beforenm(shared.data(), pk, sk) != 0)
67  return -1;
68 
69  return crypto_box_curve25519xsalsa20poly1305_open_afternm(ptext, ctext, ctext_len, nonce, shared.data());
70  }
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:685
int crypto_box_curve25519xsalsa20poly1305_beforenm(uint8_t key[], const uint8_t pk[32], const uint8_t sk[32])
Definition: sodium_box.cpp:29
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 685 of file sodium.h.

References crypto_secretbox_xsalsa20poly1305_open().

Referenced by crypto_box_curve25519xsalsa20poly1305_open(), and crypto_box_open_afternm().

690  {
691  return crypto_secretbox_xsalsa20poly1305_open(ptext, ctext, ctext_len, nonce, key);
692  }
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 Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_publickeybytes ( )
inline
size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_secretkeybytes ( )
inline
int Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_seed_keypair ( uint8_t  pk[32],
uint8_t  sk[32],
const uint8_t  seed[32] 
)

Definition at line 12 of file sodium_box.cpp.

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

Referenced by crypto_box_seed_keypair().

15  {
16  secure_vector<uint8_t> digest(64);
17  crypto_hash_sha512(digest.data(), seed, 32);
18  copy_mem(sk, digest.data(), 32);
19  return crypto_scalarmult_curve25519_base(pk, sk);
20  }
int crypto_hash_sha512(uint8_t out[64], const uint8_t in[], size_t in_len)
Definition: sodium_auth.cpp:13
int crypto_scalarmult_curve25519_base(uint8_t out[32], const uint8_t scalar[32])
void copy_mem(T *out, const T *in, size_t n)
Definition: mem_ops.h:133
size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_seedbytes ( )
inline
size_t Botan::Sodium::crypto_box_curve25519xsalsa20poly1305_zerobytes ( )
inline
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 72 of file sodium_box.cpp.

References crypto_box_beforenm(), and crypto_box_detached_afternm().

Referenced by crypto_box_easy().

76  {
77  secure_vector<uint8_t> shared(32);
78 
79  if(crypto_box_beforenm(shared.data(), pk, sk) != 0)
80  return -1;
81 
82  return crypto_box_detached_afternm(ctext, mac, ptext, ptext_len, nonce, shared.data());
83  }
int crypto_box_beforenm(uint8_t key[], const uint8_t pk[32], const uint8_t sk[32])
Definition: sodium.h:779
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:821
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 821 of file sodium.h.

References crypto_secretbox_detached().

Referenced by crypto_box_detached(), and crypto_box_easy_afternm().

824  {
825  return crypto_secretbox_detached(ctext, mac, ptext, ptext_len, nonce, key);
826  }
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 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 758 of file sodium.h.

References crypto_box_detached(), and crypto_box_MACBYTES.

761  {
762  return crypto_box_detached(ctext + crypto_box_MACBYTES, ctext, ptext, ptext_len, nonce, pk, sk);
763  }
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])
Definition: sodium_box.cpp:72
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 828 of file sodium.h.

References crypto_box_detached_afternm(), and crypto_box_MACBYTES.

831  {
832  return crypto_box_detached_afternm(ctext + crypto_box_MACBYTES, ctext, ptext, ptext_len, nonce, key);
833  }
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:821
int Botan::Sodium::crypto_box_keypair ( uint8_t  pk[32],
uint8_t  sk[32] 
)
inline

Definition at line 739 of file sodium.h.

References crypto_box_curve25519xsalsa20poly1305_keypair().

740  {
742  }
int crypto_box_curve25519xsalsa20poly1305_keypair(uint8_t pk[32], uint8_t sk[32])
Definition: sodium_box.cpp:22
size_t Botan::Sodium::crypto_box_macbytes ( )
inline

Definition at line 716 of file sodium.h.

References crypto_box_MACBYTES.

717  {
718  return crypto_box_MACBYTES;
719  }
size_t Botan::Sodium::crypto_box_messagebytes_max ( )
inline

Definition at line 721 of file sodium.h.

References crypto_box_MESSAGEBYTES_MAX.

size_t Botan::Sodium::crypto_box_noncebytes ( )
inline

Definition at line 711 of file sodium.h.

References crypto_box_NONCEBYTES.

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 846 of file sodium.h.

References crypto_box_curve25519xsalsa20poly1305_open().

849  {
850  return crypto_box_curve25519xsalsa20poly1305_open(ptext, ctext, ctext_len, nonce, pk, sk);
851  }
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])
Definition: sodium_box.cpp:57
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 792 of file sodium.h.

References crypto_box_curve25519xsalsa20poly1305_open_afternm().

795  {
796  return crypto_box_curve25519xsalsa20poly1305_open_afternm(ptext, ctext, ctext_len, nonce, key);
797  }
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:685
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 85 of file sodium_box.cpp.

References crypto_box_beforenm(), and crypto_box_open_detached_afternm().

Referenced by crypto_box_open_easy().

91  {
92  secure_vector<uint8_t> shared(32);
93 
94  if(crypto_box_beforenm(shared.data(), pk, sk) != 0)
95  return -1;
96 
97  return crypto_box_open_detached_afternm(ptext, ctext, mac, ctext_len, nonce, shared.data());
98  }
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[])
Definition: sodium.h:799
int crypto_box_beforenm(uint8_t key[], const uint8_t pk[32], const uint8_t sk[32])
Definition: sodium.h:779
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 799 of file sodium.h.

References crypto_secretbox_open_detached().

Referenced by crypto_box_open_detached(), and crypto_box_open_easy_afternm().

803  {
804  return crypto_secretbox_open_detached(ptext, ctext, mac, ctext_len, nonce, key);
805  }
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 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 765 of file sodium.h.

References crypto_box_MACBYTES, and crypto_box_open_detached().

768  {
769  if(ctext_len < crypto_box_MACBYTES)
770  {
771  return -1;
772  }
773 
774  return crypto_box_open_detached(ptext, ctext + crypto_box_MACBYTES,
775  ctext, ctext_len - crypto_box_MACBYTES,
776  nonce, pk, sk);
777  }
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])
Definition: sodium_box.cpp:85
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 807 of file sodium.h.

References crypto_box_MACBYTES, and crypto_box_open_detached_afternm().

810  {
811  if(ctext_len < crypto_box_MACBYTES)
812  {
813  return -1;
814  }
815 
817  ctext, ctext_len - crypto_box_MACBYTES,
818  nonce, key);
819  }
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[])
Definition: sodium.h:799
const char* Botan::Sodium::crypto_box_primitive ( )
inline

Definition at line 731 of file sodium.h.

731 { return "curve25519xsalsa20poly1305"; }
size_t Botan::Sodium::crypto_box_publickeybytes ( )
inline

Definition at line 701 of file sodium.h.

References crypto_box_PUBLICKEYBYTES.

size_t Botan::Sodium::crypto_box_secretkeybytes ( )
inline

Definition at line 706 of file sodium.h.

References crypto_box_SECRETKEYBYTES.

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

Definition at line 733 of file sodium.h.

References crypto_box_curve25519xsalsa20poly1305_seed_keypair().

735  {
737  }
int crypto_box_curve25519xsalsa20poly1305_seed_keypair(uint8_t pk[32], uint8_t sk[32], const uint8_t seed[32])
Definition: sodium_box.cpp:12
size_t Botan::Sodium::crypto_box_seedbytes ( )
inline

Definition at line 696 of file sodium.h.

References crypto_box_SEEDBYTES.

697  {
698  return crypto_box_SEEDBYTES;
699  }
size_t Botan::Sodium::crypto_box_zerobytes ( )
inline

Definition at line 835 of file sodium.h.

References crypto_box_ZEROBYTES.

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

Definition at line 13 of file sodium_salsa.cpp.

References Botan::copy_out_le(), Botan::Salsa20::hsalsa20(), and Botan::load_le< uint32_t >().

Referenced by crypto_box_curve25519xsalsa20poly1305_beforenm().

15  {
16  uint32_t in32[16] = { 0 };
17 
18  static const uint32_t SIGMA[] =
19  { 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 };
20 
21  if(c == nullptr)
22  {
23  in32[0] = SIGMA[0];
24  in32[5] = SIGMA[1];
25  in32[10] = SIGMA[2];
26  in32[15] = SIGMA[3];
27  }
28  else
29  {
30  in32[0] = load_le<uint32_t>(c, 0);
31  in32[5] = load_le<uint32_t>(c, 1);
32  in32[10] = load_le<uint32_t>(c, 2);
33  in32[15] = load_le<uint32_t>(c, 3);
34  }
35 
36  in32[1] = load_le<uint32_t>(key, 0);
37  in32[2] = load_le<uint32_t>(key, 1);
38  in32[3] = load_le<uint32_t>(key, 2);
39  in32[4] = load_le<uint32_t>(key, 3);
40 
41  in32[6] = load_le<uint32_t>(in, 0);
42  in32[7] = load_le<uint32_t>(in, 1);
43  in32[8] = load_le<uint32_t>(in, 2);
44  in32[9] = load_le<uint32_t>(in, 3);
45 
46  in32[11] = load_le<uint32_t>(key, 4);
47  in32[12] = load_le<uint32_t>(key, 5);
48  in32[13] = load_le<uint32_t>(key, 6);
49  in32[14] = load_le<uint32_t>(key, 7);
50 
51  uint32_t out32[8] = { 0 };
52  Salsa20::hsalsa20(out32, in32);
53 
54  copy_out_le(out, 32, out32);
55  return 0;
56  }
void copy_out_le(uint8_t out[], size_t out_bytes, const T in[])
Definition: loadstor.h:679
uint32_t load_le< uint32_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:198
size_t Botan::Sodium::crypto_core_hsalsa20_constbytes ( )
inline

Definition at line 1030 of file sodium.h.

References crypto_core_hsalsa20_CONSTBYTES.

size_t Botan::Sodium::crypto_core_hsalsa20_inputbytes ( )
inline

Definition at line 1020 of file sodium.h.

References crypto_core_hsalsa20_INPUTBYTES.

size_t Botan::Sodium::crypto_core_hsalsa20_keybytes ( )
inline

Definition at line 1025 of file sodium.h.

References crypto_core_hsalsa20_KEYBYTES.

size_t Botan::Sodium::crypto_core_hsalsa20_outputbytes ( )
inline

Definition at line 1015 of file sodium.h.

References crypto_core_hsalsa20_OUTPUTBYTES.

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

Definition at line 1046 of file sodium.h.

References crypto_hash_sha512().

1047  {
1048  return crypto_hash_sha512(out, in, in_len);
1049  }
int crypto_hash_sha512(uint8_t out[64], const uint8_t in[], size_t in_len)
Definition: sodium_auth.cpp:13
size_t Botan::Sodium::crypto_hash_bytes ( )
inline

Definition at line 1041 of file sodium.h.

References crypto_hash_BYTES.

1042  {
1043  return crypto_hash_BYTES;
1044  }
const char* Botan::Sodium::crypto_hash_primitive ( )
inline

Definition at line 1051 of file sodium.h.

1051 { return "sha512"; }
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.

References Botan::HashFunction::create_or_throw().

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

Definition at line 939 of file sodium.h.

References crypto_hash_sha256_BYTES.

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

Definition at line 13 of file sodium_auth.cpp.

References Botan::HashFunction::create_or_throw().

Referenced by crypto_box_curve25519xsalsa20poly1305_seed_keypair(), and crypto_hash().

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

Definition at line 855 of file sodium.h.

References crypto_hash_sha512_BYTES.

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

Definition at line 1090 of file sodium.h.

References crypto_onetimeauth_poly1305().

1092  {
1093  return crypto_onetimeauth_poly1305(out, in, in_len, key);
1094  }
int crypto_onetimeauth_poly1305(uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
Definition: sodium_auth.cpp:39
size_t Botan::Sodium::crypto_onetimeauth_bytes ( )
inline

Definition at line 1084 of file sodium.h.

References crypto_onetimeauth_BYTES.

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

Definition at line 1102 of file sodium.h.

References crypto_onetimeauth_poly1305_keygen().

1103  {
1105  }
void crypto_onetimeauth_poly1305_keygen(uint8_t k[32])
Definition: sodium.h:1077
int Botan::Sodium::crypto_onetimeauth_poly1305 ( uint8_t  out[],
const uint8_t  in[],
size_t  in_len,
const uint8_t  key[] 
)

Definition at line 39 of file sodium_auth.cpp.

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

Referenced by crypto_onetimeauth(), and crypto_onetimeauth_poly1305_verify().

43  {
44  auto mac = MessageAuthenticationCode::create_or_throw("Poly1305");
45  mac->set_key(key, crypto_onetimeauth_poly1305_KEYBYTES);
46  mac->update(in, in_len);
47  mac->final(out);
48  return 0;
49  }
size_t Botan::Sodium::crypto_onetimeauth_poly1305_bytes ( )
inline
size_t Botan::Sodium::crypto_onetimeauth_poly1305_keybytes ( )
inline
void Botan::Sodium::crypto_onetimeauth_poly1305_keygen ( uint8_t  k[32])
inline

Definition at line 1077 of file sodium.h.

References randombytes_buf().

Referenced by crypto_onetimeauth_keygen().

1078  {
1079  return randombytes_buf(k, 32);
1080  }
void randombytes_buf(void *buf, size_t size)
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 51 of file sodium_auth.cpp.

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

Referenced by crypto_onetimeauth_verify().

55  {
56  secure_vector<uint8_t> computed(crypto_onetimeauth_poly1305_BYTES);
57  crypto_onetimeauth_poly1305(computed.data(), in, in_len, key);
58  return crypto_verify_16(computed.data(), mac) ? 0 : -1;
59  }
int crypto_onetimeauth_poly1305(uint8_t out[], const uint8_t in[], size_t in_len, const uint8_t key[])
Definition: sodium_auth.cpp:39
int crypto_verify_16(const uint8_t x[16], const uint8_t y[16])
const char* Botan::Sodium::crypto_onetimeauth_primitive ( )
inline

Definition at line 1088 of file sodium.h.

1088 { return "poly1305"; }
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 1096 of file sodium.h.

References crypto_onetimeauth_poly1305_verify().

1098  {
1099  return crypto_onetimeauth_poly1305_verify(h, in, in_len, key);
1100  }
int crypto_onetimeauth_poly1305_verify(const uint8_t h[], const uint8_t in[], size_t in_len, const uint8_t key[])
Definition: sodium_auth.cpp:51
int Botan::Sodium::crypto_scalarmult ( uint8_t  out[],
const uint8_t  scalar[],
const uint8_t  base[] 
)
inline

Definition at line 1138 of file sodium.h.

References crypto_scalarmult_curve25519().

1139  {
1140  return crypto_scalarmult_curve25519(out, scalar, base);
1141  }
int crypto_scalarmult_curve25519(uint8_t out[32], const uint8_t scalar[32], const uint8_t basepoint[32])
int Botan::Sodium::crypto_scalarmult_base ( uint8_t  out[],
const uint8_t  scalar[] 
)
inline

Definition at line 1133 of file sodium.h.

References crypto_scalarmult_curve25519_base().

1134  {
1135  return crypto_scalarmult_curve25519_base(out, scalar);
1136  }
int crypto_scalarmult_curve25519_base(uint8_t out[32], const uint8_t scalar[32])
size_t Botan::Sodium::crypto_scalarmult_bytes ( )
inline

Definition at line 1127 of file sodium.h.

References crypto_scalarmult_curve25519_bytes().

size_t crypto_scalarmult_curve25519_bytes()
Definition: sodium.h:1109
int Botan::Sodium::crypto_scalarmult_curve25519 ( uint8_t  out[32],
const uint8_t  scalar[32],
const uint8_t  basepoint[32] 
)

Definition at line 13 of file sodium_25519.cpp.

References Botan::curve25519_donna().

Referenced by crypto_box_curve25519xsalsa20poly1305_beforenm(), and crypto_scalarmult().

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:440
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.

References Botan::curve25519_basepoint().

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

20  {
21  curve25519_basepoint(out, scalar);
22  return 0;
23  }
void curve25519_basepoint(uint8_t mypublic[32], const uint8_t secret[32])
Definition: curve25519.cpp:16
size_t Botan::Sodium::crypto_scalarmult_curve25519_bytes ( )
inline
size_t Botan::Sodium::crypto_scalarmult_curve25519_scalarbytes ( )
inline
const char* Botan::Sodium::crypto_scalarmult_primitive ( )
inline

Definition at line 1131 of file sodium.h.

1131 { return "curve25519"; }
size_t Botan::Sodium::crypto_scalarmult_scalarbytes ( )
inline

Definition at line 1129 of file sodium.h.

References crypto_scalarmult_curve25519_scalarbytes().

size_t crypto_scalarmult_curve25519_scalarbytes()
Definition: sodium.h:1114
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 356 of file sodium.h.

References crypto_secretbox_xsalsa20poly1305().

359  {
360  return crypto_secretbox_xsalsa20poly1305(ctext, ptext, ptext_len, nonce, key);
361  }
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 Botan::Sodium::crypto_secretbox_boxzerobytes ( )
inline

Definition at line 351 of file sodium.h.

References crypto_secretbox_BOXZEROBYTES.

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 73 of file sodium_secretbox.cpp.

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().

78  {
79  auto salsa = StreamCipher::create_or_throw("Salsa20");
80  salsa->set_key(key, crypto_secretbox_KEYBYTES);
81  salsa->set_iv(nonce, crypto_secretbox_NONCEBYTES);
82 
83  secure_vector<uint8_t> auth_key(32);
84  salsa->write_keystream(auth_key.data(), auth_key.size());
85 
86  salsa->cipher(ptext, ctext, ptext_len);
87 
88  auto poly1305 = MessageAuthenticationCode::create_or_throw("Poly1305");
89  poly1305->set_key(auth_key);
90  poly1305->update(ctext, ptext_len);
91  poly1305->final(mac);
92 
93  return 0;
94  }
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 320 of file sodium.h.

References crypto_secretbox_detached(), and crypto_secretbox_MACBYTES.

323  {
325  ptext, ptext_len, nonce, key);
326  }
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[])
size_t Botan::Sodium::crypto_secretbox_keybytes ( )
inline
void Botan::Sodium::crypto_secretbox_keygen ( uint8_t  k[32])
inline

Definition at line 341 of file sodium.h.

References randombytes_buf().

342  {
343  return randombytes_buf(k, 32);
344  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_secretbox_macbytes ( )
inline
size_t Botan::Sodium::crypto_secretbox_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_secretbox_noncebytes ( )
inline
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 363 of file sodium.h.

References crypto_secretbox_xsalsa20poly1305_open().

366  {
367  return crypto_secretbox_xsalsa20poly1305_open(ptext, ctext, ctext_len, nonce, key);
368  }
int crypto_secretbox_xsalsa20poly1305_open(uint8_t ptext[], const uint8_t ctext[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
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 96 of file sodium_secretbox.cpp.

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

Referenced by crypto_box_open_detached_afternm(), and crypto_secretbox_open_easy().

102  {
103  auto salsa = StreamCipher::create_or_throw("Salsa20");
104  salsa->set_key(key, crypto_secretbox_KEYBYTES);
105  salsa->set_iv(nonce, crypto_secretbox_NONCEBYTES);
106 
107  secure_vector<uint8_t> auth_key(32);
108  salsa->write_keystream(auth_key.data(), auth_key.size());
109 
110  auto poly1305 = MessageAuthenticationCode::create_or_throw("Poly1305");
111  poly1305->set_key(auth_key);
112  poly1305->update(ctext, ctext_len);
113  secure_vector<uint8_t> computed_mac = poly1305->final();
114 
115  if(!constant_time_compare(mac, computed_mac.data(), computed_mac.size()))
116  return -1;
117 
118  salsa->cipher(ctext, ptext, ctext_len);
119 
120  return 0;
121  }
bool constant_time_compare(const uint8_t x[], const uint8_t y[], size_t len)
Definition: mem_ops.h:82
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 328 of file sodium.h.

References crypto_secretbox_MACBYTES, and crypto_secretbox_open_detached().

330  {
331  if(ctext_len < crypto_secretbox_MACBYTES)
332  {
333  return -1;
334  }
335 
337  ctext, ctext_len - crypto_secretbox_MACBYTES,
338  nonce, key);
339  }
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[])
const char* Botan::Sodium::crypto_secretbox_primitive ( )
inline

Definition at line 303 of file sodium.h.

303 { return "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 14 of file sodium_secretbox.cpp.

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().

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

Definition at line 278 of file sodium.h.

References randombytes_buf().

279  {
280  return randombytes_buf(k, 32);
281  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_secretbox_xsalsa20poly1305_macbytes ( )
inline
size_t Botan::Sodium::crypto_secretbox_xsalsa20poly1305_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_secretbox_xsalsa20poly1305_noncebytes ( )
inline
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 41 of file sodium_secretbox.cpp.

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

Referenced by crypto_box_curve25519xsalsa20poly1305_open_afternm(), and crypto_secretbox_open().

46  {
48  {
49  return -1;
50  }
51 
52  auto salsa = StreamCipher::create_or_throw("Salsa20");
53  salsa->set_key(key, crypto_secretbox_KEYBYTES);
54  salsa->set_iv(nonce, crypto_secretbox_NONCEBYTES);
55 
56  secure_vector<uint8_t> auth_key(32);
57  salsa->write_keystream(auth_key.data(), auth_key.size());
58 
59  auto poly1305 = MessageAuthenticationCode::create_or_throw("Poly1305");
60  poly1305->set_key(auth_key);
61  poly1305->update(ctext + 32, ctext_len - 32);
62  secure_vector<uint8_t> computed = poly1305->final();
63 
64  if(!constant_time_compare(computed.data(), ctext + 16, 16))
65  return -1;
66 
67  salsa->cipher(ctext + 32, ptext + 32, ctext_len - 32);
68 
69  clear_mem(ptext, 32);
70  return 0;
71  }
void clear_mem(T *ptr, size_t n)
Definition: mem_ops.h:115
bool constant_time_compare(const uint8_t x[], const uint8_t y[], size_t len)
Definition: mem_ops.h:82
size_t Botan::Sodium::crypto_secretbox_xsalsa20poly1305_zerobytes ( )
inline
size_t Botan::Sodium::crypto_secretbox_zerobytes ( )
inline

Definition at line 346 of file sodium.h.

References crypto_secretbox_ZEROBYTES.

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 1333 of file sodium.h.

References crypto_shorthash_siphash24().

1335  {
1336  return crypto_shorthash_siphash24(out, in, in_len, k);
1337  }
int crypto_shorthash_siphash24(uint8_t out[8], const uint8_t in[], size_t in_len, const uint8_t key[16])
Definition: sodium_auth.cpp:29
size_t Botan::Sodium::crypto_shorthash_bytes ( )
inline

Definition at line 1327 of file sodium.h.

References crypto_shorthash_siphash24_bytes().

size_t crypto_shorthash_siphash24_bytes()
Definition: sodium.h:1318
size_t Botan::Sodium::crypto_shorthash_keybytes ( )
inline

Definition at line 1329 of file sodium.h.

References crypto_shorthash_siphash24_keybytes().

size_t crypto_shorthash_siphash24_keybytes()
Definition: sodium.h:1320
void Botan::Sodium::crypto_shorthash_keygen ( uint8_t  k[16])
inline

Definition at line 1339 of file sodium.h.

References crypto_shorthash_siphash24_KEYBYTES, and randombytes_buf().

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

Definition at line 1331 of file sodium.h.

1331 { return "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 29 of file sodium_auth.cpp.

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

Referenced by crypto_shorthash().

31  {
32  auto mac = MessageAuthenticationCode::create_or_throw("SipHash(2,4)");
33  mac->set_key(key, crypto_shorthash_siphash24_KEYBYTES);
34  mac->update(in, in_len);
35  mac->final(out);
36  return 0;
37  }
size_t Botan::Sodium::crypto_shorthash_siphash24_bytes ( )
inline
size_t Botan::Sodium::crypto_shorthash_siphash24_keybytes ( )
inline
size_t Botan::Sodium::crypto_sign_bytes ( )
inline

Definition at line 1393 of file sodium.h.

References crypto_sign_BYTES.

1394  {
1395  return crypto_sign_BYTES;
1396  }
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 1434 of file sodium.h.

References crypto_sign_ed25519_detached().

1437  {
1438  return crypto_sign_ed25519_detached(sig, sig_len, msg, msg_len, sk);
1439  }
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])
size_t Botan::Sodium::crypto_sign_ed25519_bytes ( )
inline

Definition at line 1346 of file sodium.h.

References crypto_sign_ed25519_BYTES.

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.

References Botan::ed25519_sign().

Referenced by crypto_sign_detached().

29  {
30  ed25519_sign(sig, msg, msg_len, sk, nullptr, 0);
31 
32  if(sig_len)
33  *sig_len = 64;
34  return 0;
35  }
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:36
int Botan::Sodium::crypto_sign_ed25519_keypair ( uint8_t  pk[32],
uint8_t  sk[64] 
)

Definition at line 46 of file sodium_25519.cpp.

References crypto_sign_ed25519_seed_keypair(), and randombytes_buf().

Referenced by crypto_sign_keypair().

47  {
48  secure_vector<uint8_t> seed(32);
49  randombytes_buf(seed.data(), seed.size());
50  return crypto_sign_ed25519_seed_keypair(pk, sk, seed.data());
51  }
void randombytes_buf(void *buf, size_t size)
int crypto_sign_ed25519_seed_keypair(uint8_t pk[], uint8_t sk[], const uint8_t seed[])
size_t Botan::Sodium::crypto_sign_ed25519_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_sign_ed25519_publickeybytes ( )
inline
size_t Botan::Sodium::crypto_sign_ed25519_secretkeybytes ( )
inline
int Botan::Sodium::crypto_sign_ed25519_seed_keypair ( uint8_t  pk[],
uint8_t  sk[],
const uint8_t  seed[] 
)

Definition at line 53 of file sodium_25519.cpp.

References Botan::ed25519_gen_keypair().

Referenced by crypto_sign_ed25519_keypair(), and crypto_sign_seed_keypair().

55  {
56  ed25519_gen_keypair(pk, sk, seed);
57  return 0;
58  }
void ed25519_gen_keypair(uint8_t *pk, uint8_t *sk, const uint8_t seed[32])
Definition: ed25519.cpp:18
size_t Botan::Sodium::crypto_sign_ed25519_seedbytes ( )
inline

Definition at line 1351 of file sodium.h.

References crypto_sign_ed25519_SEEDBYTES.

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 37 of file sodium_25519.cpp.

References Botan::ed25519_verify().

Referenced by crypto_sign_verify_detached().

41  {
42  const bool ok = ed25519_verify(msg, msg_len, sig, pk, nullptr, 0);
43  return ok ? 0 : -1;
44  }
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:71
int Botan::Sodium::crypto_sign_keypair ( uint8_t  pk[32],
uint8_t  sk[32] 
)
inline

Definition at line 1429 of file sodium.h.

References crypto_sign_ed25519_keypair().

1430  {
1431  return crypto_sign_ed25519_keypair(pk, sk);
1432  }
int crypto_sign_ed25519_keypair(uint8_t pk[32], uint8_t sk[64])
size_t Botan::Sodium::crypto_sign_messagebytes_max ( )
inline

Definition at line 1413 of file sodium.h.

References crypto_sign_MESSAGEBYTES_MAX.

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

Definition at line 1418 of file sodium.h.

1419  {
1420  return "ed25519";
1421  }
size_t Botan::Sodium::crypto_sign_publickeybytes ( )
inline

Definition at line 1403 of file sodium.h.

References crypto_sign_PUBLICKEYBYTES.

size_t Botan::Sodium::crypto_sign_secretkeybytes ( )
inline

Definition at line 1408 of file sodium.h.

References crypto_sign_SECRETKEYBYTES.

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

Definition at line 1423 of file sodium.h.

References crypto_sign_ed25519_seed_keypair().

1425  {
1426  return crypto_sign_ed25519_seed_keypair(pk, sk, seed);
1427  }
int crypto_sign_ed25519_seed_keypair(uint8_t pk[], uint8_t sk[], const uint8_t seed[])
size_t Botan::Sodium::crypto_sign_seedbytes ( )
inline

Definition at line 1398 of file sodium.h.

References crypto_sign_SEEDBYTES.

1399  {
1400  return crypto_sign_SEEDBYTES;
1401  }
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 1441 of file sodium.h.

References crypto_sign_ed25519_verify_detached().

1445  {
1446  return crypto_sign_ed25519_verify_detached(sig, in, in_len, pk);
1447  }
int crypto_sign_ed25519_verify_detached(const uint8_t sig[], const uint8_t msg[], size_t msg_len, const uint8_t pk[32])
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 1299 of file sodium.h.

References crypto_stream_xsalsa20().

1301  {
1302  return crypto_stream_xsalsa20(out, out_len, nonce, key);
1303  }
int crypto_stream_xsalsa20(uint8_t out[], size_t ctext_len, const uint8_t nonce[], const uint8_t key[])
int Botan::Sodium::crypto_stream_chacha20 ( uint8_t  out[],
size_t  ctext_len,
const uint8_t  nonce[],
const uint8_t  key[] 
)

Definition at line 12 of file sodium_chacha.cpp.

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

14  {
15  auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
16  chacha->set_key(key, crypto_stream_chacha20_KEYBYTES);
17  chacha->set_iv(nonce, crypto_stream_chacha20_NONCEBYTES);
18  chacha->write_keystream(out, out_len);
19  return 0;
20  }
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 45 of file sodium_chacha.cpp.

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

47  {
48  auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
49  chacha->set_key(key, crypto_stream_chacha20_ietf_KEYBYTES);
50  chacha->set_iv(nonce, crypto_stream_chacha20_ietf_NONCEBYTES);
51  chacha->write_keystream(out, out_len);
52  return 0;
53  }
size_t Botan::Sodium::crypto_stream_chacha20_ietf_keybytes ( )
inline
void Botan::Sodium::crypto_stream_chacha20_ietf_keygen ( uint8_t  k[32])
inline

Definition at line 1210 of file sodium.h.

References randombytes_buf().

1211  {
1212  return randombytes_buf(k, 32);
1213  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_stream_chacha20_ietf_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_stream_chacha20_ietf_noncebytes ( )
inline
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 55 of file sodium_chacha.cpp.

References crypto_stream_chacha20_ietf_xor_ic().

59  {
60  return crypto_stream_chacha20_ietf_xor_ic(out, in, in_len, nonce, 0, key);
61  }
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[])
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 63 of file sodium_chacha.cpp.

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

Referenced by crypto_stream_chacha20_ietf_xor().

67  {
68  auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
69  chacha->set_key(key, crypto_stream_chacha20_ietf_KEYBYTES);
70  chacha->set_iv(nonce, crypto_stream_chacha20_ietf_NONCEBYTES);
71  chacha->seek(static_cast<uint64_t>(ic) * 64);
72  chacha->cipher(in, out, in_len);
73  return 0;
74  }
size_t Botan::Sodium::crypto_stream_chacha20_keybytes ( )
inline

Definition at line 1145 of file sodium.h.

References crypto_stream_chacha20_KEYBYTES.

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

Definition at line 1175 of file sodium.h.

References randombytes_buf().

1176  {
1177  return randombytes_buf(k, 32);
1178  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_stream_chacha20_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_stream_chacha20_noncebytes ( )
inline
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 22 of file sodium_chacha.cpp.

References crypto_stream_chacha20_xor_ic().

25  {
26  return crypto_stream_chacha20_xor_ic(out, in, in_len, nonce, 0, key);
27  }
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[])
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 29 of file sodium_chacha.cpp.

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

Referenced by crypto_stream_chacha20_xor().

33  {
34  if((ic >> 6) != 0) // otherwise multiply overflows
35  return -1;
36 
37  auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
38  chacha->set_key(key, crypto_stream_chacha20_KEYBYTES);
39  chacha->set_iv(nonce, crypto_stream_chacha20_NONCEBYTES);
40  chacha->seek(ic * 64);
41  chacha->cipher(in, out, in_len);
42  return 0;
43  }
size_t Botan::Sodium::crypto_stream_keybytes ( )
inline

Definition at line 1291 of file sodium.h.

References crypto_stream_xsalsa20_keybytes().

1291 { return crypto_stream_xsalsa20_keybytes(); }
size_t crypto_stream_xsalsa20_keybytes()
Definition: sodium.h:978
void Botan::Sodium::crypto_stream_keygen ( uint8_t  key[32])
inline

Definition at line 1311 of file sodium.h.

References randombytes_buf().

1312  {
1313  return randombytes_buf(key, 32);
1314  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_stream_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_stream_noncebytes ( )
inline

Definition at line 1293 of file sodium.h.

References crypto_stream_xsalsa20_noncebytes().

size_t crypto_stream_xsalsa20_noncebytes()
Definition: sodium.h:983
const char* Botan::Sodium::crypto_stream_primitive ( )
inline

Definition at line 1297 of file sodium.h.

1297 { return "xsalsa20"; }
int Botan::Sodium::crypto_stream_salsa20 ( uint8_t  out[],
size_t  ctext_len,
const uint8_t  nonce[],
const uint8_t  key[] 
)
size_t Botan::Sodium::crypto_stream_salsa20_keybytes ( )
inline

Definition at line 1254 of file sodium.h.

References crypto_stream_xsalsa20_KEYBYTES.

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

Definition at line 1284 of file sodium.h.

References randombytes_buf().

1285  {
1286  return randombytes_buf(k, 32);
1287  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_stream_salsa20_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_stream_salsa20_noncebytes ( )
inline

Definition at line 1259 of file sodium.h.

References crypto_stream_salsa20_NONCEBYTES.

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 68 of file sodium_salsa.cpp.

References crypto_stream_salsa20_xor_ic().

71  {
72  return crypto_stream_salsa20_xor_ic(out, in, in_len, nonce, 0, key);
73  }
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 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 75 of file sodium_salsa.cpp.

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

Referenced by crypto_stream_salsa20_xor().

79  {
80  if((ic >> 6) != 0) // otherwise multiply overflows
81  return -1;
82 
83  Salsa20 salsa;
84  salsa.set_key(key, crypto_stream_salsa20_KEYBYTES);
85  salsa.set_iv(nonce, crypto_stream_salsa20_NONCEBYTES);
86  salsa.seek(ic * 64);
87  salsa.cipher(in, out, in_len);
88  return 0;
89  }
int Botan::Sodium::crypto_stream_xchacha20 ( uint8_t  out[],
size_t  ctext_len,
const uint8_t  nonce[],
const uint8_t  key[] 
)

Definition at line 76 of file sodium_chacha.cpp.

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

78  {
79  auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
80  chacha->set_key(key, crypto_stream_xchacha20_KEYBYTES);
81  chacha->set_iv(nonce, crypto_stream_xchacha20_NONCEBYTES);
82  chacha->write_keystream(out, out_len);
83  return 0;
84  }
size_t Botan::Sodium::crypto_stream_xchacha20_keybytes ( )
inline

Definition at line 1217 of file sodium.h.

References crypto_stream_xchacha20_KEYBYTES.

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

Definition at line 1247 of file sodium.h.

References crypto_stream_xchacha20_KEYBYTES, and randombytes_buf().

1248  {
1250  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_stream_xchacha20_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_stream_xchacha20_noncebytes ( )
inline
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 86 of file sodium_chacha.cpp.

References crypto_stream_xchacha20_xor_ic().

89  {
90  return crypto_stream_xchacha20_xor_ic(out, in, in_len, nonce, 0, key);
91  }
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 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 93 of file sodium_chacha.cpp.

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

Referenced by crypto_stream_xchacha20_xor().

97  {
98  if((ic >> 6) != 0) // otherwise multiply overflows
99  return -1;
100 
101  auto chacha = StreamCipher::create_or_throw("ChaCha(20)");
102  chacha->set_key(key, crypto_stream_xchacha20_KEYBYTES);
103  chacha->set_iv(nonce, crypto_stream_xchacha20_NONCEBYTES);
104  chacha->seek(ic * 64);
105  chacha->cipher(in, out, in_len);
106  return 0;
107  }
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 1305 of file sodium.h.

References crypto_stream_xsalsa20_xor().

1307  {
1308  return crypto_stream_xsalsa20_xor(out, in, in_len, nonce, key);
1309  }
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 Botan::Sodium::crypto_stream_xsalsa20 ( uint8_t  out[],
size_t  ctext_len,
const uint8_t  nonce[],
const uint8_t  key[] 
)
size_t Botan::Sodium::crypto_stream_xsalsa20_keybytes ( )
inline

Definition at line 978 of file sodium.h.

References crypto_stream_xsalsa20_KEYBYTES.

Referenced by crypto_stream_keybytes().

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

Definition at line 1008 of file sodium.h.

References randombytes_buf().

1009  {
1010  return randombytes_buf(k, 32);
1011  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::crypto_stream_xsalsa20_messagebytes_max ( )
inline
size_t Botan::Sodium::crypto_stream_xsalsa20_noncebytes ( )
inline
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 101 of file sodium_salsa.cpp.

References crypto_stream_xsalsa20_xor_ic().

Referenced by crypto_stream_xor().

104  {
105  return crypto_stream_xsalsa20_xor_ic(out, in, in_len, nonce, 0, key);
106  }
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 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 108 of file sodium_salsa.cpp.

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

Referenced by crypto_stream_xsalsa20_xor().

112  {
113  if((ic >> 6) != 0) // otherwise multiply overflows
114  return -1;
115 
116  Salsa20 salsa;
117  salsa.set_key(key, crypto_stream_xsalsa20_KEYBYTES);
118  salsa.set_iv(nonce, crypto_stream_xsalsa20_NONCEBYTES);
119  salsa.seek(ic * 64);
120  salsa.cipher(in, out, in_len);
121  return 0;
122  }
int Botan::Sodium::crypto_verify_16 ( const uint8_t  x[16],
const uint8_t  y[16] 
)

Definition at line 46 of file sodium_utils.cpp.

References Botan::same_mem().

Referenced by crypto_onetimeauth_poly1305_verify().

47  {
48  return same_mem(x, y, 16);
49  }
bool same_mem(const T *p1, const T *p2, size_t n)
Definition: mem_ops.h:217
int Botan::Sodium::crypto_verify_32 ( const uint8_t  x[32],
const uint8_t  y[32] 
)

Definition at line 51 of file sodium_utils.cpp.

References Botan::same_mem().

Referenced by crypto_auth_hmacsha256_verify(), and crypto_auth_hmacsha512256_verify().

52  {
53  return same_mem(x, y, 32);
54  }
bool same_mem(const T *p1, const T *p2, size_t n)
Definition: mem_ops.h:217
int Botan::Sodium::crypto_verify_64 ( const uint8_t  x[64],
const uint8_t  y[64] 
)

Definition at line 56 of file sodium_utils.cpp.

References Botan::same_mem().

Referenced by crypto_auth_hmacsha512_verify().

57  {
58  return same_mem(x, y, 64);
59  }
bool same_mem(const T *p1, const T *p2, size_t n)
Definition: mem_ops.h:217
void Botan::Sodium::randombytes ( uint8_t  buf[],
size_t  buf_len 
)
inline

Definition at line 237 of file sodium.h.

References randombytes_buf().

238  {
239  return randombytes_buf(buf, buf_len);
240  }
void randombytes_buf(void *buf, size_t size)
void Botan::Sodium::randombytes_buf ( void *  buf,
size_t  size 
)
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.

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

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

Definition at line 230 of file sodium.h.

230 { return 0; }
const char* Botan::Sodium::randombytes_implementation_name ( )
inline

Definition at line 232 of file sodium.h.

233  {
234  return "botan";
235  }
uint32_t Botan::Sodium::randombytes_random ( )
inline

Definition at line 221 of file sodium.h.

References randombytes_buf().

222  {
223  uint32_t x = 0;
224  randombytes_buf(&x, 4);
225  return x;
226  }
void randombytes_buf(void *buf, size_t size)
size_t Botan::Sodium::randombytes_seedbytes ( )
inline

Definition at line 209 of file sodium.h.

References randombytes_SEEDBYTES.

void Botan::Sodium::randombytes_stir ( )
inline

Definition at line 228 of file sodium.h.

228 {}
uint32_t Botan::Sodium::randombytes_uniform ( uint32_t  upper_bound)

Definition at line 23 of file sodium_utils.cpp.

References randombytes_buf().

24  {
25  if(upper_bound <= 1)
26  return 0;
27 
28  // Not completely uniform
29  uint64_t x;
30  randombytes_buf(&x, sizeof(x));
31  return x % upper_bound;
32  }
void randombytes_buf(void *buf, size_t size)
void Botan::Sodium::sodium_add ( uint8_t  a[],
const uint8_t  b[],
size_t  len 
)

Definition at line 108 of file sodium_utils.cpp.

References Botan::carry().

109  {
110  uint8_t carry = 0;
111  for(size_t i = 0; i != len; ++i)
112  {
113  a[i] += b[i] + carry;
114  carry = (a[i] < b[i]);
115  }
116  }
void carry(int64_t &h0, int64_t &h1)
void * Botan::Sodium::sodium_allocarray ( size_t  count,
size_t  size 
)

Definition at line 141 of file sodium_utils.cpp.

References sodium_malloc().

142  {
143  const size_t bytes = count * size;
144  if(bytes < count || bytes < size)
145  return nullptr;
146  return sodium_malloc(bytes);
147  }
void * sodium_malloc(size_t size)
int Botan::Sodium::sodium_compare ( const uint8_t  x[],
const uint8_t  y[],
size_t  len 
)

Definition at line 72 of file sodium_utils.cpp.

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

73  {
74  const uint8_t LT = static_cast<uint8_t>(-1);
75  const uint8_t EQ = 0;
76  const uint8_t GT = 1;
77 
78  uint8_t result = EQ; // until found otherwise
79 
80  for(size_t i = 0; i != len; ++i)
81  {
82  const auto is_eq = CT::Mask<uint8_t>::is_equal(x[i], y[i]);
83  const auto is_lt = CT::Mask<uint8_t>::is_lt(x[i], y[i]);
84  result = is_eq.select(result, is_lt.select(LT, GT));
85  }
86 
87  return static_cast<int8_t>(result);
88  }
void Botan::Sodium::sodium_free ( void *  ptr)

Definition at line 130 of file sodium_utils.cpp.

References Botan::load_le< uint64_t >(), and Botan::secure_scrub_memory().

131  {
132  if(ptr == nullptr)
133  return;
134 
135  uint8_t* p = static_cast<uint8_t*>(ptr) - 8;
136  const uint64_t len = load_le<uint64_t>(p, 0);
137  secure_scrub_memory(ptr, static_cast<size_t>(len));
138  std::free(p);
139  }
uint64_t load_le< uint64_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:237
void secure_scrub_memory(void *ptr, size_t n)
Definition: os_utils.cpp:66
void Botan::Sodium::sodium_increment ( uint8_t  n[],
size_t  nlen 
)

Definition at line 98 of file sodium_utils.cpp.

References Botan::carry().

99  {
100  uint8_t carry = 1;
101  for(size_t i = 0; i != len; ++i)
102  {
103  b[i] += carry;
104  carry &= (b[i] == 0);
105  }
106  }
void carry(int64_t &h0, int64_t &h1)
int Botan::Sodium::sodium_init ( )
inline

Definition at line 160 of file sodium.h.

160 { return 0; }
int Botan::Sodium::sodium_is_zero ( const uint8_t  nonce[],
size_t  nlen 
)

Definition at line 90 of file sodium_utils.cpp.

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

91  {
92  uint8_t sum = 0;
93  for(size_t i = 0; i != len; ++i)
94  sum |= b[i];
95  return static_cast<int>(CT::Mask<uint8_t>::expand(sum).if_not_set_return(1));
96  }
int Botan::Sodium::sodium_library_minimal ( )
inline

Definition at line 158 of file sodium.h.

158 { return 0; }
int Botan::Sodium::sodium_library_version_major ( )
inline

Definition at line 154 of file sodium.h.

154 { return 0; }
int Botan::Sodium::sodium_library_version_minor ( )
inline

Definition at line 156 of file sodium.h.

156 { return 0; }
void * Botan::Sodium::sodium_malloc ( size_t  size)

Definition at line 118 of file sodium_utils.cpp.

References Botan::store_le().

Referenced by sodium_allocarray().

119  {
120  const uint64_t len = size;
121 
122  if(size + sizeof(len) < size)
123  return nullptr;
124 
125  uint8_t* p = static_cast<uint8_t*>(std::calloc(size + sizeof(len), 1));
126  store_le(len, p);
127  return p + 8;
128  }
void store_le(uint16_t in, uint8_t out[2])
Definition: loadstor.h:454
int Botan::Sodium::sodium_memcmp ( const void *  x,
const void *  y,
size_t  len 
)

Definition at line 66 of file sodium_utils.cpp.

References Botan::constant_time_compare().

67  {
68  const bool same = constant_time_compare(static_cast<const uint8_t*>(x), static_cast<const uint8_t*>(y), len);
69  return same ? 0 : -1;
70  }
bool constant_time_compare(const uint8_t x[], const uint8_t y[], size_t len)
Definition: mem_ops.h:82
void Botan::Sodium::sodium_memzero ( void *  ptr,
size_t  len 
)

Definition at line 61 of file sodium_utils.cpp.

References Botan::secure_scrub_memory().

62  {
63  secure_scrub_memory(ptr, len);
64  }
void secure_scrub_memory(void *ptr, size_t n)
Definition: os_utils.cpp:66
int Botan::Sodium::sodium_mprotect_noaccess ( void *  ptr)

Definition at line 149 of file sodium_utils.cpp.

References Botan::OS::page_prohibit_access().

150  {
152  return 0;
153  }
void page_prohibit_access(void *page)
Definition: os_utils.cpp:562
int Botan::Sodium::sodium_mprotect_readwrite ( void *  ptr)

Definition at line 155 of file sodium_utils.cpp.

References Botan::OS::page_allow_access().

156  {
158  return 0;
159  }
void page_allow_access(void *page)
Definition: os_utils.cpp:547
const char* Botan::Sodium::sodium_version_string ( )
inline

Definition at line 152 of file sodium.h.

152 { return "Botan Sodium Compat"; }