xref: /freebsd/crypto/libecc/src/sig/bign.c (revision f0865ec9906d5a18fa2a3b61381f22ce16e606ad)
1*f0865ec9SKyle Evans /*
2*f0865ec9SKyle Evans  *  Copyright (C) 2017 - This file is part of libecc project
3*f0865ec9SKyle Evans  *
4*f0865ec9SKyle Evans  *  Authors:
5*f0865ec9SKyle Evans  *      Ryad BENADJILA <ryadbenadjila@gmail.com>
6*f0865ec9SKyle Evans  *      Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
7*f0865ec9SKyle Evans  *      Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
8*f0865ec9SKyle Evans  *
9*f0865ec9SKyle Evans  *  Contributors:
10*f0865ec9SKyle Evans  *      Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
11*f0865ec9SKyle Evans  *      Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
12*f0865ec9SKyle Evans  *
13*f0865ec9SKyle Evans  *  This software is licensed under a dual BSD and GPL v2 license.
14*f0865ec9SKyle Evans  *  See LICENSE file at the root folder of the project.
15*f0865ec9SKyle Evans  */
16*f0865ec9SKyle Evans #include <libecc/lib_ecc_config.h>
17*f0865ec9SKyle Evans #ifdef WITH_SIG_BIGN
18*f0865ec9SKyle Evans 
19*f0865ec9SKyle Evans #include <libecc/nn/nn_rand.h>
20*f0865ec9SKyle Evans #include <libecc/nn/nn_mul_public.h>
21*f0865ec9SKyle Evans #include <libecc/nn/nn_logical.h>
22*f0865ec9SKyle Evans 
23*f0865ec9SKyle Evans #include <libecc/sig/sig_algs_internal.h>
24*f0865ec9SKyle Evans #include <libecc/sig/ec_key.h>
25*f0865ec9SKyle Evans #include <libecc/utils/utils.h>
26*f0865ec9SKyle Evans #ifdef VERBOSE_INNER_VALUES
27*f0865ec9SKyle Evans #define EC_SIG_ALG "BIGN"
28*f0865ec9SKyle Evans #endif
29*f0865ec9SKyle Evans #include <libecc/utils/dbg_sig.h>
30*f0865ec9SKyle Evans 
bign_init_pub_key(ec_pub_key * out_pub,const ec_priv_key * in_priv)31*f0865ec9SKyle Evans int bign_init_pub_key(ec_pub_key *out_pub, const ec_priv_key *in_priv)
32*f0865ec9SKyle Evans {
33*f0865ec9SKyle Evans 	return __bign_init_pub_key(out_pub, in_priv, BIGN);
34*f0865ec9SKyle Evans }
35*f0865ec9SKyle Evans 
bign_siglen(u16 p_bit_len,u16 q_bit_len,u8 hsize,u8 blocksize,u8 * siglen)36*f0865ec9SKyle Evans int bign_siglen(u16 p_bit_len, u16 q_bit_len, u8 hsize, u8 blocksize, u8 *siglen)
37*f0865ec9SKyle Evans {
38*f0865ec9SKyle Evans 	return __bign_siglen(p_bit_len, q_bit_len, hsize, blocksize, siglen);
39*f0865ec9SKyle Evans }
40*f0865ec9SKyle Evans 
_bign_sign_init(struct ec_sign_context * ctx)41*f0865ec9SKyle Evans int _bign_sign_init(struct ec_sign_context *ctx)
42*f0865ec9SKyle Evans {
43*f0865ec9SKyle Evans 	return __bign_sign_init(ctx, BIGN);
44*f0865ec9SKyle Evans }
45*f0865ec9SKyle Evans 
_bign_sign_update(struct ec_sign_context * ctx,const u8 * chunk,u32 chunklen)46*f0865ec9SKyle Evans int _bign_sign_update(struct ec_sign_context *ctx,
47*f0865ec9SKyle Evans 		       const u8 *chunk, u32 chunklen)
48*f0865ec9SKyle Evans {
49*f0865ec9SKyle Evans 	return __bign_sign_update(ctx, chunk, chunklen, BIGN);
50*f0865ec9SKyle Evans }
51*f0865ec9SKyle Evans 
_bign_sign_finalize(struct ec_sign_context * ctx,u8 * sig,u8 siglen)52*f0865ec9SKyle Evans int _bign_sign_finalize(struct ec_sign_context *ctx, u8 *sig, u8 siglen)
53*f0865ec9SKyle Evans {
54*f0865ec9SKyle Evans 	return __bign_sign_finalize(ctx, sig, siglen, BIGN);
55*f0865ec9SKyle Evans }
56*f0865ec9SKyle Evans 
_bign_verify_init(struct ec_verify_context * ctx,const u8 * sig,u8 siglen)57*f0865ec9SKyle Evans int _bign_verify_init(struct ec_verify_context *ctx, const u8 *sig, u8 siglen)
58*f0865ec9SKyle Evans {
59*f0865ec9SKyle Evans 	return __bign_verify_init(ctx, sig, siglen, BIGN);
60*f0865ec9SKyle Evans }
61*f0865ec9SKyle Evans 
_bign_verify_update(struct ec_verify_context * ctx,const u8 * chunk,u32 chunklen)62*f0865ec9SKyle Evans int _bign_verify_update(struct ec_verify_context *ctx,
63*f0865ec9SKyle Evans 			 const u8 *chunk, u32 chunklen)
64*f0865ec9SKyle Evans {
65*f0865ec9SKyle Evans 	return __bign_verify_update(ctx, chunk, chunklen, BIGN);
66*f0865ec9SKyle Evans }
67*f0865ec9SKyle Evans 
_bign_verify_finalize(struct ec_verify_context * ctx)68*f0865ec9SKyle Evans int _bign_verify_finalize(struct ec_verify_context *ctx)
69*f0865ec9SKyle Evans {
70*f0865ec9SKyle Evans 	return __bign_verify_finalize(ctx, BIGN);
71*f0865ec9SKyle Evans }
72*f0865ec9SKyle Evans 
73*f0865ec9SKyle Evans #else /* WITH_SIG_BIGN */
74*f0865ec9SKyle Evans 
75*f0865ec9SKyle Evans /*
76*f0865ec9SKyle Evans  * Dummy definition to avoid the empty translation unit ISO C warning
77*f0865ec9SKyle Evans  */
78*f0865ec9SKyle Evans typedef int dummy;
79*f0865ec9SKyle Evans #endif /* WITH_SIG_BIGN */
80