nacl.bindings¶
The nacl.bindings module exposes the low-level APIs provided by libsodium.
AEAD constructions¶
-
crypto_aead_chacha20poly1305_decrypt(ciphertext, aad, nonce, key)[source]¶ Decrypt the given
ciphertextusing the “legacy” construction described in draft-agl-tls-chacha20poly1305.Parameters: Returns: message
Return type:
-
crypto_aead_chacha20poly1305_encrypt(message, aad, nonce, key)[source]¶ Encrypt the given
messageusing the “legacy” construction described in draft-agl-tls-chacha20poly1305.Parameters: Returns: authenticated ciphertext
Return type:
-
crypto_aead_chacha20poly1305_ietf_decrypt(ciphertext, aad, nonce, key)[source]¶ Decrypt the given
ciphertextusing the IETF ratified chacha20poly1305 construction described in RFC7539.Parameters: Returns: message
Return type:
-
crypto_aead_chacha20poly1305_ietf_encrypt(message, aad, nonce, key)[source]¶ Encrypt the given
messageusing the IETF ratified chacha20poly1305 construction described in RFC7539.Parameters: Returns: authenticated ciphertext
Return type:
Key exchange¶
-
crypto_kx_keypair()[source]¶ Generate a keypair. This is a duplicate crypto_box_keypair, but is included for api consistency.
Returns: (public_key, secret_key) Return type: (bytes, bytes)
Utilities¶
-
sodium_add(a, b)[source]¶ Given a couple of same-sized byte sequences, interpreted as the little-endian representation of two unsigned integers, compute the modular addition of the represented values, in constant time for a given common length of the byte sequences.
Parameters: Returns: a byte-sequence representing, as a little-endian big integer, the integer value of
(to_int(a) + to_int(b)) mod 2^(8*len(a))Return type:
-
sodium_increment(inp)[source]¶ Increment the value of a byte-sequence interpreted as the little-endian representation of a unsigned big integer.
Parameters: inp (bytes) – input bytes buffer Returns: a byte-sequence representing, as a little-endian unsigned big integer, the value to_int(inp)incremented by one.Return type: bytes