Skip to content

crandas.crypto

crypto.cipher

Cipher(name, round_keys)

Cipher object, contains the round keys needed for encryption of a message using encrypt. 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

PARAMETER DESCRIPTION
message

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.

TYPE: bytes column

RETURNS DESCRIPTION
bytes column

Message encrypted with the key belonging to the Cipher

AES_128(key)

AES-128 cipher

PARAMETER DESCRIPTION
key

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

TYPE: bytes column

RETURNS DESCRIPTION
Cipher

Cipher object for AES-128 initialized with the provided key

AES_192(key)

AES-192 cipher

PARAMETER DESCRIPTION
key

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

TYPE: bytes column

RETURNS DESCRIPTION
Cipher

Cipher object for AES-192 initialized with the provided key

AES_256(key)

AES-256 cipher

PARAMETER DESCRIPTION
key

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

TYPE: bytes column

RETURNS DESCRIPTION
Cipher

Cipher object for AES-256 initialized with the provided key

crypto.hash

RIPEMD_160 = Hash('ripemd_160') module-attribute

RIPEMD-160 hash

SHA3_224 = Hash('sha3_224') module-attribute

SHA3-224 hash

SHA3_256 = Hash('sha3_256') module-attribute

SHA3-256 hash

SHA3_384 = Hash('sha3_384') module-attribute

SHA3-384 hash

SHA3_512 = Hash('sha3_512') module-attribute

SHA3-512 hash

SHAKE128 = Hash('shake_128') module-attribute

SHAKE128 hash

SHAKE256 = Hash('shake_256') module-attribute

SHAKE256 hash

TurboSHAKE128 = Hash('turbo_shake_128') module-attribute

TurboSHAKE128 hash

TurboSHAKE256 = Hash('turbo_shake_256') module-attribute

TurboSHAKE256 hash

Hash(name, *, pre_hmac_key=None)

Hash object, denotes a hash function of which a digest of a message can be computed using .digest. 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

PARAMETER DESCRIPTION
message

Message to be hashed as a crandas bytes column. Can be of arbitrary length.

TYPE: bytes column

length

Specify the digest output size in bytes for an extendable output function (XOF). Currently only relevant for SHAKE or TurboSHAKE.

TYPE: int DEFAULT: None

RETURNS DESCRIPTION
bytes column

Digest of the message using the instantiated hash function

HMAC_RIPEMD_160(hmac_key)

HMAC RIPEMD-160 keyed hash

PARAMETER DESCRIPTION
hmac_key

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

TYPE: bytes column

RETURNS DESCRIPTION
Hash

Hash object for HMAC-RIPEMD-160 initialized with the provided key

HMAC_SHA3_224(hmac_key)

HMAC SHA3-224 keyed hash

PARAMETER DESCRIPTION
hmac_key

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

TYPE: bytes column

RETURNS DESCRIPTION
Hash

Hash object for HMAC-SHA3-224 initialized with the provided key

HMAC_SHA3_256(hmac_key)

HMAC SHA3-256 keyed hash

PARAMETER DESCRIPTION
hmac_key

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

TYPE: bytes column

RETURNS DESCRIPTION
Hash

Hash object for HMAC-SHA3-256 initialized with the provided key

HMAC_SHA3_384(hmac_key)

HMAC SHA3-384 keyed hash

PARAMETER DESCRIPTION
hmac_key

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

TYPE: bytes column

RETURNS DESCRIPTION
Hash

Hash object for HMAC-SHA3-384 initialized with the provided key

HMAC_SHA3_512(hmac_key)

HMAC SHA3-512 keyed hash

PARAMETER DESCRIPTION
hmac_key

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

TYPE: bytes column

RETURNS DESCRIPTION
Hash

Hash object for HMAC-SHA3-512 initialized with the provided key