Module openssl

Openssl binding for Lua, provide openssl full function in lua.

Usage:

    openssl = require('openssl')
    

Functions

version ([format]) get lua-openssl version
hex (str[, encode=true]) hex encode or decode string
base64 (input[, encode=true[, NO_NL=true]]) base64 encode or decode
list (type) get method names
error ([error]) get last or given error infomation
clear_error () Empties the current thread’s error queue, helps reduce memory usage.
errors () Fetch all error strings from current thread’s error queue, and empty the error queue.
rand_add (seed, entropy) mixes the num bytes at buf into the PRNG state.
rand_load ([file=nil]) load rand seed from file
rand_write ([file=nil]) save rand seed to file
rand_status (result) get random generator state
random (length) get random bytes
FIPS_mode (fips) set FIPS mode
FIPS_mode () get FIPS mode
engine (engine_id) get openssl engine object


Functions

version ([format])
get lua-openssl version

Parameters:

  • format boolean result will be number when set true, or string (optional)

Returns:

    lua-openssl version, lua version, openssl version
hex (str[, encode=true])
hex encode or decode string

Parameters:

  • str string
  • encode boolean true to encoed, false to decode (default true)

Returns:

    string
base64 (input[, encode=true[, NO_NL=true]])
base64 encode or decode

Parameters:

  • input string or bio
  • encode boolean true to encoed, false to decode (default true)
  • NO_NL boolean default true without newline, false with newline (default true)

Returns:

    string
list (type)
get method names

Parameters:

  • type string support ‘cipher’,‘digests’,‘pkeys’,‘comps’

Returns:

    table as array
error ([error])
get last or given error infomation Most lua-openssl function or methods return nil or false when error or failed, followed by string type error reason and number type error code, code can pass to openssl.error() to get more error information.

Parameters:

  • error number , default use ERR_get_error() return value (optional)

Returns:

  1. string reason
  2. string library name
  3. number errcode
  4. string function name if available
  5. boolean indicates whether a given error code is a fatal error
clear_error ()
Empties the current thread’s error queue, helps reduce memory usage.
errors ()
Fetch all error strings from current thread’s error queue, and empty the error queue.

Returns:

    string
rand_add (seed, entropy)
mixes the num bytes at buf into the PRNG state.

Parameters:

  • seed string data to seed random generator
  • entropy number the lower bound of an estimate of how much randomness is contained in buf, measured in bytes.
rand_load ([file=nil])
load rand seed from file

Parameters:

  • file string path to laod seed, default openssl management (default nil)

Returns:

    boolean result
rand_write ([file=nil])
save rand seed to file

Parameters:

  • file string path to save seed, default openssl management (default nil)

Returns:

    bool result
rand_status (result)
get random generator state

Parameters:

  • result boolean true for sucess
random (length)
get random bytes

Parameters:

  • length number

Returns:

    string
FIPS_mode (fips)
set FIPS mode

Parameters:

  • fips boolean true enable FIPS mode, false disable it.

Returns:

    boolean success
FIPS_mode ()
get FIPS mode

Returns:

    boolean return true when FIPS mode enabled, false when FIPS mode disabled.
engine (engine_id)
get openssl engine object

Parameters:

Returns:

    engine
generated by LDoc 1.5.0 Last updated 2024-05-16 23:31:39