Encrypts data with Camellia-CBC (PKCS#7 padding).
@eryx/crypto/camellia Module
JSON
Camellia symmetric encryption.
Camellia is an ISO/IEC 18033-3 and NESSIE-approved block cipher with the same block and key sizes as AES (128/192/256-bit keys, 128-bit block). It is a recognised alternative to AES in TLS and IPsec.
Supports CBC, CTR, and GCM modes - see @eryx/crypto/aes for
mode descriptions. CCM is not defined for Camellia in PSA Crypto.
local camellia = require("@eryx/crypto/camellia")
local key = buffer.fromstring("0123456789abcdef") -- 16-byte / 128-bit
local iv = buffer.fromstring("0000000000000000")
local plain = buffer.fromstring("Hello, Camellia!")
local ct = camellia.cbc_encrypt(key, iv, plain)
local pt = camellia.cbc_decrypt(key, iv, ct)
Summary
Functions
API Reference
Functions
camellia.encryptCBC
Parameters
Key - 16, 24, or 32 bytes (128/192/256-bit).
Initialisation vector - 16 bytes.
Plaintext to encrypt.
Returns
Ciphertext.
camellia.decryptCBC
Decrypts Camellia-CBC ciphertext (strips PKCS#7 padding).
Parameters
Key - 16, 24, or 32 bytes.
Initialisation vector - 16 bytes.
Ciphertext to decrypt.
Returns
Plaintext.
camellia.encryptCTR
Encrypts data with Camellia-CTR (stream cipher; no padding).
Parameters
Key - 16, 24, or 32 bytes.
Counter/nonce block - 16 bytes.
Plaintext to encrypt.
Returns
Ciphertext (same length as input).
camellia.decryptCTR
Decrypts Camellia-CTR ciphertext.
Parameters
Key - 16, 24, or 32 bytes.
Counter/nonce block - 16 bytes.
Ciphertext to decrypt.
Returns
Plaintext (same length as input).
camellia.encryptGCM
Encrypts data with Camellia-GCM (authenticated encryption).
Returns ciphertext and authentication tag separately.
Parameters
Key - 16, 24, or 32 bytes.
Nonce - 12 bytes recommended.
Plaintext to encrypt.
Additional authenticated data (optional).
Returns
Ciphertext.
16-byte authentication tag.
camellia.decryptGCM
Decrypts Camellia-GCM ciphertext and verifies the authentication tag.
Raises an error if the tag does not match.
Parameters
Key - 16, 24, or 32 bytes.
Nonce - must match the value used during encryption.
Ciphertext.
16-byte authentication tag.
Additional authenticated data (must match encryption).
Returns
Plaintext.