QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
ecdsa.h File Reference

Contains the primary public API for the ECDSA asymmetric signature scheme implementation. More...

#include "common.h"

Go to the source code of this file.

Macros

#define QSC_ECDSA_SIGNATURE_SIZE   64
 The byte size of the signature array.
 
#define QSC_ECDSA_PRIVATEKEY_SIZE   64
 The byte size of the secret private-key array.
 
#define QSC_ECDSA_PUBLICKEY_SIZE   32
 The byte size of the public-key array.
 
#define QSC_ECDSA_SEED_SIZE   32ULL
 The byte size of the random seed array.
 
#define QSC_ECDSA_ALGNAME   "ECDSA"
 The formal algorithm name.
 

Functions

QSC_EXPORT_API void qsc_ecdsa_generate_seeded_keypair (uint8_t *publickey, uint8_t *privatekey, const uint8_t *seed)
 Generates a ECDSA public/private key-pair.
 
QSC_EXPORT_API void qsc_ecdsa_generate_keypair (uint8_t *publickey, uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
 Generates a ECDSA public/private key-pair.
 
QSC_EXPORT_API void qsc_ecdsa_sign (uint8_t *signedmsg, size_t *smsglen, const uint8_t *message, size_t msglen, const uint8_t *privatekey)
 Takes the message as input and returns an array containing the signature followed by the message.
 
QSC_EXPORT_API bool qsc_ecdsa_verify (uint8_t *message, size_t *msglen, const uint8_t *signedmsg, size_t smsglen, const uint8_t *publickey)
 Verifies a signature-message pair with the public key.
 

Detailed Description

Contains the primary public API for the ECDSA asymmetric signature scheme implementation.

This header defines the API for the ECDSA (Elliptic Curve Digital Signature Algorithm) asymmetric signature scheme, operating over the Ed25519 elliptic curve. It provides functions for generating key pairs (either randomly or via a seeded generator), signing messages, and verifying signatures.

Example:
// An example of key-pair creation, signing, and verification using ECDSA
#define MSGLEN 32
uint8_t sk[QSC_ECDSA_SECRETKEY_SIZE];
uint8_t msg[32];
uint8_t smsg[QSC_ECDSA_SIGNATURE_SIZE + MSGLEN];
uint8_t rmsg[32];
uint32_t rmsglen = 0;
uint32_t smsglen = 0;
// Create the public and secret keys using a seeded generator
qsc_ecdsa_generate_seeded_keypair(pk, sk, random_seed);
// Sign the message; the signature is prepended to the message
qsc_ecdsa_sign(smsg, &smsglen, msg, MSGLEN, sk);
// Verify the signature and retrieve the message bytes
if (qsc_ecdsa_verify(rmsg, &rmsglen, smsg, smsglen, pk) != true)
{
// Authentication failed; handle error.
}
QSC_EXPORT_API void qsc_ecdsa_generate_seeded_keypair(uint8_t *publickey, uint8_t *privatekey, const uint8_t *seed)
Generates a ECDSA public/private key-pair.
Definition ecdsa.c:6
#define QSC_ECDSA_SIGNATURE_SIZE
The byte size of the signature array.
Definition ecdsa.h:97
#define QSC_ECDSA_PUBLICKEY_SIZE
The byte size of the public-key array.
Definition ecdsa.h:109
QSC_EXPORT_API bool qsc_ecdsa_verify(uint8_t *message, size_t *msglen, const uint8_t *signedmsg, size_t smsglen, const uint8_t *publickey)
Verifies a signature-message pair with the public key.
Definition ecdsa.c:38
QSC_EXPORT_API void qsc_ecdsa_sign(uint8_t *signedmsg, size_t *smsglen, const uint8_t *message, size_t msglen, const uint8_t *privatekey)
Takes the message as input and returns an array containing the signature followed by the message.
Definition ecdsa.c:28
Remarks
This ECDSA implementation utilizes the Ed25519 elliptic curve along with its underlying field arithmetic over the prime field defined by 2^255 - 19. It supports standard digital signature operations including key pair generation, signing, and verification. The design emphasizes constant-time execution to mitigate timing attacks and is suitable for secure applications in modern cryptographic protocols.

Reference Links

Function Documentation

◆ qsc_ecdsa_generate_keypair()

QSC_EXPORT_API void qsc_ecdsa_generate_keypair ( uint8_t * publickey,
uint8_t * privatekey,
bool(* rng_generate )(uint8_t *, size_t) )

Generates a ECDSA public/private key-pair.

Warning
Arrays must be sized to QSC_ECDSA_PUBLICKEY_SIZE and QSC_ECDSA_SECRETKEY_SIZE.
Parameters
publickey[uint8_t*] Pointer to the public verification-key array
privatekey[uint8_t*] Pointer to the private signature-key array
rng_generate[uint8_t*, size_t] Pointer to the random generator

◆ qsc_ecdsa_generate_seeded_keypair()

QSC_EXPORT_API void qsc_ecdsa_generate_seeded_keypair ( uint8_t * publickey,
uint8_t * privatekey,
const uint8_t * seed )

Generates a ECDSA public/private key-pair.

Warning
Arrays must be sized to QSC_ECDSA_PUBLICKEY_SIZE and QSC_ECDSA_SECRETKEY_SIZE.
Parameters
publickey[uint8_t*] Pointer to the public verification-key array
privatekey[uint8_t*] Pointer to the private signature-key array
seed[const uint8_t*] Pointer to the random 32-byte seed array

◆ qsc_ecdsa_sign()

QSC_EXPORT_API void qsc_ecdsa_sign ( uint8_t * signedmsg,
size_t * smsglen,
const uint8_t * message,
size_t msglen,
const uint8_t * privatekey )

Takes the message as input and returns an array containing the signature followed by the message.

Warning
Signature array must be sized to the size of the message plus QSC_ECDSA_SIGNATURE_SIZE.
Parameters
signedmsg[uint8_t*] Pointer to the signed-message array
smsglen[size_t*] Pointer to the signed message length
message[const uint8_t*] Pointer to the message array
msglen[size_t] The message length
privatekey[const uint8_t*] Pointer to the private signature-key array

◆ qsc_ecdsa_verify()

QSC_EXPORT_API bool qsc_ecdsa_verify ( uint8_t * message,
size_t * msglen,
const uint8_t * signedmsg,
size_t smsglen,
const uint8_t * publickey )

Verifies a signature-message pair with the public key.

Parameters
message[uint8_t*] Pointer to the message array to be signed
msglen[size_t*]Pointer to the message length
signedmsg[const uint8_t*] Pointer to the signed message array
smsglen[size_t] The signed message length
publickey[const uint8_t*] Pointer to the public verification-key array
Returns
[bool] Returns true for success