wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Fri Jun 05 00:11:07 2020 +0000
Revision:
17:a5f916481144
Parent:
16:8e0d178b1d1e
wolfSSL 4.4.0

Who changed what in which revision?

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