Lunatik

crypto_skcipherClass

Lua interface to symmetric-key ciphers (SKCIPHER).

Every method raises “not allowed with IRQs disabled” where the CPU runs with them off, in every callback of a hardirq runtime among them. Not built where the kernel builds no user of its skcipher API, CONFIG_CRYPTO_SKCIPHER2.

Methods

crypto_skcipher:algname () Returns the driver-independent name of the algorithm the transform was allocated with.
crypto_skcipher:blocksize () Returns the cipher block size in bytes.
crypto_skcipher:close () Releases the transform.
crypto_skcipher:decrypt (iv, data) Decrypts data.
crypto_skcipher:encrypt (iv, data) Encrypts data.
crypto_skcipher:ivsize () Returns the required IV size in bytes.
crypto_skcipher:setkey (key) Sets the cipher key.

Methods in detail

crypto_skcipher:algname ()
Returns the driver-independent name of the algorithm the transform was allocated with.

Returns

    string
crypto_skcipher:blocksize ()
Returns the cipher block size in bytes.

Returns

    integer
crypto_skcipher:close ()
Releases the transform. A to-be-closed variable holding the object releases it the same way. Calling it again does nothing, and every other method raises “closed object” afterwards.

Returns

    nil
crypto_skcipher:decrypt (iv, data)
Decrypts data. IV length must match ivsize().

Parameters

Returns

    string plaintext (same length as input)

Raises

on decryption failure or incorrect IV length, “not enough memory” when one kmalloc block cannot be allocated for the data without sleeping, in any runtime: always past KMALLOC_MAX_SIZE, and for data of several pages when memory is short
crypto_skcipher:encrypt (iv, data)
Encrypts data. IV length must match ivsize().

Parameters

Returns

    string ciphertext (same length as input)

Raises

on encryption failure or incorrect IV length, “not enough memory” when one kmalloc block cannot be allocated for the data without sleeping, in any runtime: always past KMALLOC_MAX_SIZE, and for data of several pages when memory is short
crypto_skcipher:ivsize ()
Returns the required IV size in bytes.

Returns

    integer
crypto_skcipher:setkey (key)
Sets the cipher key.

Parameters

Raises

on invalid key length or algorithm error