PQSPP_keygen

Description

PQSPP_keygen generates a public key and a secret key for digital signing processes.

Syntax

int PQSPP_keygen(
    uint8_t**   sk,
    uint8_t**   pk,
    int*        pk_len
);

Parameters

  • sk

The address of a uint8_t* pointer. PQSPP_keygen will be populate this address with the address of the secret key.

Note to free this memory address by calling PQSPP_free_memory on sk when the memory is no longer needed.

  • pk

The address of a uint8_t* pointer. PQSPP_keygen will be populate this address with the address of the public key.

Note to free this memory address by calling PQSPP_free_memory on pk when the memory is no longer needed.

  • pk_len

The address of an integer variable. PQSPP_keygen will populate this address with the size of the public key. This size is in terms of number of bytes.

Return value

Return code

Description

PQSPP_OK

The function was successful

Anything other than OK is an error.

Code example

#include "pqspp.h"
#include "sha256.h"

#include <stdio.h>
#include <stdlib.h>

int main()
{

    // PQSPP_keygen
    uint8_t *sk = NULL;
    uint8_t *pk = NULL;
    int pk_len = -1;

    int ret = PQSPP_keygen(&sk, &pk, &pk_len);
    if (ret != PQSPP_OK) {
        printf("Error in keygen: %d\n", ret);
        return -1;
    }
    printf(
        "Generated a secret key and a public key (DER encoded of length %d)!\n",
        pk_len);
}