Module digest
digest module perform digest operations base on OpenSSL EVP API.
Usage:
digest = require('openssl').digest
Functions
list ([alias]) | list all support digest algs |
get (alg) | get evp_digest object |
new (alg) | get evp_digest_ctx object |
digest (alg, msg[, raw]) | quick method to generate digest result |
signInit (alg[, object=nil]) | create digest object for sign |
verifyInit (alg[, object=nil]) | create digest object for verify |
Class evp_digest
evp_digest:digest (msg[, eng]) | compute msg digest result |
evp_digest:info () | get infomation of evp_digest object |
evp_digest:new ([eng]) | create new evp_digest_ctx |
evp_digest:signInit ([object=nil]) | create digest object for sign |
evp_digest:verifyInit ([object=nil]) | create digest object for verify |
Class evp_digest_ctx
evp_digest_ctx:info () | get infomation of evp_digest_ctx object |
evp_digest_ctx:update (msg) | feed data to do digest |
evp_digest_ctx:final ([last[, raw]]) | get result of digest |
evp_digest_ctx:reset () | reset evp_diget_ctx to reuse |
evp_digest_ctx:data () | retrieve md data |
evp_digest_ctx:data (md_data) | restore md data |
evp_digest_ctx:verifyUpdate (data) | feed data for sign to get signature |
evp_digest_ctx:verifyUpdate (data) | feed data for verify with signature |
evp_digest_ctx:signFinal (private) | get result of sign |
evp_digest_ctx:verifyFinal (signature) | get verify result |
evp_digest_ctx:sign (ctx, data) | get result of oneshot sign |
evp_digest_ctx:verify (ctx, signature, to, signature) | get result of oneshot verify |
Functions
- list ([alias])
-
list all support digest algs
Parameters:
- alias boolean include alias names for digest alg, default true (optional)
Returns:
-
all
methods
- get (alg)
-
get evp_digest object
Parameters:
- alg string, integer or asn1_object name, nid or object identity
Returns:
-
evp_digest
digest object mapping EVP_MD in openssl
See also:
- new (alg)
-
get evp_digest_ctx object
Parameters:
- alg string, integer or asn1_object name, nid or object identity
Returns:
-
evp_digest_ctx
digest object mapping EVP_MD_CTX in openssl
See also:
- digest (alg, msg[, raw])
-
quick method to generate digest result
Parameters:
- alg string, integer or asn1_object name, nid or object identity
- msg string to compute digest
- raw boolean binary result return if set true, or hex encoded string default (optional)
Returns:
-
string
digest result value
- signInit (alg[, object=nil])
-
create digest object for sign
Parameters:
- alg string, integer or asn1_object name, nid or object identity
- object engine (default nil)
Returns:
-
evp_digest_ctx
- verifyInit (alg[, object=nil])
-
create digest object for verify
Parameters:
- alg string, integer or asn1_object name, nid or object identity
- object engine (default nil)
Returns:
-
evp_digest_ctx
Class evp_digest
openssl.evp_digest object
- evp_digest:digest (msg[, eng])
-
compute msg digest result
Parameters:
- msg string data to digest
- eng engine, (optional)
Returns:
-
string
result a binary hash value for msg
- evp_digest:info ()
-
get infomation of evp_digest object
Returns:
-
table
info keys include nid,name size,block_size,pkey_type,flags
- evp_digest:new ([eng])
-
create new evp_digest_ctx
Parameters:
- eng engine, (optional)
Returns:
-
evp_digest_ctx
ctx
See also:
- evp_digest:signInit ([object=nil])
-
create digest object for sign
Parameters:
- object engine (default nil)
Returns:
-
evp_digest_ctx
- evp_digest:verifyInit ([object=nil])
-
create digest object for verify
Parameters:
- object engine (default nil)
Returns:
-
evp_digest_ctx
Class evp_digest_ctx
openssl.evp_digest_ctx object
- evp_digest_ctx:info ()
-
get infomation of evp_digest_ctx object
Returns:
-
table
info keys include size,block_size,digest
- evp_digest_ctx:update (msg)
-
feed data to do digest
Parameters:
- msg string data
Returns:
-
boolean
result true for success
- evp_digest_ctx:final ([last[, raw]])
-
get result of digest
Parameters:
- last string last part of data (optional)
- raw boolean binary or hexadecimal result, default false for hexadecimal result (optional)
Returns:
-
string
val hash result
- evp_digest_ctx:reset ()
- reset evp_diget_ctx to reuse
- evp_digest_ctx:data ()
-
retrieve md data
Returns:
-
string
md_data
- evp_digest_ctx:data (md_data)
-
restore md data
Parameters:
- md_data string
- evp_digest_ctx:verifyUpdate (data)
-
feed data for sign to get signature
Parameters:
- data string to be signed
Returns:
-
boolean
result
- evp_digest_ctx:verifyUpdate (data)
-
feed data for verify with signature
Parameters:
- data string to be verified
Returns:
-
boolean
result
- evp_digest_ctx:signFinal (private)
-
get result of sign
Parameters:
- private evp_pkey key to do sign
Returns:
-
string
singed result
- evp_digest_ctx:verifyFinal (signature)
-
get verify result
Parameters:
- signature string
Returns:
-
boolean
result, true for verify pass
- evp_digest_ctx:sign (ctx, data)
-
get result of oneshot sign
Parameters:
- ctx evp_digest_ctx
- data string to sign
Returns:
-
string
singed result
Or
-
nil
followd by error message
- evp_digest_ctx:verify (ctx, signature, to, signature)
-
get result of oneshot verify
Parameters:
Returns:
-
boolean
result, true for verify pass
Or
-
string
singed result
Or
-
nil
followd by error message