sp.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. /* sp.h
  2. *
  3. * Copyright (C) 2006-2023 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. #ifndef WOLF_CRYPT_SP_H
  22. #define WOLF_CRYPT_SP_H
  23. #include <wolfssl/wolfcrypt/types.h>
  24. #if defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH) || \
  25. defined(WOLFSSL_HAVE_SP_ECC)
  26. #ifdef _WIN32_WCE
  27. typedef __int8 int8_t;
  28. typedef __int32 int32_t;
  29. typedef __int64 int64_t;
  30. typedef unsigned __int8 uint8_t;
  31. typedef unsigned __int32 uint32_t;
  32. typedef unsigned __int64 uint64_t;
  33. #elif !defined(WOLFSSL_LINUXKM)
  34. #include <stdint.h>
  35. #endif
  36. #include <wolfssl/wolfcrypt/wolfmath.h>
  37. #include <wolfssl/wolfcrypt/sp_int.h>
  38. #include <wolfssl/wolfcrypt/ecc.h>
  39. #ifdef noinline
  40. #define SP_NOINLINE noinline
  41. #elif defined(_MSC_VER)
  42. #define SP_NOINLINE __declspec(noinline)
  43. #elif defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__)
  44. #define SP_NOINLINE _Pragma("inline = never")
  45. #elif defined(__GNUC__) || defined(__KEIL__) || defined(__DCC__)
  46. #define SP_NOINLINE __attribute__((noinline))
  47. #else
  48. #define SP_NOINLINE
  49. #endif
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. #ifdef WOLFSSL_HAVE_SP_RSA
  54. /* non-const versions only needed for inlined ARM assembly */
  55. #if defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION == 2 \
  56. && ( defined(WOLFSSL_SP_ARM32_ASM) || defined(WOLFSSL_SP_ARM64_ASM) )
  57. WOLFSSL_LOCAL int sp_RsaPublic_2048(const byte* in, word32 inLen,
  58. mp_int* em, mp_int* mm, byte* out, word32* outLen);
  59. WOLFSSL_LOCAL int sp_RsaPrivate_2048(const byte* in, word32 inLen,
  60. mp_int* dm, mp_int* pm, mp_int* qm, mp_int* dpm, mp_int* dqm, mp_int* qim,
  61. mp_int* mm, byte* out, word32* outLen);
  62. WOLFSSL_LOCAL int sp_RsaPublic_3072(const byte* in, word32 inLen,
  63. mp_int* em, mp_int* mm, byte* out, word32* outLen);
  64. WOLFSSL_LOCAL int sp_RsaPrivate_3072(const byte* in, word32 inLen,
  65. mp_int* dm, mp_int* pm, mp_int* qm, mp_int* dpm, mp_int* dqm, mp_int* qim,
  66. mp_int* mm, byte* out, word32* outLen);
  67. WOLFSSL_LOCAL int sp_RsaPublic_4096(const byte* in, word32 inLen,
  68. mp_int* em, mp_int* mm, byte* out, word32* outLen);
  69. WOLFSSL_LOCAL int sp_RsaPrivate_4096(const byte* in, word32 inLen,
  70. mp_int* dm, mp_int* pm, mp_int* qm, mp_int* dpm, mp_int* dqm, mp_int* qim,
  71. mp_int* mm, byte* out, word32* outLen);
  72. #else
  73. WOLFSSL_LOCAL int sp_RsaPublic_2048(const byte* in, word32 inLen,
  74. const mp_int* em, const mp_int* mm, byte* out, word32* outLen);
  75. WOLFSSL_LOCAL int sp_RsaPrivate_2048(const byte* in, word32 inLen,
  76. const mp_int* dm, const mp_int* pm, const mp_int* qm, const mp_int* dpm,
  77. const mp_int* dqm, const mp_int* qim, const mp_int* mm, byte* out,
  78. word32* outLen);
  79. WOLFSSL_LOCAL int sp_RsaPublic_3072(const byte* in, word32 inLen,
  80. const mp_int* em, const mp_int* mm, byte* out, word32* outLen);
  81. WOLFSSL_LOCAL int sp_RsaPrivate_3072(const byte* in, word32 inLen,
  82. const mp_int* dm, const mp_int* pm, const mp_int* qm, const mp_int* dpm,
  83. const mp_int* dqm, const mp_int* qim, const mp_int* mm, byte* out,
  84. word32* outLen);
  85. WOLFSSL_LOCAL int sp_RsaPublic_4096(const byte* in, word32 inLen,
  86. const mp_int* em, const mp_int* mm, byte* out, word32* outLen);
  87. WOLFSSL_LOCAL int sp_RsaPrivate_4096(const byte* in, word32 inLen,
  88. const mp_int* dm, const mp_int* pm, const mp_int* qm, const mp_int* dpm,
  89. const mp_int* dqm, const mp_int* qim, const mp_int* mm, byte* out,
  90. word32* outLen);
  91. #endif /* HAVE_FIPS_VERSION && HAVE_FIPS_VERSION == 2 && !WOLFSSL_SP_ARM[32|64]_ASM */
  92. #endif /* WOLFSSL_HAVE_SP_RSA */
  93. #if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
  94. /* non-const versions only needed for inlined ARM assembly */
  95. #if defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION == 2 \
  96. && ( defined(WOLFSSL_SP_ARM32_ASM) || defined(WOLFSSL_SP_ARM64_ASM) )
  97. WOLFSSL_LOCAL int sp_ModExp_1024(mp_int* base, mp_int* exp, mp_int* mod,
  98. mp_int* res);
  99. WOLFSSL_LOCAL int sp_ModExp_1536(mp_int* base, mp_int* exp, mp_int* mod,
  100. mp_int* res);
  101. WOLFSSL_LOCAL int sp_ModExp_2048(mp_int* base, mp_int* exp, mp_int* mod,
  102. mp_int* res);
  103. WOLFSSL_LOCAL int sp_ModExp_3072(mp_int* base, mp_int* exp, mp_int* mod,
  104. mp_int* res);
  105. WOLFSSL_LOCAL int sp_ModExp_4096(mp_int* base, mp_int* exp, mp_int* mod,
  106. mp_int* res);
  107. #else
  108. WOLFSSL_LOCAL int sp_ModExp_1024(const mp_int* base, const mp_int* exp,
  109. const mp_int* mod, mp_int* res);
  110. WOLFSSL_LOCAL int sp_ModExp_1536(const mp_int* base, const mp_int* exp,
  111. const mp_int* mod, mp_int* res);
  112. WOLFSSL_LOCAL int sp_ModExp_2048(const mp_int* base, const mp_int* exp,
  113. const mp_int* mod, mp_int* res);
  114. WOLFSSL_LOCAL int sp_ModExp_3072(const mp_int* base, const mp_int* exp,
  115. const mp_int* mod, mp_int* res);
  116. WOLFSSL_LOCAL int sp_ModExp_4096(const mp_int* base, const mp_int* exp,
  117. const mp_int* mod, mp_int* res);
  118. #endif /* HAVE_FIPS_VERSION && HAVE_FIPS_VERSION == 2 && !WOLFSSL_SP_ARM[32|64]_ASM */
  119. #endif
  120. #ifdef WOLFSSL_HAVE_SP_DH
  121. /* non-const versions only needed for inlined ARM assembly */
  122. #if defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION == 2 \
  123. && ( defined(WOLFSSL_SP_ARM32_ASM) || defined(WOLFSSL_SP_ARM64_ASM) )
  124. WOLFSSL_LOCAL int sp_DhExp_2048(mp_int* base, const byte* exp, word32 expLen,
  125. mp_int* mod, byte* out, word32* outLen);
  126. WOLFSSL_LOCAL int sp_DhExp_3072(mp_int* base, const byte* exp, word32 expLen,
  127. mp_int* mod, byte* out, word32* outLen);
  128. WOLFSSL_LOCAL int sp_DhExp_4096(mp_int* base, const byte* exp, word32 expLen,
  129. mp_int* mod, byte* out, word32* outLen);
  130. #else
  131. WOLFSSL_LOCAL int sp_DhExp_2048(const mp_int* base, const byte* exp,
  132. word32 expLen, const mp_int* mod, byte* out, word32* outLen);
  133. WOLFSSL_LOCAL int sp_DhExp_3072(const mp_int* base, const byte* exp,
  134. word32 expLen, const mp_int* mod, byte* out, word32* outLen);
  135. WOLFSSL_LOCAL int sp_DhExp_4096(const mp_int* base, const byte* exp,
  136. word32 expLen, const mp_int* mod, byte* out, word32* outLen);
  137. #endif /* HAVE_FIPS_VERSION && HAVE_FIPS_VERSION == 2 && !WOLFSSL_SP_ARM[32|64]_ASM */
  138. #endif /* WOLFSSL_HAVE_SP_DH */
  139. #ifdef WOLFSSL_HAVE_SP_ECC
  140. /* non-const versions only needed for inlined ARM assembly */
  141. #if defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION == 2 \
  142. && ( defined(WOLFSSL_SP_ARM32_ASM) || defined(WOLFSSL_SP_ARM64_ASM) )
  143. int sp_ecc_mulmod_256(mp_int* km, ecc_point* gm, ecc_point* rm, int map,
  144. void* heap);
  145. int sp_ecc_mulmod_base_256(mp_int* km, ecc_point* rm, int map, void* heap);
  146. int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap);
  147. int sp_ecc_secret_gen_256(mp_int* priv, ecc_point* pub, byte* out,
  148. word32* outlen, void* heap);
  149. int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
  150. mp_int* rm, mp_int* sm, mp_int* km, void* heap);
  151. int sp_ecc_verify_256(const byte* hash, word32 hashLen, mp_int* pX, mp_int* pY,
  152. mp_int* pZ, mp_int* r, mp_int* sm, int* res, void* heap);
  153. int sp_ecc_is_point_256(mp_int* pX, mp_int* pY);
  154. int sp_ecc_check_key_256(mp_int* pX, mp_int* pY, mp_int* privm, void* heap);
  155. int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ,
  156. mp_int* qX, mp_int* qY, mp_int* qZ,
  157. mp_int* rX, mp_int* rY, mp_int* rZ);
  158. int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ,
  159. mp_int* rX, mp_int* rY, mp_int* rZ);
  160. int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ);
  161. int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym);
  162. int sp_ecc_mulmod_384(mp_int* km, ecc_point* gm, ecc_point* rm, int map,
  163. void* heap);
  164. int sp_ecc_mulmod_base_384(mp_int* km, ecc_point* rm, int map, void* heap);
  165. int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap);
  166. int sp_ecc_secret_gen_384(mp_int* priv, ecc_point* pub, byte* out,
  167. word32* outlen, void* heap);
  168. int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
  169. mp_int* rm, mp_int* sm, mp_int* km, void* heap);
  170. int sp_ecc_verify_384(const byte* hash, word32 hashLen, mp_int* pX, mp_int* pY,
  171. mp_int* pZ, mp_int* r, mp_int* sm, int* res, void* heap);
  172. int sp_ecc_is_point_384(mp_int* pX, mp_int* pY);
  173. int sp_ecc_check_key_384(mp_int* pX, mp_int* pY, mp_int* privm, void* heap);
  174. int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
  175. mp_int* qX, mp_int* qY, mp_int* qZ,
  176. mp_int* rX, mp_int* rY, mp_int* rZ);
  177. int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
  178. mp_int* rX, mp_int* rY, mp_int* rZ);
  179. int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ);
  180. int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym);
  181. #else
  182. WOLFSSL_LOCAL int sp_ecc_mulmod_256(const mp_int* km, const ecc_point* gm,
  183. ecc_point* rm, int map, void* heap);
  184. WOLFSSL_LOCAL int sp_ecc_mulmod_add_256(const mp_int* km, const ecc_point* gm,
  185. const ecc_point* am, int inMont, ecc_point* rm, int map, void* heap);
  186. WOLFSSL_LOCAL int sp_ecc_mulmod_base_256(const mp_int* km, ecc_point* rm,
  187. int map, void* heap);
  188. WOLFSSL_LOCAL int sp_ecc_mulmod_base_add_256(const mp_int* km,
  189. const ecc_point* am, int inMont, ecc_point* rm, int map, void* heap);
  190. WOLFSSL_LOCAL int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub,
  191. void* heap);
  192. WOLFSSL_LOCAL int sp_ecc_secret_gen_256(const mp_int* priv,
  193. const ecc_point* pub, byte* out, word32* outlen, void* heap);
  194. WOLFSSL_LOCAL int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng,
  195. const mp_int* priv, mp_int* rm, mp_int* sm, mp_int* km, void* heap);
  196. WOLFSSL_LOCAL int sp_ecc_verify_256(const byte* hash, word32 hashLen,
  197. const mp_int* pX, const mp_int* pY, const mp_int* pZ, const mp_int* r,
  198. const mp_int* sm, int* res, void* heap);
  199. WOLFSSL_LOCAL int sp_ecc_is_point_256(const mp_int* pX, const mp_int* pY);
  200. WOLFSSL_LOCAL int sp_ecc_check_key_256(const mp_int* pX, const mp_int* pY,
  201. const mp_int* privm, void* heap);
  202. WOLFSSL_LOCAL int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ,
  203. mp_int* qX, mp_int* qY, mp_int* qZ, mp_int* rX, mp_int* rY, mp_int* rZ);
  204. WOLFSSL_LOCAL int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ,
  205. mp_int* rX, mp_int* rY, mp_int* rZ);
  206. WOLFSSL_LOCAL int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ);
  207. WOLFSSL_LOCAL int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym);
  208. WOLFSSL_LOCAL int sp_ecc_mulmod_384(const mp_int* km, const ecc_point* gm,
  209. ecc_point* rm, int map, void* heap);
  210. WOLFSSL_LOCAL int sp_ecc_mulmod_add_384(const mp_int* km, const ecc_point* gm,
  211. const ecc_point* am, int inMont, ecc_point* rm, int map, void* heap);
  212. WOLFSSL_LOCAL int sp_ecc_mulmod_base_384(const mp_int* km, ecc_point* rm,
  213. int map, void* heap);
  214. WOLFSSL_LOCAL int sp_ecc_mulmod_base_add_384(const mp_int* km,
  215. const ecc_point* am, int inMont, ecc_point* rm, int map, void* heap);
  216. WOLFSSL_LOCAL int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap);
  217. WOLFSSL_LOCAL int sp_ecc_secret_gen_384(const mp_int* priv,
  218. const ecc_point* pub, byte* out, word32* outlen, void* heap);
  219. WOLFSSL_LOCAL int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng,
  220. const mp_int* priv, mp_int* rm, mp_int* sm, mp_int* km, void* heap);
  221. WOLFSSL_LOCAL int sp_ecc_verify_384(const byte* hash, word32 hashLen,
  222. const mp_int* pX, const mp_int* pY, const mp_int* pZ, const mp_int* r,
  223. const mp_int* sm, int* res, void* heap);
  224. WOLFSSL_LOCAL int sp_ecc_is_point_384(const mp_int* pX, const mp_int* pY);
  225. WOLFSSL_LOCAL int sp_ecc_check_key_384(const mp_int* pX, const mp_int* pY,
  226. const mp_int* privm, void* heap);
  227. WOLFSSL_LOCAL int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
  228. mp_int* qX, mp_int* qY, mp_int* qZ, mp_int* rX, mp_int* rY, mp_int* rZ);
  229. WOLFSSL_LOCAL int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
  230. mp_int* rX, mp_int* rY, mp_int* rZ);
  231. WOLFSSL_LOCAL int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ);
  232. WOLFSSL_LOCAL int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym);
  233. WOLFSSL_LOCAL int sp_ecc_mulmod_521(const mp_int* km, const ecc_point* gm,
  234. ecc_point* rm, int map, void* heap);
  235. WOLFSSL_LOCAL int sp_ecc_mulmod_add_521(const mp_int* km, const ecc_point* gm,
  236. const ecc_point* am, int inMont, ecc_point* rm, int map, void* heap);
  237. WOLFSSL_LOCAL int sp_ecc_mulmod_base_521(const mp_int* km, ecc_point* rm,
  238. int map, void* heap);
  239. WOLFSSL_LOCAL int sp_ecc_mulmod_base_add_521(const mp_int* km,
  240. const ecc_point* am, int inMont, ecc_point* rm, int map, void* heap);
  241. WOLFSSL_LOCAL int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap);
  242. WOLFSSL_LOCAL int sp_ecc_secret_gen_521(const mp_int* priv,
  243. const ecc_point* pub, byte* out, word32* outlen, void* heap);
  244. WOLFSSL_LOCAL int sp_ecc_sign_521(const byte* hash, word32 hashLen, WC_RNG* rng,
  245. const mp_int* priv, mp_int* rm, mp_int* sm, mp_int* km, void* heap);
  246. WOLFSSL_LOCAL int sp_ecc_verify_521(const byte* hash, word32 hashLen,
  247. const mp_int* pX, const mp_int* pY, const mp_int* pZ, const mp_int* r,
  248. const mp_int* sm, int* res, void* heap);
  249. WOLFSSL_LOCAL int sp_ecc_is_point_521(const mp_int* pX, const mp_int* pY);
  250. WOLFSSL_LOCAL int sp_ecc_check_key_521(const mp_int* pX, const mp_int* pY,
  251. const mp_int* privm, void* heap);
  252. WOLFSSL_LOCAL int sp_ecc_proj_add_point_521(mp_int* pX, mp_int* pY, mp_int* pZ,
  253. mp_int* qX, mp_int* qY, mp_int* qZ, mp_int* rX, mp_int* rY, mp_int* rZ);
  254. WOLFSSL_LOCAL int sp_ecc_proj_dbl_point_521(mp_int* pX, mp_int* pY, mp_int* pZ,
  255. mp_int* rX, mp_int* rY, mp_int* rZ);
  256. WOLFSSL_LOCAL int sp_ecc_map_521(mp_int* pX, mp_int* pY, mp_int* pZ);
  257. WOLFSSL_LOCAL int sp_ecc_uncompress_521(mp_int* xm, int odd, mp_int* ym);
  258. WOLFSSL_LOCAL int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm,
  259. ecc_point* rm, int map, void* heap);
  260. WOLFSSL_LOCAL int sp_ecc_mulmod_base_1024(const mp_int* km, ecc_point* rm,
  261. int map, void* heap);
  262. WOLFSSL_LOCAL int sp_ecc_mulmod_base_add_1024(const mp_int* km,
  263. const ecc_point* am, int inMont, ecc_point* rm, int map, void* heap);
  264. WOLFSSL_LOCAL int sp_ecc_gen_table_1024(const ecc_point* gm, byte* table,
  265. word32* len, void* heap);
  266. WOLFSSL_LOCAL int sp_ecc_mulmod_table_1024(const mp_int* km,
  267. const ecc_point* gm, byte* table, ecc_point* r, int map, void* heap);
  268. WOLFSSL_LOCAL int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp,
  269. mp_int* res);
  270. WOLFSSL_LOCAL int sp_Pairing_1024(const ecc_point* p, const ecc_point* q,
  271. mp_int* res);
  272. WOLFSSL_LOCAL int sp_Pairing_gen_precomp_1024(const ecc_point* p, byte* table,
  273. word32* len);
  274. WOLFSSL_LOCAL int sp_Pairing_precomp_1024(const ecc_point* p,
  275. const ecc_point* q, mp_int* res, const byte* table, word32 len);
  276. WOLFSSL_LOCAL int sp_ecc_is_point_1024(const mp_int* pX, const mp_int* pY);
  277. WOLFSSL_LOCAL int sp_ecc_check_key_1024(const mp_int* pX, const mp_int* pY,
  278. const mp_int* privm, void* heap);
  279. #endif /* HAVE_FIPS_VERSION && HAVE_FIPS_VERSION == 2 && !WOLFSSL_SP_ARM[32|64]_ASM */
  280. #ifdef WOLFSSL_SP_NONBLOCK
  281. WOLFSSL_LOCAL int sp_ecc_make_key_256_nb(sp_ecc_ctx_t* sp_ctx, WC_RNG* rng,
  282. mp_int* priv, ecc_point* pub, void* heap);
  283. WOLFSSL_LOCAL int sp_ecc_secret_gen_256_nb(sp_ecc_ctx_t* sp_ctx,
  284. const mp_int* priv, const ecc_point* pub, byte* out, word32* outLen,
  285. void* heap);
  286. WOLFSSL_LOCAL int sp_ecc_sign_256_nb(sp_ecc_ctx_t* ctx, const byte* hash,
  287. word32 hashLen, WC_RNG* rng, mp_int* priv, mp_int* rm, mp_int* sm,
  288. mp_int* km, void* heap);
  289. WOLFSSL_LOCAL int sp_ecc_verify_256_nb(sp_ecc_ctx_t* ctx, const byte* hash,
  290. word32 hashLen, const mp_int* pX, const mp_int* pY, const mp_int* pZ,
  291. const mp_int* r, const mp_int* sm, int* res, void* heap);
  292. WOLFSSL_LOCAL int sp_ecc_make_key_384_nb(sp_ecc_ctx_t* sp_ctx, WC_RNG* rng,
  293. mp_int* priv, ecc_point* pub, void* heap);
  294. WOLFSSL_LOCAL int sp_ecc_secret_gen_384_nb(sp_ecc_ctx_t* sp_ctx,
  295. const mp_int* priv, const ecc_point* pub, byte* out, word32* outLen,
  296. void* heap);
  297. WOLFSSL_LOCAL int sp_ecc_sign_384_nb(sp_ecc_ctx_t* ctx, const byte* hash,
  298. word32 hashLen, WC_RNG* rng, mp_int* priv, mp_int* rm, mp_int* sm,
  299. mp_int* km, void* heap);
  300. WOLFSSL_LOCAL int sp_ecc_verify_384_nb(sp_ecc_ctx_t* ctx, const byte* hash,
  301. word32 hashLen, const mp_int* pX, const mp_int* pY, const mp_int* pZ,
  302. const mp_int* r, const mp_int* sm, int* res, void* heap);
  303. WOLFSSL_LOCAL int sp_ecc_make_key_521_nb(sp_ecc_ctx_t* sp_ctx, WC_RNG* rng,
  304. mp_int* priv, ecc_point* pub, void* heap);
  305. WOLFSSL_LOCAL int sp_ecc_secret_gen_521_nb(sp_ecc_ctx_t* sp_ctx,
  306. const mp_int* priv, const ecc_point* pub, byte* out, word32* outLen,
  307. void* heap);
  308. WOLFSSL_LOCAL int sp_ecc_sign_521_nb(sp_ecc_ctx_t* ctx, const byte* hash,
  309. word32 hashLen, WC_RNG* rng, mp_int* priv, mp_int* rm, mp_int* sm,
  310. mp_int* km, void* heap);
  311. WOLFSSL_LOCAL int sp_ecc_verify_521_nb(sp_ecc_ctx_t* ctx, const byte* hash,
  312. word32 hashLen, const mp_int* pX, const mp_int* pY, const mp_int* pZ,
  313. const mp_int* r, const mp_int* sm, int* res, void* heap);
  314. #endif /* WOLFSSL_SP_NONBLOCK */
  315. #ifdef HAVE_ECC_SM2
  316. WOLFSSL_LOCAL int sp_ecc_mulmod_sm2_256(mp_int* km, ecc_point* gm,
  317. ecc_point* rm, int map, void* heap);
  318. WOLFSSL_LOCAL int sp_ecc_mulmod_base_sm2_256(mp_int* km, ecc_point* rm, int map,
  319. void* heap);
  320. WOLFSSL_LOCAL int sp_ecc_make_key_sm2_256(WC_RNG* rng, mp_int* priv,
  321. ecc_point* pub, void* heap);
  322. WOLFSSL_LOCAL int sp_ecc_secret_gen_sm2_256(mp_int* priv, ecc_point* pub,
  323. byte* out, word32* outlen, void* heap);
  324. WOLFSSL_LOCAL int sp_ecc_sign_sm2_256(const byte* hash, word32 hashLen,
  325. WC_RNG* rng, mp_int* priv, mp_int* rm, mp_int* sm, mp_int* km, void* heap);
  326. WOLFSSL_LOCAL int sp_ecc_verify_sm2_256(const byte* hash, word32 hashLen,
  327. mp_int* pX, mp_int* pY, mp_int* pZ, mp_int* r, mp_int* sm, int* res,
  328. void* heap);
  329. WOLFSSL_LOCAL int sp_ecc_is_point_sm2_256(mp_int* pX, mp_int* pY);
  330. WOLFSSL_LOCAL int sp_ecc_check_key_sm2_256(mp_int* pX, mp_int* pY,
  331. mp_int* privm, void* heap);
  332. WOLFSSL_LOCAL int sp_ecc_proj_add_point_sm2_256(mp_int* pX, mp_int* pY,
  333. mp_int* pZ, mp_int* qX, mp_int* qY, mp_int* qZ, mp_int* rX, mp_int* rY,
  334. mp_int* rZ);
  335. WOLFSSL_LOCAL int sp_ecc_proj_dbl_point_sm2_256(mp_int* pX, mp_int* pY,
  336. mp_int* pZ, mp_int* rX, mp_int* rY, mp_int* rZ);
  337. WOLFSSL_LOCAL int sp_ecc_map_sm2_256(mp_int* pX, mp_int* pY, mp_int* pZ);
  338. WOLFSSL_LOCAL int sp_ecc_uncompress_sm2_256(mp_int* xm, int odd, mp_int* ym);
  339. #endif
  340. #endif /* WOLFSSL_HAVE_SP_ECC */
  341. #ifdef __cplusplus
  342. } /* extern "C" */
  343. #endif
  344. #endif /* WOLFSSL_HAVE_SP_RSA || WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_ECC */
  345. #endif /* WOLF_CRYPT_SP_H */