MPHELL  5.0.0
Data Structures | Typedefs | Functions
mphell_tuto_ecsdsa.c File Reference

Tutorial for ecsdsa signature and verification using mphell. More...

#include <stdio.h>
#include "mphell/mphell.h"
Include dependency graph for mphell_tuto_ecsdsa.c:

Go to the source code of this file.

Data Structures

struct  ecsdsa_sig
 Define an ECSDSA signature. More...
 

Typedefs

typedef struct ecsdsa_sig ecsdsa_sig_t
 Define the ECSDSA signature type.
 
typedef ecsdsa_sig_t ecsdsa_sig[1]
 Pointer on an allocated ecsdsa_sig_t structure.
 

Functions

void ecsdsa_sign_alloc (ecsdsa_sig *sig, int size)
 
void ecsdsa_sign_free (ecsdsa_sig *sig)
 
void ec_point_mul_ecdsa (ec_point dst, number_srcptr u1, ec_point_srcptr G, number_srcptr u2, ec_point_srcptr key, ec_curve_srcptr E)
 
void ecsdsa_sign (unsigned char *hash, ecsdsa_sig *sig, number priv_key, ec_curve *curve)
 Sign "hash" with ECDSA algorithm using the EC "curve" and the private key "key". More...
 
int8_t ecsdsa_verify (unsigned char *hash, ecsdsa_sig *sig, ec_point *pub_key, ec_curve *curve)
 Verify the signature "sig" of hash "hash" using public key "pub_key" and the EC "curve". More...
 
int8_t ecsdsa_pub_key_validation (ec_point *pub_key, ec_curve *curve)
 Verify that the public key is valid (id est check taht pub_key belongs to the curve, that pub_key is not the neutral element and that pub_key is of ordre n) More...
 
int main ()
 

Detailed Description

Tutorial for ecsdsa signature and verification using mphell.

Definition in file mphell_tuto_ecsdsa.c.

Function Documentation

◆ ecsdsa_pub_key_validation()

int8_t ecsdsa_pub_key_validation ( ec_point pub_key,
ec_curve curve 
)

Verify that the public key is valid (id est check taht pub_key belongs to the curve, that pub_key is not the neutral element and that pub_key is of ordre n)

Parameters
hashH(m) where H is a cryptographic hash function and m the message to sign. Must be written under hexadecimal form. ex: 64 hexadecimal characters for sha256.
pub_keyPublic key
curveElliptic curve
Returns
1 on success, 0 on failure

Definition at line 398 of file mphell_tuto_ecsdsa.c.

◆ ecsdsa_sign()

void ecsdsa_sign ( unsigned char *  hash,
ecsdsa_sig sig,
number  priv_key,
ec_curve curve 
)

Sign "hash" with ECDSA algorithm using the EC "curve" and the private key "key".

Parameters
hashH(m) where H is a cryptographic hash function and m the message to sign. Must be written under hexadecimal form. ex: 64 hexadecimal characters for sha256.
sigDestination signature. Pointer on an allocated ecdsa_sig structure.
priv_keyPrivate key
curveElliptic curve

Definition at line 166 of file mphell_tuto_ecsdsa.c.

◆ ecsdsa_verify()

int8_t ecsdsa_verify ( unsigned char *  hash,
ecsdsa_sig sig,
ec_point pub_key,
ec_curve curve 
)

Verify the signature "sig" of hash "hash" using public key "pub_key" and the EC "curve".

For the hash several functions can be used, the interested reader can refer to [FIPS-180]

Parameters
hashH(m) where H is a cryptographic hash function and m the message to sign. Must be written under hexadecimal form. ex: 64 hexadecimal characters for sha256.
sigSignature of hash
pub_keyPublic key
curveElliptic curve
Returns
1 on success, 0 on failure

Definition at line 288 of file mphell_tuto_ecsdsa.c.