backend.globaleaks.utils.crypto

Module Contents

Functions

_convert_to_bytes(arg) Convert the argument to bytes if of string type
_sha(alg, data) Perform the sha of the passed data
sha256(data) Perform the sha256 of the passed thata
generateRandomKey() Return a random secret of 256bits
generateApiToken() Generate an API token
generateRandomPassword(N) Return a random password
generate2FA()
_hash_scrypt(password, salt)
_kdf_argon2(password, salt)
_hash_argon2(password, salt)
backend.globaleaks.utils.crypto.crypto_backend[source]
backend.globaleaks.utils.crypto._convert_to_bytes(arg)[source]

Convert the argument to bytes if of string type :param arg: a string or a byte object :return: the converted byte object

backend.globaleaks.utils.crypto._sha(alg, data)[source]

Perform the sha of the passed data :param alg: A specific hash algorithm :param data: A data to be hashed :return: A hash value

backend.globaleaks.utils.crypto.sha256(data)[source]

Perform the sha256 of the passed thata :param data: A data to be hashed :return: A hash value

backend.globaleaks.utils.crypto.generateRandomKey()[source]

Return a random secret of 256bits

backend.globaleaks.utils.crypto.generateApiToken()[source]

Generate an API token :return: An API token to be used for authentication

backend.globaleaks.utils.crypto.generateRandomPassword(N)[source]

Return a random password

backend.globaleaks.utils.crypto.generate2FA()[source]
backend.globaleaks.utils.crypto._hash_scrypt(password, salt)[source]
backend.globaleaks.utils.crypto._kdf_argon2(password, salt)[source]
backend.globaleaks.utils.crypto._hash_argon2(password, salt)[source]
class backend.globaleaks.utils.crypto._StreamingEncryptionObject(mode, user_key, filepath)[source]

Bases: object

fullNonce(self, i)[source]
lastFullNonce(self)[source]
getNextNonce(self, last)[source]
encrypt_chunk(self, chunk, last=0)[source]
decrypt_chunk(self)[source]
read(self, a)[source]
close(self)[source]
__enter__(self)[source]
__exit__(self, exc_type, exc_val, exc_tb)[source]
__del__(self)[source]
class backend.globaleaks.utils.crypto._GCE[source]

Bases: object

ALGORITM_CONFIGURATION[source]
KDF_FUNCTIONS[source]
HASH_FUNCTIONS[source]
static generate_receipt()[source]

Return a random receipt of 16 digits

static generate_salt()[source]

Return a salt with 128 bit of entropy

static hash_password(password, salt, algorithm='ARGON2')[source]

Return the hash a password using a specified algorithm If the algorithm provided is none uses the best available algorithm

static check_password(algorithm, password, salt, hash)[source]

Perform passowrd check for match with a provided hash

static generate_key()[source]

Generate a 256 bit key

static derive_key(password, salt)[source]

Perform key derivation from a user password

static generate_keypair()[source]

Generate a curve25519 keypair

static generate_recovery_key(prv_key)[source]
static symmetric_encrypt(key, data)[source]

Perform symmetric encryption using libsodium secretbox (XSalsa20-Poly1305))

static symmetric_decrypt(key, data)[source]

Perform symmetric decryption using libsodium secretbox (XSalsa20-Poly1305)

static asymmetric_encrypt(pub_key, data)[source]

Perform asymmetric encryption using libsodium sealedbox (Curve25519, XSalsa20-Poly1305)

static asymmetric_decrypt(prv_key, data)[source]

Perform asymmetric decryption using libsodium sealedbox (Curve25519, XSalsa20-Poly1305)

static streaming_encryption_open(mode, user_key, filepath)[source]
backend.globaleaks.utils.crypto.GCE[source]