Path: blob/main/external/libecc/src/examples/sig/sdsa/sdsa.h
2066 views
/*1* Copyright (C) 2021 - This file is part of libecc project2*3* Authors:4* Ryad BENADJILA <[email protected]>5* Arnaud EBALARD <[email protected]>6*7* This software is licensed under a dual BSD and GPL v2 license.8* See LICENSE file at the root folder of the project.9*/10#ifndef __SDSA_H__11#define __SDSA_H__1213/*14* NOTE: although we only need libarith for SDSA as we15* manipulate a ring of integers, we include libsig for16* the hash algorithms.17*/18#include <libecc/lib_ecc_config.h>1920/* The hash algorithms wrapper */21#include "../../hash/hash.h"2223/* The DSA include file as we reuse DSA primitives internally */24#include "../dsa/dsa.h"2526/* We define hereafter the types and functions for SDSA.27*/2829/* SDSA public key, composed of:30* p the SDSA prime modulus31* q the SDSA prime order (prime divisor of (p-1))32* g the SDSA generator33* y the public key = g^x (p)34*35* NOTE: the SDSA (Schnorr DSA) public key is mapped to a DSA public key36* as the parameters are the same.37*/38typedef dsa_pub_key sdsa_pub_key;3940/* SDSA private key, composed of:41* p the SDSA prime modulus42* q the SDSA prime order (prime divisor of (p-1))43* g the SDSA generator44* x the secret key45*46* NOTE: the SDSA (Schnorr DSA) private key is mapped to a DSA private key47* as the parameters are the same.48*/49typedef dsa_priv_key sdsa_priv_key;5051ATTRIBUTE_WARN_UNUSED_RET int sdsa_import_priv_key(sdsa_priv_key *priv, const u8 *p, u16 plen,52const u8 *q, u16 qlen,53const u8 *g, u16 glen,54const u8 *x, u16 xlen);5556ATTRIBUTE_WARN_UNUSED_RET int sdsa_import_pub_key(sdsa_pub_key *pub, const u8 *p, u16 plen,57const u8 *q, u16 qlen,58const u8 *g, u16 glen,59const u8 *y, u16 ylen);6061ATTRIBUTE_WARN_UNUSED_RET int sdsa_compute_pub_from_priv(sdsa_pub_key *pub,62const sdsa_priv_key *priv);6364ATTRIBUTE_WARN_UNUSED_RET int sdsa_sign(const sdsa_priv_key *priv, const u8 *msg, u32 msglen,65const u8 *nonce, u16 noncelen,66u8 *sig, u16 siglen, gen_hash_alg_type sdsa_hash);6768ATTRIBUTE_WARN_UNUSED_RET int sdsa_verify(const sdsa_pub_key *pub, const u8 *msg, u32 msglen,69const u8 *sig, u16 siglen, gen_hash_alg_type sdsa_hash);7071#endif /* __SDSA_H__ */727374