crypto_skcipherClass
Lua interface to symmetric-key ciphers (SKCIPHER).
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
- 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, always pastKMALLOC_MAX_SIZE - 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, always pastKMALLOC_MAX_SIZE - crypto_skcipher:ivsize ()
-
Returns the required IV size in bytes.
Returns
-
integer
- crypto_skcipher:setkey (key)
-
Sets the cipher key.
Parameters
- key string
Raises
on invalid key length or algorithm error