Qore Programming Language Reference Manual 2.0.0
|
Functions | |
string | Qore::DSS1_hmac (data data, data key) |
Returns the DSS1 (SHA-1 and DSA) based HMAC of the supplied argument as a hex string. | |
string | Qore::DSS_hmac (data data, data key) |
Returns the DSS (SHA-0 and DSA) based HMAC of the supplied argument as a hex string. | |
string | Qore::MD2_hmac (data data, data key) |
Returns the MD2 based HMAC of the supplied argument as a hex string. | |
string | Qore::MD4_hmac (data data, data key) |
Returns the MD4 based HMAC of the supplied argument as a hex string. | |
string | Qore::MD5_hmac (data data, data key) |
Returns the MD5 based HMAC of the supplied argument as a hex string. | |
string | Qore::MDC2_hmac (data data, data key) |
Returns the MDC2 based HMAC of the supplied argument as a hex string. | |
string | Qore::RIPEMD160_hmac (data data, data key) |
Returns the RIPEMD based HMAC of the supplied argument as a hex string. | |
string | Qore::SHA1_hmac (data data, data key) |
Returns the SHA1 based HMAC of the supplied argument as a hex string. | |
string | Qore::SHA224_hmac (data data, data key) |
Returns the SHA224 based HMAC of the supplied argument as a hex string. | |
string | Qore::SHA256_hmac (data data, data key) |
Returns the SHA256 based HMAC of the supplied argument as a hex string. | |
string | Qore::SHA384_hmac (data data, data key) |
Returns the SHA384 based HMAC of the supplied argument as a hex string. | |
string | Qore::SHA512_hmac (data data, data key) |
Returns the SHA512 based HMAC of the supplied argument as a hex string. | |
string | Qore::SHA_hmac (data data, data key) |
Returns the SHA based HMAC of the supplied argument as a hex string. | |
binary | Qore::decrypt_to_binary (string alg, data data, data key, data iv=Qore::DefaultIV, __7_ data mac, __7_ data aad) |
Returns a binary value of decrypted data corresponding to the input arguments inluding the given algorithm. | |
string | Qore::decrypt_to_string (string alg, data data, data key, data iv=Qore::DefaultIV, __7_ data mac, __7_ data aad, __7_ string encoding) |
Returns a string of decrypted data corresponding to the input arguments inluding the given algorithm. | |
binary | Qore::digest (string digest, data data) |
Returns the digest of the supplied arguments as a binary value. | |
binary | Qore::encrypt (string alg, data data, data key, data iv=Qore::DefaultIV, __7_ reference< binary > mac, __7_ int mac_size, __7_ data aad) |
Returns a binary value of encrypted data corresponding to the input arguments inluding the given algorithm. | |
__7_ hash< auto > | Qore::get_cipher_info (string cipher) |
Returns information about the given cipher or NOTHING if the cipher is unknown. | |
hash< auto > | Qore::get_crypto_info () |
Returns a hash of information about each cryptographic algorithmn supported by the current build of Qore. | |
Transform | Qore::get_decryptor (string alg, data key, data iv=Qore::DefaultIV, __7_ data mac, __7_ data aad) |
Returns a Transform object for decrypting data using the given algorithm for use with TransformInputStream and TransformOutputStream. | |
list< string > | Qore::get_digests () |
Returns a list of supported digest algorithms for hmac() | |
Transform | Qore::get_encryptor (string alg, data key, data iv=Qore::DefaultIV, __7_ reference< binary > mac, __7_ int mac_size, __7_ data aad) |
Returns a Transform object for encrypting data using the given algorithm for use with TransformInputStream and TransformOutputStream. | |
binary | Qore::get_random_bytes (int size) |
returns a binary value of random bytes using openssl | |
bool | Qore::has_digest (string digest) |
Returns True if the given digest is supported, False if not. | |
binary | Qore::hmac (string digest, data data, data key) |
Returns the digest-based HMAC of the supplied arguments as a binary value. | |
Qore's cryptography support is provided by the OpenSSL library.
In cryptography, a keyed-hash message authentication code (HMAC) is a specific construction for calculating a message authentication code (MAC) involving a cryptographic hash function in combination with a secret cryptographic key. As with any MAC, it may be used to simultaneously verify both the data integrity and the authentication of a message. Any cryptographic hash function, such as MD5 or SHA-1, may be used in the calculation of an HMAC; the resulting MAC algorithm is termed HMAC-MD5 or HMAC-SHA1 accordingly. The cryptographic strength of the HMAC depends upon the cryptographic strength of the underlying hash function, the size of its hash output, and on the size and quality of the key.
For more info: Wikipedia's Hash-based message authentication code article.
See also:
binary Qore::decrypt_to_binary | ( | string | alg, |
data | data, | ||
data | key, | ||
data | iv = Qore::DefaultIV , |
||
__7_ data | mac, | ||
__7_ data | aad | ||
) |
Returns a binary value of decrypted data corresponding to the input arguments inluding the given algorithm.
alg | the transformation algorithm; see Cryptographic Stream Transformations for possible values |
data | the data to decrypt |
key | the encryption key |
iv | the initialization vector or cryptographic nonce |
mac | a message authentication code to be used to decrypt the message if required by the cryptographic algorithm, if not required, this argument is ignored |
aad | Additional Authenticated Data; if the cryptographic algorithm does not support AAD, then this argument is ignored |
DECRYPT-ERROR | unknown decryption algorithm; error with the decryption algorithm (ex: invalid key) |
string Qore::decrypt_to_string | ( | string | alg, |
data | data, | ||
data | key, | ||
data | iv = Qore::DefaultIV , |
||
__7_ data | mac, | ||
__7_ data | aad, | ||
__7_ string | encoding | ||
) |
Returns a string of decrypted data corresponding to the input arguments inluding the given algorithm.
alg | the transformation algorithm; see Cryptographic Stream Transformations for possible values |
data | the data to decrypt |
key | the encryption key |
iv | the initialization vector or cryptographic nonce |
mac | a message authentication code to be used to decrypt the message if required by the cryptographic algorithm, if not required, this argument is ignored |
aad | Additional Authenticated Data; if the cryptographic algorithm does not support AAD, then this argument is ignored |
encoding | the character encoding tag for the string return value; if not present, the default character encoding is assumed |
DECRYPT-ERROR | unknown decryption algorithm; error with the decryption algorithm (ex: invalid key) |
Returns the digest of the supplied arguments as a binary value.
digest | the digest to use; for supported digests, see DigestMap |
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
DIGEST-ERROR | unknown digest |
DIGEST-CALCULATION-ERROR | error calculating digest (should not normally happen) |
Returns the DSS1 (SHA-1 and DSA) based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"37a3cc73159aa129b0eb22bbdf4b9309d389f629"
)DSS1-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the DSS (SHA-0 and DSA) based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"37a3cc73159aa129b0eb22bbdf4b9309d389f629"
)DSS-HMAC-ERROR | error calculating digest (should not normally happen) |
binary Qore::encrypt | ( | string | alg, |
data | data, | ||
data | key, | ||
data | iv = Qore::DefaultIV , |
||
__7_ reference< binary > | mac, | ||
__7_ int | mac_size, | ||
__7_ data | aad | ||
) |
Returns a binary value of encrypted data corresponding to the input arguments inluding the given algorithm.
alg | the transformation algorithm; see Cryptographic Stream Transformations for possible values |
data | the data to encrypt |
key | the encryption key |
iv | the initialization vector or cryptographic nonce |
mac | a reference to a binary lvalue that will store the Message Authentication Code (MAC) when the transformation is closed, if the algorithm produces one; it is not an error to provide a reference here for cryptographic algorithms that do not generate a MAC, however in such cases, nothing will be written to the reference; in case this argument is passed, the mac_size argument must also be passed or a MAC-ERROR exception will be thrown |
mac_size | number of bytes of the MAC to return; this value must be non-negative and less than 4096 or a MAC-ERROR exception will be thrown |
aad | Additional Authenticated Data; if the cryptographic algorithm does not support AAD, then this argument is ignored |
MAC-ERROR | this exception is thrown if the mac_size argument is passed but no mac argument or vice-versa or if the mac_size argument is negative or greater than 4096 bytes |
ENCRYPT-ERROR | unknown encryption algorithm; error with the encryption algorithm (ex: invalid key size) |
Returns information about the given cipher or NOTHING if the cipher is unknown.
cipher | the cipher to look up |
ENCODING-CONVERSION-ERROR | this error is thrown if the string cannot be converted to the default character encoding |
Returns a hash of information about each cryptographic algorithmn supported by the current build of Qore.
key_len:
the minimum required length of the cryptographic key; if 0 it means that the cipher takes a variable key lengthiv_len:
the minimum required lengh of the initialization vector or nonce; if 0 it means that the initialization vector can be of any length (note that initialization vector or nonce is always optional); -1 means that the algorithm does not support (ignores) initialization vectorstype:
either "GCM"
for Galois Counter Mode (meaning that the cipher accepts AAD and produces / requires a Message Authentication Code (MAC) for encryption / decryption, respectively) or "CBC"
for Cipher Block Chaining (meaning that the cipher does not support AAD or a MAC)Transform Qore::get_decryptor | ( | string | alg, |
data | key, | ||
data | iv = Qore::DefaultIV , |
||
__7_ data | mac, | ||
__7_ data | aad | ||
) |
Returns a Transform object for decrypting data using the given algorithm for use with TransformInputStream and TransformOutputStream.
alg | the transformation algorithm; see Cryptographic Stream Transformations for possible values |
key | the encryption key |
iv | the initialization vector |
mac | a message authentication code to be used to decrypt the message if required by the cryptographic algorithm, if not required, this argument is ignored |
aad | Additional Authenticated Data; if the cryptographic algorithm does not support AAD, then this argument is ignored |
DECRYPT-ERROR | unknown encryption algorithm; error decrypting the data |
Returns a list of supported digest algorithms for hmac()
Transform Qore::get_encryptor | ( | string | alg, |
data | key, | ||
data | iv = Qore::DefaultIV , |
||
__7_ reference< binary > | mac, | ||
__7_ int | mac_size, | ||
__7_ data | aad | ||
) |
Returns a Transform object for encrypting data using the given algorithm for use with TransformInputStream and TransformOutputStream.
alg | the transformation algorithm; see Cryptographic Stream Transformations for possible values |
key | the encryption key |
iv | the initialization vector |
mac | a reference to a binary lvalue that will store the Message Authentication Code (MAC) when the transformation is closed, if the algorithm produces one; it is not an error to provide a reference here for cryptographic algorithms that do not generate a MAC, however in such cases, nothing will be written to the reference; in case this argument is passed, the mac_size argument must also be passed or a MAC-ERROR exception will be thrown |
mac_size | number of bytes of the MAC to return; this value must be non-negative and less than 4096 or a MAC-ERROR exception will be thrown |
aad | Additional Authenticated Data; if the cryptographic algorithm does not support AAD, then this argument is ignored |
MAC-ERROR | this exception is thrown if the mac_size argument is passed but no mac argument or vice-versa or if the mac_size argument is negative or greater than 4096 bytes |
ENCRYPT-ERROR | unknown encryption algorithm; error with the encryption algorithm (ex: invalid key size) |
returns a binary value of random bytes using openssl
size | the number of bytes in the output; if this value is not positive, an empty binary value is returned |
GET-RANDOM-BYTES-ERROR | thrown if there is an error generating or acquiring random data (ex: not enough entropy; random function not supported by the current random method) |
Returns True if the given digest is supported, False if not.
digest | the digest to check |
ENCODING-CONVERSION-ERROR | this error is thrown if the string cannot be converted to the default character encoding |
Returns the digest-based HMAC of the supplied arguments as a binary value.
digest | the digest to use; for supported digests, see DigestMap |
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
DIGEST-ERROR | unknown digest |
HMAC-CALCULATION-ERROR | error calculating digest (should not normally happen) |
Returns the MD2 based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"27f5f17500b408e97643403ea8ef1413"
)MD2-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the MD4 based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"053d084f321a3886e60166ebd9609ce1"
)MD4-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the MD5 based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"87505c6164aaf6ca6315233902a01ef4"
)MD5-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the MDC2 based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"e0ef6a6803e58807c5db395e180a999c"
)MDC2-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the RIPEMD based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"4bca70bca1601aba57624eeb2606535cb12f2079"
)RIPEMD160-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the SHA1 based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"37a3cc73159aa129b0eb22bbdf4b9309d389f629"
)SHA1-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the SHA224 based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"fad5667fa5aa412044555b7e077fced62372fe9c6ce20815609da12c"
)SHA224-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the SHA256 based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"1c90c21e227712b62019ff831f34cba22c2e70f1a902651ef69a70705ee0f754"
)SHA256-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the SHA384 based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"e2c253c6dcb050990b4da3cee95cd7b227f43388fa8116f476f59395af295d0d3bb7156ab2fcd0663b0500249a7a0865"
)SHA384-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the SHA512 based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"8dcefd7ea3f90ff1c822b5e9547fc36edf78c3e4ce13d47510a212a406bdda1a4094e7ea5ade90e1c736e204d331a814520eba49f3d074e2c261208de07264f6"
)SHA512-HMAC-ERROR | error calculating digest (should not normally happen) |
Returns the SHA based HMAC of the supplied argument as a hex string.
data | the data to process and produce a digest for; the trailing null character is not included in the digest when processing string arguments |
key | a secret passphrase/key |
"0ad47c8d36dc4606d52f7e4cbd144ef2fda492a0"
)SHA-HMAC-ERROR | error calculating digest (should not normally happen) |