![]() |
PQLR
Postquantum Crypto Library by QAPP
|
Typedefs | |
typedef struct pqlr_dsa_st * | pqlr_dsa |
PQLR DSA instance handle. More... | |
Functions | |
PQLR_API size_t | pqlr_dsa_num_algs (void) |
Obtains the number of available PQLR DSA algorithms. More... | |
PQLR_API size_t | pqlr_dsa_get_algs (const char **algs, size_t count) |
Fills the provided buffer with names of available DSA algorithms. More... | |
PQLR_API pqlr_dsa | pqlr_dsa_new (const pqlr_alg alg) |
Creates new pqlr_dsa instance with selected parameter set. More... | |
PQLR_API void | pqlr_dsa_free (pqlr_dsa dsa) |
Frees pqlr_dsa instance and all corresponding resources. More... | |
PQLR_API pqlr_dsa | pqlr_dsa_duplicate (const pqlr_dsa src) |
Duplicates context copying all related resources. More... | |
PQLR_API size_t | pqlr_dsa_get_public_key_bytes_len (const pqlr_dsa dsa) |
Obtains public key buffer length in bytes for current pqlr_dsa instance. More... | |
PQLR_API size_t | pqlr_dsa_get_secret_key_bytes_len (const pqlr_dsa dsa) |
Obtains secret key buffer length in bytes for current pqlr_dsa instance. More... | |
PQLR_API size_t | pqlr_dsa_get_signature_bytes_len (const pqlr_dsa dsa) |
Obtains signature buffer length in bytes for current pqlr_dsa instance. More... | |
PQLR_API int | pqlr_dsa_keygen (const pqlr_dsa dsa, uint8_t *sk, uint8_t *pk) |
Generates random secret key and public key for given context. More... | |
PQLR_API int | pqlr_dsa_sign (const pqlr_dsa dsa, const uint8_t *sk, const uint8_t *msg, size_t msg_len, uint8_t *result_sig, size_t *sig_len) |
Generates signature for given message according to context and secret key. More... | |
PQLR_API int | pqlr_dsa_verify (const pqlr_dsa dsa, const uint8_t *pk, const uint8_t *sig, size_t sig_len, const uint8_t *msg, size_t msg_len) |
Verifies that given signature is the signature of given message. More... | |
This module provides post-quantum digital signature algorithm implementation.
At first, initialize algorithm's instance with parameters you want with pqlr_dsa_new(). After that, you can generate secret and public keys using pqlr_dsa_keygen, then sign your message with pqlr_dsa_sign, or verify message wasn't changed with pqlr_dsa_verify.
After the signature scheme is no more needed it's resources must be freed by pqlr_dsa_free.
In order to use any PQLR common DSA interface functions, add following include:
Example code is listed below:
typedef struct pqlr_dsa_st* pqlr_dsa |
PQLR DSA instance handle.
Duplicates context copying all related resources.
[in] | src | non-null context to duplicate |
Frees pqlr_dsa instance and all corresponding resources.
[in] | dsa | instance to free |
PQLR_API size_t pqlr_dsa_get_algs | ( | const char ** | algs, |
size_t | count | ||
) |
Fills the provided buffer with names of available DSA algorithms.
[out] | algs | Array of DSA names |
[in] | count | Array size |
Obtains public key buffer length in bytes for current pqlr_dsa instance.
[in] | dsa | initialized pqlr_dsa instance |
Obtains secret key buffer length in bytes for current pqlr_dsa instance.
[in] | dsa | initialized pqlr_dsa instance |
Obtains signature buffer length in bytes for current pqlr_dsa instance.
[in] | dsa | initialized pqlr_dsa instance |
Generates random secret key and public key for given context.
Usage:
[in] | dsa | Instance of pqlr_dsa created with pqlr_dsa_new(). If NULL , the fatal error occurs. |
[out] | sk | Contiguous array to receive secret key, of size pqlr_dsa_get_secret_key_bytes_len . If NULL , the fatal error occurs. |
[out] | pk | Contiguous array to receive public key, of size pqlr_dsa_get_public_key_bytes_len . If NULL , the fatal error occurs. |
Creates new pqlr_dsa instance with selected parameter set.
Usage:
[in] | alg | Initialized PQLR DSA algorithm instance |
NULL
if out of memory PQLR_API size_t pqlr_dsa_num_algs | ( | void | ) |
Obtains the number of available PQLR DSA algorithms.
PQLR_API int pqlr_dsa_sign | ( | const pqlr_dsa | dsa, |
const uint8_t * | sk, | ||
const uint8_t * | msg, | ||
size_t | msg_len, | ||
uint8_t * | result_sig, | ||
size_t * | sig_len | ||
) |
Generates signature for given message according to context and secret key.
Usage:
pqlr_dsa_get_signature_bytes_len
, while the actual length may be smaller and is returned in sig_len
.[in] | dsa | Instance of pqlr_dsa created with pqlr_dsa_new(). If NULL , the fatal error occurs. |
[in] | sk | Secret key, the contiguous array of size pqlr_dsa_get_secret_key_bytes_len . If NULL , the fatal error occurs. |
[in] | msg | Message to generate signature of, the contiguous array. If NULL , the fatal error occurs. |
[in] | msg_len | The length of a message in bytes. If 0 , the fatal error occurs. |
[out] | result_sig | Contiguous array to receive signature, of size sig_len . If NULL , the fatal error occurs. |
[out] | sig_len | The result signature size. |
PQLR_API int pqlr_dsa_verify | ( | const pqlr_dsa | dsa, |
const uint8_t * | pk, | ||
const uint8_t * | sig, | ||
size_t | sig_len, | ||
const uint8_t * | msg, | ||
size_t | msg_len | ||
) |
Verifies that given signature is the signature of given message.
Usage:
[in] | dsa | Context, initialized with pqlr_dsa_new(). If NULL , the fatal error occurs. |
[in] | pk | Public key, the contiguous array of size pqlr_dsa_get_public_key_bytes_len . If NULL , the fatal error occurs. |
[in] | sig | Signature, the contiguous array of size ‘sig_len’. If NULL , the fatal error occurs. |
[in] | sig_len | Signature size. |
[in] | msg | Message to verify signature of, the contiguous array. If NULL , the fatal error occurs. |
[in] | msg_len | The length of a message in bytes. If 0 , the fatal error occurs. |
0
if given signature is the signature of given message, otherwise non-zero value.