Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
wolfssl/wolfcrypt/sp.h@16:048e5e270a58, 2019-11-19 (annotated)
- Committer:
- sPymbed
- Date:
- Tue Nov 19 14:32:16 2019 +0000
- Revision:
- 16:048e5e270a58
- Parent:
- 14:167253f4e170
working ssl
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 14:167253f4e170 | 1 | /* sp.h |
wolfSSL | 14:167253f4e170 | 2 | * |
wolfSSL | 14:167253f4e170 | 3 | * Copyright (C) 2006-2017 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 | 14:167253f4e170 | 40 | #elif defined(__GNUC__) |
wolfSSL | 14:167253f4e170 | 41 | #define SP_NOINLINE __attribute__((noinline)) |
wolfSSL | 14:167253f4e170 | 42 | #else |
wolfSSL | 14:167253f4e170 | 43 | #define 5P_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 | 14:167253f4e170 | 65 | #endif /* WOLFSSL_HAVE_SP_RSA */ |
wolfSSL | 14:167253f4e170 | 66 | |
wolfSSL | 14:167253f4e170 | 67 | #ifdef WOLFSSL_HAVE_SP_DH |
wolfSSL | 14:167253f4e170 | 68 | |
wolfSSL | 14:167253f4e170 | 69 | WOLFSSL_LOCAL int sp_ModExp_2048(mp_int* base, mp_int* exp, mp_int* mod, |
wolfSSL | 14:167253f4e170 | 70 | mp_int* res); |
wolfSSL | 14:167253f4e170 | 71 | WOLFSSL_LOCAL int sp_ModExp_3072(mp_int* base, mp_int* exp, mp_int* mod, |
wolfSSL | 14:167253f4e170 | 72 | mp_int* res); |
wolfSSL | 14:167253f4e170 | 73 | |
wolfSSL | 14:167253f4e170 | 74 | WOLFSSL_LOCAL int sp_DhExp_2048(mp_int* base, const byte* exp, word32 expLen, |
wolfSSL | 14:167253f4e170 | 75 | mp_int* mod, byte* out, word32* outLen); |
wolfSSL | 14:167253f4e170 | 76 | WOLFSSL_LOCAL int sp_DhExp_3072(mp_int* base, const byte* exp, word32 expLen, |
wolfSSL | 14:167253f4e170 | 77 | mp_int* mod, byte* out, word32* outLen); |
wolfSSL | 14:167253f4e170 | 78 | |
wolfSSL | 14:167253f4e170 | 79 | #endif /* WOLFSSL_HAVE_SP_DH */ |
wolfSSL | 14:167253f4e170 | 80 | |
wolfSSL | 14:167253f4e170 | 81 | #ifdef WOLFSSL_HAVE_SP_ECC |
wolfSSL | 14:167253f4e170 | 82 | |
wolfSSL | 14:167253f4e170 | 83 | int sp_ecc_mulmod_256(mp_int* km, ecc_point* gm, ecc_point* rm, int map, |
wolfSSL | 14:167253f4e170 | 84 | void* heap); |
wolfSSL | 14:167253f4e170 | 85 | int sp_ecc_mulmod_base_256(mp_int* km, ecc_point* rm, int map, void* heap); |
wolfSSL | 14:167253f4e170 | 86 | |
wolfSSL | 14:167253f4e170 | 87 | int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap); |
wolfSSL | 14:167253f4e170 | 88 | int sp_ecc_secret_gen_256(mp_int* priv, ecc_point* pub, byte* out, |
wolfSSL | 14:167253f4e170 | 89 | word32* outlen, void* heap); |
wolfSSL | 14:167253f4e170 | 90 | int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv, |
wolfSSL | 14:167253f4e170 | 91 | mp_int* rm, mp_int* sm, void* heap); |
wolfSSL | 14:167253f4e170 | 92 | int sp_ecc_verify_256(const byte* hash, word32 hashLen, mp_int* pX, mp_int* pY, |
wolfSSL | 14:167253f4e170 | 93 | mp_int* pZ, mp_int* r, mp_int* sm, int* res, void* heap); |
wolfSSL | 14:167253f4e170 | 94 | int sp_ecc_is_point_256(mp_int* pX, mp_int* pY); |
wolfSSL | 14:167253f4e170 | 95 | int sp_ecc_check_key_256(mp_int* pX, mp_int* pY, mp_int* privm, void* heap); |
wolfSSL | 14:167253f4e170 | 96 | int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, |
wolfSSL | 14:167253f4e170 | 97 | mp_int* qX, mp_int* qY, mp_int* qZ, |
wolfSSL | 14:167253f4e170 | 98 | mp_int* rX, mp_int* rY, mp_int* rZ); |
wolfSSL | 14:167253f4e170 | 99 | int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ, |
wolfSSL | 14:167253f4e170 | 100 | mp_int* rX, mp_int* rY, mp_int* rZ); |
wolfSSL | 14:167253f4e170 | 101 | int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ); |
wolfSSL | 14:167253f4e170 | 102 | int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym); |
wolfSSL | 14:167253f4e170 | 103 | |
wolfSSL | 14:167253f4e170 | 104 | #endif /*ifdef WOLFSSL_HAVE_SP_ECC */ |
wolfSSL | 14:167253f4e170 | 105 | |
wolfSSL | 14:167253f4e170 | 106 | |
wolfSSL | 14:167253f4e170 | 107 | #ifdef __cplusplus |
wolfSSL | 14:167253f4e170 | 108 | } /* extern "C" */ |
wolfSSL | 14:167253f4e170 | 109 | #endif |
wolfSSL | 14:167253f4e170 | 110 | |
wolfSSL | 14:167253f4e170 | 111 | #endif /* WOLFSSL_HAVE_SP_RSA || WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_ECC */ |
wolfSSL | 14:167253f4e170 | 112 | |
wolfSSL | 14:167253f4e170 | 113 | #endif /* WOLF_CRYPT_SP_H */ |
wolfSSL | 14:167253f4e170 | 114 | |
wolfSSL | 14:167253f4e170 | 115 |