PQLR
Postquantum Crypto Library by QAPP
|
Typedefs | |
typedef struct dilithium_st * | dilithium_t |
Dilithium algorithm instance handle. More... | |
Enumerations | |
enum | dilithium_parameterset_t { dilithium_2 , dilithium_3 , dilithium_5 , dilithium_2_r , dilithium_3_r , dilithium_5_r , dilithium_last } |
Possible dilithium parameters sets. More... | |
Functions | |
PQLR_API dilithium_t | dilithium_new (dilithium_parameterset_t parameterset) |
Creates new dilithium instance with selected parameter set. More... | |
PQLR_API void | dilithium_free (dilithium_t dilithium) |
Frees dilithium instance and all corresponding resources. More... | |
PQLR_API dilithium_t | dilithium_duplicate (const dilithium_t dilithium) |
Duplicates context of dilithium instance. More... | |
PQLR_API pqlr_t | dilithium_to_pqlr (dilithium_t dilithium) |
Gets pqlr instance linked to this dilithium instance. More... | |
PQLR_API size_t | dilithium_get_public_key_bytes_len (const dilithium_t dilithium) |
Obtains public key buffer length in bytes for current dilithium instance. More... | |
PQLR_API size_t | dilithium_get_secret_key_bytes_len (const dilithium_t dilithium) |
Obtains secret key buffer length in bytes for current dilithium instance. More... | |
PQLR_API size_t | dilithium_get_signature_bytes_len (dilithium_t dilithium) |
Obtains signature buffer length in bytes for current dilithium instance. More... | |
PQLR_API void | dilithium_generate_keys (const dilithium_t dilithium, uint8_t *result_sk, uint8_t *result_pk) |
Generates random secret key and public key for given context. More... | |
PQLR_API void | dilithium_sign (const dilithium_t dilithium, const uint8_t *sk, const uint8_t *msg, size_t msg_len, uint8_t *result_sig, size_t *result_sig_len) |
Generates signature for given message according to context and secret key. More... | |
PQLR_API int | dilithium_verify (const dilithium_t dilithium, 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 Dilithium algorithm implementation, whose security is based on the hardness of finding short vectors in lattices.
At first, initialize algorithm's instance with parameters you want with dilithium_new(). After that, you can generate secret and public keys using dilithium_generate_keys, or sign your message with dilithium_sign, or verify message wasn't changed with dilithium_verify. You are able to interact with this algorithm likewise pqlr_t instance (change error handler, source of entropy input, e.t.c) via dilithium_to_pqlr() call.
After there are no more need in signature scheme it's resources must be made free by dilithium_free.
In order to use any Dilithium signature scheme functions, add the following include:
Example code is listed below:
typedef struct dilithium_st* dilithium_t |
Dilithium algorithm instance handle.
PQLR_API dilithium_t dilithium_duplicate | ( | const dilithium_t | dilithium | ) |
Duplicates context of dilithium instance.
dilithium | instance to duplicate |
PQLR_API void dilithium_free | ( | dilithium_t | dilithium | ) |
Frees dilithium instance and all corresponding resources.
[in] | dilithium | instance to free |
PQLR_API void dilithium_generate_keys | ( | const dilithium_t | dilithium, |
uint8_t * | result_sk, | ||
uint8_t * | result_pk | ||
) |
Generates random secret key and public key for given context.
Usage:
[in] | dilithium | Instance of dilithium created with dilithium_new(). If NULL , the fatal error occurs. |
[out] | result_sk | Contiguous array to receive secret key, of size dilithium_get_secret_key_bytes_len . If NULL , the fatal error occurs. |
[out] | result_pk | Contiguous array to receive public key, of size dilithium_get_public_key_bytes_len . If NULL , the fatal error occurs. |
PQLR_API size_t dilithium_get_public_key_bytes_len | ( | const dilithium_t | dilithium | ) |
Obtains public key buffer length in bytes for current dilithium instance.
[in] | dilithium | initialized dilithium instance |
PQLR_API size_t dilithium_get_secret_key_bytes_len | ( | const dilithium_t | dilithium | ) |
Obtains secret key buffer length in bytes for current dilithium instance.
[in] | dilithium | initialized dilithium instance |
PQLR_API size_t dilithium_get_signature_bytes_len | ( | dilithium_t | dilithium | ) |
Obtains signature buffer length in bytes for current dilithium instance.
[in] | dilithium | initialized dilithium instance |
PQLR_API dilithium_t dilithium_new | ( | dilithium_parameterset_t | parameterset | ) |
Creates new dilithium instance with selected parameter set.
Usage:
[in] | parameterset | available set of parameters for dilithium algorithm |
NULL
if out of memory PQLR_API void dilithium_sign | ( | const dilithium_t | dilithium, |
const uint8_t * | sk, | ||
const uint8_t * | msg, | ||
size_t | msg_len, | ||
uint8_t * | result_sig, | ||
size_t * | result_sig_len | ||
) |
Generates signature for given message according to context and secret key.
Usage:
[in] | dilithium | Instance of dilithium created with dilithium_new(). If NULL , the fatal error occurs. |
[in] | sk | Secret key, the contiguous array of size dilithium_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 dilithium_get_signature_bytes_len . If NULL , the fatal error occurs. |
[out] | result_sig_len | The result signature size. |
PQLR_API pqlr_t dilithium_to_pqlr | ( | dilithium_t | dilithium | ) |
Gets pqlr instance linked to this dilithium instance.
[in] | dilithium | initialized dilithium instance |
NULL
if dilithium is NULL PQLR_API int dilithium_verify | ( | const dilithium_t | dilithium, |
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] | dilithium | Context, initialized with dilithium_new(). If NULL , the fatal error occurs. |
[in] | pk | Public key, the contiguous array of size dilithium_get_public_key_bytes_len . If NULL , the fatal error occurs. |
[in] | sig | Signature, the contiguous array of size ‘dilithium_get_signature_bytes_len’. If NULL , the fatal error occurs. |
[in] | sig_len | The length of a signature in bytes. |
[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.