My Project
Loading...
Searching...
No Matches
sp.h
1/* sp.h
2 *
3 * Copyright (C) 2006-2020 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL.
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 */
21
22
23#ifndef WOLF_CRYPT_SP_H
24#define WOLF_CRYPT_SP_H
25
27
28#if defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH) || \
29 defined(WOLFSSL_HAVE_SP_ECC)
30
31#include <stdint.h>
32
33#include <wolfssl/wolfcrypt/integer.h>
34#include <wolfssl/wolfcrypt/sp_int.h>
35
37
38#if defined(_MSC_VER)
39 #define SP_NOINLINE __declspec(noinline)
40#elif defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__KEIL__)
41 #define SP_NOINLINE __attribute__((noinline))
42#else
43 #define SP_NOINLINE
44#endif
45
46
47#ifdef __cplusplus
48 extern "C" {
49#endif
50
51#ifdef WOLFSSL_HAVE_SP_RSA
52
53WOLFSSL_LOCAL int sp_RsaPublic_2048(const byte* in, word32 inLen,
54 mp_int* em, mp_int* mm, byte* out, word32* outLen);
55WOLFSSL_LOCAL int sp_RsaPrivate_2048(const byte* in, word32 inLen,
56 mp_int* dm, mp_int* pm, mp_int* qm, mp_int* dpm, mp_int* dqm, mp_int* qim,
57 mp_int* mm, byte* out, word32* outLen);
58
59WOLFSSL_LOCAL int sp_RsaPublic_3072(const byte* in, word32 inLen,
60 mp_int* em, mp_int* mm, byte* out, word32* outLen);
61WOLFSSL_LOCAL int sp_RsaPrivate_3072(const byte* in, word32 inLen,
62 mp_int* dm, mp_int* pm, mp_int* qm, mp_int* dpm, mp_int* dqm, mp_int* qim,
63 mp_int* mm, byte* out, word32* outLen);
64
65WOLFSSL_LOCAL int sp_RsaPublic_4096(const byte* in, word32 inLen,
66 mp_int* em, mp_int* mm, byte* out, word32* outLen);
67WOLFSSL_LOCAL int sp_RsaPrivate_4096(const byte* in, word32 inLen,
68 mp_int* dm, mp_int* pm, mp_int* qm, mp_int* dpm, mp_int* dqm, mp_int* qim,
69 mp_int* mm, byte* out, word32* outLen);
70
71#endif /* WOLFSSL_HAVE_SP_RSA */
72
73#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
74
75WOLFSSL_LOCAL int sp_ModExp_1024(mp_int* base, mp_int* exp, mp_int* mod,
76 mp_int* res);
77WOLFSSL_LOCAL int sp_ModExp_1536(mp_int* base, mp_int* exp, mp_int* mod,
78 mp_int* res);
79WOLFSSL_LOCAL int sp_ModExp_2048(mp_int* base, mp_int* exp, mp_int* mod,
80 mp_int* res);
81WOLFSSL_LOCAL int sp_ModExp_3072(mp_int* base, mp_int* exp, mp_int* mod,
82 mp_int* res);
83WOLFSSL_LOCAL int sp_ModExp_4096(mp_int* base, mp_int* exp, mp_int* mod,
84 mp_int* res);
85
86#endif
87
88#ifdef WOLFSSL_HAVE_SP_DH
89
90WOLFSSL_LOCAL int sp_DhExp_2048(mp_int* base, const byte* exp, word32 expLen,
91 mp_int* mod, byte* out, word32* outLen);
92WOLFSSL_LOCAL int sp_DhExp_3072(mp_int* base, const byte* exp, word32 expLen,
93 mp_int* mod, byte* out, word32* outLen);
94WOLFSSL_LOCAL int sp_DhExp_4096(mp_int* base, const byte* exp, word32 expLen,
95 mp_int* mod, byte* out, word32* outLen);
96
97#endif /* WOLFSSL_HAVE_SP_DH */
98
99#ifdef WOLFSSL_HAVE_SP_ECC
100
101int sp_ecc_mulmod_256(mp_int* km, ecc_point* gm, ecc_point* rm, int map,
102 void* heap);
103int sp_ecc_mulmod_base_256(mp_int* km, ecc_point* rm, int map, void* heap);
104
105int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap);
106int sp_ecc_secret_gen_256(mp_int* priv, ecc_point* pub, byte* out,
107 word32* outlen, void* heap);
108int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
109 mp_int* rm, mp_int* sm, mp_int* km, void* heap);
110int sp_ecc_verify_256(const byte* hash, word32 hashLen, mp_int* pX, mp_int* pY,
111 mp_int* pZ, mp_int* r, mp_int* sm, int* res, void* heap);
112int sp_ecc_is_point_256(mp_int* pX, mp_int* pY);
113int sp_ecc_check_key_256(mp_int* pX, mp_int* pY, mp_int* privm, void* heap);
114int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ,
115 mp_int* qX, mp_int* qY, mp_int* qZ,
116 mp_int* rX, mp_int* rY, mp_int* rZ);
117int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ,
118 mp_int* rX, mp_int* rY, mp_int* rZ);
119int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ);
120int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym);
121
122
123int sp_ecc_mulmod_384(mp_int* km, ecc_point* gm, ecc_point* rm, int map,
124 void* heap);
125int sp_ecc_mulmod_base_384(mp_int* km, ecc_point* rm, int map, void* heap);
126
127int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap);
128int sp_ecc_secret_gen_384(mp_int* priv, ecc_point* pub, byte* out,
129 word32* outlen, void* heap);
130int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
131 mp_int* rm, mp_int* sm, mp_int* km, void* heap);
132int sp_ecc_verify_384(const byte* hash, word32 hashLen, mp_int* pX, mp_int* pY,
133 mp_int* pZ, mp_int* r, mp_int* sm, int* res, void* heap);
134int sp_ecc_is_point_384(mp_int* pX, mp_int* pY);
135int sp_ecc_check_key_384(mp_int* pX, mp_int* pY, mp_int* privm, void* heap);
136int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
137 mp_int* qX, mp_int* qY, mp_int* qZ,
138 mp_int* rX, mp_int* rY, mp_int* rZ);
139int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
140 mp_int* rX, mp_int* rY, mp_int* rZ);
141int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ);
142int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym);
143
144#endif /*ifdef WOLFSSL_HAVE_SP_ECC */
145
146
147#ifdef __cplusplus
148 } /* extern "C" */
149#endif
150
151#endif /* WOLFSSL_HAVE_SP_RSA || WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_ECC */
152
153#endif /* WOLF_CRYPT_SP_H */
154
Definition random.h:153
Definition ecc.h:332
Definition integer.h:200