PQLR
Postquantum Crypto Library by QAPP
Shipovnik signature scheme

Typedefs

typedef struct shipovnik_st * shipovnik_t
 Shipovnik algorithm instance handle. More...
 

Enumerations

enum  shipovnik_parameterset_t { shipovnik_default , shipovnik_last }
 Possible shipovnik parameters sets. More...
 

Functions

PQLR_API shipovnik_t shipovnik_new (shipovnik_parameterset_t parameterset)
 Creates new shipovnik instance with selected parameter set. More...
 
PQLR_API void shipovnik_free (shipovnik_t shipovnik)
 Frees shipovnik instance and all corresponding resources. More...
 
PQLR_API shipovnik_t shipovnik_duplicate (const shipovnik_t shipovnik)
 Duplicates context of shipovnik instance. More...
 
PQLR_API pqlr_t shipovnik_to_pqlr (shipovnik_t shipovnik)
 Casts shipovnik instance to pqlr instance. More...
 
PQLR_API size_t shipovnik_get_public_key_bytes_len (const shipovnik_t shipovnik)
 Obtains public key buffer length in bytes for current shipovnik instance. More...
 
PQLR_API size_t shipovnik_get_secret_key_bytes_len (const shipovnik_t shipovnik)
 Obtains secret key buffer length in bytes for current shipovnik instance. More...
 
PQLR_API size_t shipovnik_get_signature_bytes_len (shipovnik_t shipovnik)
 Obtains signature buffer length in bytes for current shipovnik instance. More...
 
PQLR_API void shipovnik_generate_keys (const shipovnik_t shipovnik, uint8_t *result_sk, uint8_t *result_pk)
 Generates random secret key and public key for given context. More...
 
PQLR_API void shipovnik_sign (const shipovnik_t shipovnik, 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 shipovnik_verify (const shipovnik_t shipovnik, 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...
 

Detailed Description

This module provides Shipovnik algorithm, whose security is implemented using operations on error-correcting codes defined on a final two-element prime field.

General usage

At first, initialize algorithm's instance with parameters you want with shipovnik_new(). After that, you can generate secret and public keys using shipovnik_generate_keys, or sign your message with shipovnik_sign, or verify message wasn't changed with shipovnik_verify. You are able to interact with this algorithm likewise pqlr_t instance (change error handler, source of entropy input, e.t.c) via shipovnik_to_pqlr() call.

After there is no more need in signature scheme it's resources must be made free by shipovnik_free.

In order to use any Shipovnik signature scheme functions, add the following include:

Example code is listed below:

#include <stdlib.h>
void use_new(void)
{
// free resources
shipovnik_free(shipovnik);
}
void use_generate_keys(void)
{
const size_t sk_len = shipovnik_get_secret_key_bytes_len(shipovnik);
const size_t pk_len = shipovnik_get_public_key_bytes_len(shipovnik);
uint8_t* sk = (uint8_t*)calloc(sk_len, sizeof(uint8_t));
uint8_t* pk = (uint8_t*)calloc(pk_len, sizeof(uint8_t));
shipovnik_generate_keys(shipovnik, sk, pk);
// free resources
free(pk);
free(sk);
shipovnik_free(shipovnik);
}
void use_sign(void)
{
const size_t sk_len = shipovnik_get_secret_key_bytes_len(shipovnik);
// get secret key from somewhere
uint8_t* sk = (uint8_t*)calloc(sk_len, sizeof(uint8_t));
size_t sig_len = shipovnik_get_signature_bytes_len(shipovnik);
uint8_t* sig = (uint8_t*)calloc(sig_len, sizeof(uint8_t));
unsigned char msg[] = "test";
shipovnik_sign(shipovnik, sk, msg, sizeof(msg), sig, &sig_len);
// free resources
free(sig);
free(sk);
shipovnik_free(shipovnik);
}
void use_verify(void)
{
const size_t pk_len = shipovnik_get_public_key_bytes_len(shipovnik);
const size_t sig_len = shipovnik_get_signature_bytes_len(shipovnik);
// get public key and signature from somewhere
uint8_t* pk = (uint8_t*)calloc(pk_len, sizeof(uint8_t));
uint8_t* sig = (uint8_t*)calloc(sig_len, sizeof(uint8_t));
unsigned char msg[] = "test";
int res = shipovnik_verify(shipovnik, pk, sig, sig_len, msg, sizeof(msg));
// free resources
free(sig);
free(pk);
shipovnik_free(shipovnik);
}
int main(void)
{
use_new();
use_generate_keys();
use_sign();
use_verify();
}
PQLR_API int shipovnik_verify(const shipovnik_t shipovnik, 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.
struct shipovnik_st * shipovnik_t
Shipovnik algorithm instance handle.
Definition: shipovnik.h:55
PQLR_API size_t shipovnik_get_public_key_bytes_len(const shipovnik_t shipovnik)
Obtains public key buffer length in bytes for current shipovnik instance.
PQLR_API size_t shipovnik_get_signature_bytes_len(shipovnik_t shipovnik)
Obtains signature buffer length in bytes for current shipovnik instance.
PQLR_API void shipovnik_sign(const shipovnik_t shipovnik, 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.
PQLR_API void shipovnik_free(shipovnik_t shipovnik)
Frees shipovnik instance and all corresponding resources.
PQLR_API shipovnik_t shipovnik_new(shipovnik_parameterset_t parameterset)
Creates new shipovnik instance with selected parameter set.
PQLR_API void shipovnik_generate_keys(const shipovnik_t shipovnik, uint8_t *result_sk, uint8_t *result_pk)
Generates random secret key and public key for given context.
PQLR_API size_t shipovnik_get_secret_key_bytes_len(const shipovnik_t shipovnik)
Obtains secret key buffer length in bytes for current shipovnik instance.
@ shipovnik_default
Definition: shipovnik.h:46

Typedef Documentation

◆ shipovnik_t

typedef struct shipovnik_st* shipovnik_t

Shipovnik algorithm instance handle.

Note
It could be casted to pqlr_t instance linked to this handle
See also
shipovnik_to_pqlr

Enumeration Type Documentation

◆ shipovnik_parameterset_t

Possible shipovnik parameters sets.

Enumerator
shipovnik_default 
shipovnik_last 

Function Documentation

◆ shipovnik_duplicate()

PQLR_API shipovnik_t shipovnik_duplicate ( const shipovnik_t  shipovnik)

Duplicates context of shipovnik instance.

Parameters
shipovnikinstance to duplicate
Returns
new instance with a duplicated context

◆ shipovnik_free()

PQLR_API void shipovnik_free ( shipovnik_t  shipovnik)

Frees shipovnik instance and all corresponding resources.

Parameters
[in]shipovnikinstance to free
See also
shipovnik_t
shipovnik_new

◆ shipovnik_generate_keys()

PQLR_API void shipovnik_generate_keys ( const shipovnik_t  shipovnik,
uint8_t *  result_sk,
uint8_t *  result_pk 
)

Generates random secret key and public key for given context.

Usage:

const size_t sk_len = shipovnik_get_secret_key_bytes_len(shipovnik);
const size_t pk_len = shipovnik_get_public_key_bytes_len(shipovnik);
uint8_t* sk = (uint8_t*)calloc(sk_len, sizeof(uint8_t));
uint8_t* pk = (uint8_t*)calloc(pk_len, sizeof(uint8_t));
shipovnik_generate_keys(shipovnik, sk, pk);
Parameters
[in]shipovnikInstance of shipovnik created with shipovnik_new(). If NULL, the fatal error occurs.
[out]result_skContiguous array to receive secret key, of size shipovnik_get_secret_key_bytes_len. If NULL, the fatal error occurs.
[out]result_pkContiguous array to receive public key, of size shipovnik_get_public_key_bytes_len. If NULL, the fatal error occurs.
See also
shipovnik_new
shipovnik_get_secret_key_bytes_len
shipovnik_get_public_key_bytes_len

◆ shipovnik_get_public_key_bytes_len()

PQLR_API size_t shipovnik_get_public_key_bytes_len ( const shipovnik_t  shipovnik)

Obtains public key buffer length in bytes for current shipovnik instance.

Parameters
[in]shipovnikinitialized shipovnik instance
See also
shipovnik_t
shipovnik_new
Returns
public key buffer length in bytes

◆ shipovnik_get_secret_key_bytes_len()

PQLR_API size_t shipovnik_get_secret_key_bytes_len ( const shipovnik_t  shipovnik)

Obtains secret key buffer length in bytes for current shipovnik instance.

Parameters
[in]shipovnikinitialized shipovnik instance
See also
shipovnik_t
shipovnik_new
Returns
secret key buffer length in bytes

◆ shipovnik_get_signature_bytes_len()

PQLR_API size_t shipovnik_get_signature_bytes_len ( shipovnik_t  shipovnik)

Obtains signature buffer length in bytes for current shipovnik instance.

Parameters
[in]shipovnikinitialized shipovnik instance
See also
shipovnik_t
shipovnik_new
Returns
signature buffer max length in bytes

◆ shipovnik_new()

PQLR_API shipovnik_t shipovnik_new ( shipovnik_parameterset_t  parameterset)

Creates new shipovnik instance with selected parameter set.

Usage:

Parameters
[in]parametersetavailable set of parameters for shipovnik algorithm
Returns
initialized shipovnik instance or NULL if out of memory

◆ shipovnik_sign()

PQLR_API void shipovnik_sign ( const shipovnik_t  shipovnik,
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:

const size_t sk_len = shipovnik_get_secret_key_bytes_len(shipovnik);
// get secret key from somewhere
uint8_t* sk = (uint8_t*)calloc(sk_len, sizeof(uint8_t));
size_t sig_len = shipovnik_get_signature_bytes_len(shipovnik);
uint8_t* sig = (uint8_t*)calloc(sig_len, sizeof(uint8_t));
unsigned char msg[] = "test";
shipovnik_sign(shipovnik, sk, msg, sizeof(msg), sig, &sig_len);
Note
the maximum length of a signature is given by get_signature_bytes_len, while the actual length may be smaller and is returned in sig_len.
Parameters
[in]shipovnikInstance of shipovnik created with shipovnik_new(). If NULL, the fatal error occurs.
[in]skSecret key, the contiguous array of size shipovnik_get_secret_key_bytes_len. If NULL, the fatal error occurs.
[in]msgMessage to generate signature of, the contiguous array. If NULL, the fatal error occurs.
[in]msg_lenThe length of a message in bytes. If 0, the fatal error occurs.
[out]result_sigContiguous array to receive signature, of size shipovnik_get_signature_bytes_len. If NULL, the fatal error occurs.
[out]result_sig_lenThe result signature size.
See also
shipovnik_get_secret_key_bytes_len
shipovnik_get_signature_bytes_len

◆ shipovnik_to_pqlr()

PQLR_API pqlr_t shipovnik_to_pqlr ( shipovnik_t  shipovnik)

Casts shipovnik instance to pqlr instance.

Parameters
[in]shipovnikinitialized shipovnik instance
Note
this pqlr instance will be released by shipovnik_free
See also
shipovnik_t
pqlr_t
shipovnik_free
Returns
operable pqlr instance or NULL if shipovnik is NULL

◆ shipovnik_verify()

PQLR_API int shipovnik_verify ( const shipovnik_t  shipovnik,
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:

const size_t pk_len = shipovnik_get_public_key_bytes_len(shipovnik);
const size_t sig_len = shipovnik_get_signature_bytes_len(shipovnik);
// get public key and signature from somewhere
uint8_t* pk = (uint8_t*)calloc(pk_len, sizeof(uint8_t));
uint8_t* sig = (uint8_t*)calloc(sig_len, sizeof(uint8_t));
unsigned char msg[] = "test";
int res = shipovnik_verify(shipovnik, pk, sig, sig_len, msg, sizeof(msg));
Parameters
[in]shipovnikContext, initialized with shipovnik_new(). If NULL, the fatal error occurs.
[in]pkPublic key, the contiguous array of size shipovnik_get_public_key_bytes_len. If NULL, the fatal error occurs.
[in]sigSignature, the contiguous array of size ‘shipovnik_get_signature_bytes_len’. If NULL, the fatal error occurs.
[in]msgMessage to verify signature of, the contiguous array. If NULL, the fatal error occurs.
[in]msg_lenThe length of a message in bytes. If 0, the fatal error occurs.
[in]sig_lenThe length of a signature in bytes.
Returns
0 if given signature is the signature of given message, otherwise non-zero value.
See also
shipovnik_get_signature_bytes_len
shipovnik_get_public_key_bytes_len