crandas.crypto¶
crypto.cipher¶
- crandas.crypto.cipher.AES_128(key)¶
AES-128 cipher
- Parameters:
key (bytes column) – AES-128 key as a crandas bytes column of 16 bytes. The number of rows in the column has to match the number of rows in the messages that will be encrypted. If the same key is used for all messages, use
key.as_value().- Returns:
Cipher object for AES-128 initialized with the provided key
- Return type:
- crandas.crypto.cipher.AES_192(key)¶
AES-192 cipher
- Parameters:
key (bytes column) – AES-192 key as a crandas bytes column of 24 bytes. The number of rows in the column has to match the number of rows in the messages that will be encrypted. If the same key is used for all messages, use
key.as_value().- Returns:
Cipher object for AES-192 initialized with the provided key
- Return type:
- crandas.crypto.cipher.AES_256(key)¶
AES-256 cipher
- Parameters:
key (bytes column) – AES-256 key as a crandas bytes column of 32 bytes. The number of rows in the column has to match the number of rows in the messages that will be encrypted. If the same key is used for all messages, use
key.as_value().- Returns:
Cipher object for AES-256 initialized with the provided key
- Return type:
- class crandas.crypto.cipher.Cipher(name, round_keys)¶
Bases:
objectCipher object, contains the round keys needed for encryption of a message using the
encryptmethod. Currently only AES-128, AES-192 and AES-256 are supported for 16 byte messages.- encrypt(message)¶
Encrypt the message given the round keys of the Cipher object
- Parameters:
message (bytes column) – Message to be encrypted as a crandas bytes column. Byte length must be equal to the block size of the underlying cipher. For AES this is 16 bytes.
- Returns:
Message encrypted with the key belonging to the
Cipher- Return type:
bytes column
crypto.hash¶
- crandas.crypto.hash.HMAC_RIPEMD_160(hmac_key)¶
HMAC RIPEMD-160 keyed hash
- Parameters:
hmac_key (bytes column) – HMAC key as a crandas bytes column. A key length up to 64 bytes is supported. The number of rows in the column has to match the number of rows in the messages that will be hashed. If the same key is used for all messages, use
hmac_key.as_value().- Returns:
Hash object for HMAC-RIPEMD-160 initialized with the provided key
- Return type:
- crandas.crypto.hash.HMAC_SHA3_224(hmac_key)¶
HMAC SHA3-224 keyed hash
- Parameters:
hmac_key (bytes column) – HMAC key as a crandas bytes column. A key length up to 144 bytes is supported. The number of rows in the column has to match the number of rows in the messages that will be hashed. If the same key is used for all messages, use
hmac_key.as_value().- Returns:
Hash object for HMAC-SHA3-224 initialized with the provided key
- Return type:
- crandas.crypto.hash.HMAC_SHA3_256(hmac_key)¶
HMAC SHA3-256 keyed hash
- Parameters:
hmac_key (bytes column) – HMAC key as a crandas bytes column. A key length up to 136 bytes is supported. The number of rows in the column has to match the number of rows in the messages that will be hashed. If the same key is used for all messages, use
hmac_key.as_value().- Returns:
Hash object for HMAC-SHA3-256 initialized with the provided key
- Return type:
- crandas.crypto.hash.HMAC_SHA3_384(hmac_key)¶
HMAC SHA3-384 keyed hash
- Parameters:
hmac_key (bytes column) – HMAC key as a crandas bytes column. A key length up to 104 bytes is supported. The number of rows in the column has to match the number of rows in the messages that will be hashed. If the same key is used for all messages, use
hmac_key.as_value().- Returns:
Hash object for HMAC-SHA3-384 initialized with the provided key
- Return type:
- crandas.crypto.hash.HMAC_SHA3_512(hmac_key)¶
HMAC SHA3-512 keyed hash
- Parameters:
hmac_key (bytes column) – HMAC key as a crandas bytes column. A key length up to 72 bytes is supported. The number of rows in the column has to match the number of rows in the messages that will be hashed. If the same key is used for all messages, use
hmac_key.as_value().- Returns:
Hash object for HMAC-SHA3-512 initialized with the provided key
- Return type:
- class crandas.crypto.hash.Hash(name, *, pre_hmac_key=None)¶
Bases:
objectHash object, denotes a hash function of which a diget of a message can be computed using the
digestmethod. Currently SHA-3, SHAKE, TurboSHAKE and RIPEMD-160 are supported.- digest(message, length=None)¶
Compute the digest of the message using the hash function of the Hash object
- Parameters:
message (bytes column) – Message to be hashed as a crandas bytes column. Can be of arbitrary length.
length (int, optional) – Specify the digest output size in bytes for an extendable output function (XOF). Currently only relevant for SHAKE or TurboSHAKE.
- Returns:
Digest of the message using the instantiated hash function
- Return type:
bytes column
- crandas.crypto.hash.RIPEMD_160 = <crandas.crypto.hash.Hash object>¶
RIPEMD-160 hash
- crandas.crypto.hash.SHA3_224 = <crandas.crypto.hash.Hash object>¶
SHA3-224 hash
- crandas.crypto.hash.SHA3_256 = <crandas.crypto.hash.Hash object>¶
SHA3-256 hash
- crandas.crypto.hash.SHA3_384 = <crandas.crypto.hash.Hash object>¶
SHA3-384 hash
- crandas.crypto.hash.SHA3_512 = <crandas.crypto.hash.Hash object>¶
SHA3-512 hash
- crandas.crypto.hash.SHAKE128 = <crandas.crypto.hash.Hash object>¶
SHAKE128 hash
- crandas.crypto.hash.SHAKE256 = <crandas.crypto.hash.Hash object>¶
SHAKE256 hash
- crandas.crypto.hash.TurboSHAKE128 = <crandas.crypto.hash.Hash object>¶
TurboSHAKE128 hash
- crandas.crypto.hash.TurboSHAKE256 = <crandas.crypto.hash.Hash object>¶
TurboSHAKE256 hash