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/cryptodev.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 | /* cryptodev.h |
wolfSSL | 14:167253f4e170 | 2 | * |
wolfSSL | 14:167253f4e170 | 3 | * Copyright (C) 2006-2018 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 3 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, see <http://www.gnu.org/licenses/>. |
wolfSSL | 14:167253f4e170 | 19 | */ |
wolfSSL | 14:167253f4e170 | 20 | |
wolfSSL | 14:167253f4e170 | 21 | #ifndef _WOLF_CRYPTO_DEV_H_ |
wolfSSL | 14:167253f4e170 | 22 | #define _WOLF_CRYPTO_DEV_H_ |
wolfSSL | 14:167253f4e170 | 23 | |
wolfSSL | 14:167253f4e170 | 24 | #include <wolfssl/wolfcrypt/types.h> |
wolfSSL | 14:167253f4e170 | 25 | |
wolfSSL | 14:167253f4e170 | 26 | #ifdef __cplusplus |
wolfSSL | 14:167253f4e170 | 27 | extern "C" { |
wolfSSL | 14:167253f4e170 | 28 | #endif |
wolfSSL | 14:167253f4e170 | 29 | |
wolfSSL | 14:167253f4e170 | 30 | #ifdef WOLF_CRYPTO_DEV |
wolfSSL | 14:167253f4e170 | 31 | |
wolfSSL | 14:167253f4e170 | 32 | #ifndef NO_RSA |
wolfSSL | 14:167253f4e170 | 33 | #include <wolfssl/wolfcrypt/rsa.h> |
wolfSSL | 14:167253f4e170 | 34 | #endif |
wolfSSL | 14:167253f4e170 | 35 | #ifdef HAVE_ECC |
wolfSSL | 14:167253f4e170 | 36 | #include <wolfssl/wolfcrypt/ecc.h> |
wolfSSL | 14:167253f4e170 | 37 | #endif |
wolfSSL | 14:167253f4e170 | 38 | |
wolfSSL | 14:167253f4e170 | 39 | /* Crypto Information Structure for callbacks */ |
wolfSSL | 14:167253f4e170 | 40 | typedef struct wc_CryptoInfo { |
wolfSSL | 14:167253f4e170 | 41 | int algo_type; /* enum wc_AlgoType */ |
wolfSSL | 14:167253f4e170 | 42 | struct { |
wolfSSL | 14:167253f4e170 | 43 | int type; /* enum wc_PkType */ |
wolfSSL | 14:167253f4e170 | 44 | union { |
wolfSSL | 14:167253f4e170 | 45 | #ifndef NO_RSA |
wolfSSL | 14:167253f4e170 | 46 | struct { |
wolfSSL | 14:167253f4e170 | 47 | const byte* in; |
wolfSSL | 14:167253f4e170 | 48 | word32 inLen; |
wolfSSL | 14:167253f4e170 | 49 | byte* out; |
wolfSSL | 14:167253f4e170 | 50 | word32* outLen; |
wolfSSL | 14:167253f4e170 | 51 | int type; |
wolfSSL | 14:167253f4e170 | 52 | RsaKey* key; |
wolfSSL | 14:167253f4e170 | 53 | WC_RNG* rng; |
wolfSSL | 14:167253f4e170 | 54 | } rsa; |
wolfSSL | 14:167253f4e170 | 55 | #endif |
wolfSSL | 14:167253f4e170 | 56 | #ifdef HAVE_ECC |
wolfSSL | 14:167253f4e170 | 57 | struct { |
wolfSSL | 14:167253f4e170 | 58 | ecc_key* private_key; |
wolfSSL | 14:167253f4e170 | 59 | ecc_key* public_key; |
wolfSSL | 14:167253f4e170 | 60 | byte* out; |
wolfSSL | 14:167253f4e170 | 61 | word32* outlen; |
wolfSSL | 14:167253f4e170 | 62 | } ecdh; |
wolfSSL | 14:167253f4e170 | 63 | struct { |
wolfSSL | 14:167253f4e170 | 64 | const byte* in; |
wolfSSL | 14:167253f4e170 | 65 | word32 inlen; |
wolfSSL | 14:167253f4e170 | 66 | byte* out; |
wolfSSL | 14:167253f4e170 | 67 | word32 *outlen; |
wolfSSL | 14:167253f4e170 | 68 | WC_RNG* rng; |
wolfSSL | 14:167253f4e170 | 69 | ecc_key* key; |
wolfSSL | 14:167253f4e170 | 70 | } eccsign; |
wolfSSL | 14:167253f4e170 | 71 | struct { |
wolfSSL | 14:167253f4e170 | 72 | const byte* sig; |
wolfSSL | 14:167253f4e170 | 73 | word32 siglen; |
wolfSSL | 14:167253f4e170 | 74 | const byte* hash; |
wolfSSL | 14:167253f4e170 | 75 | word32 hashlen; |
wolfSSL | 14:167253f4e170 | 76 | int* res; |
wolfSSL | 14:167253f4e170 | 77 | ecc_key* key; |
wolfSSL | 14:167253f4e170 | 78 | } eccverify; |
wolfSSL | 14:167253f4e170 | 79 | #endif |
wolfSSL | 14:167253f4e170 | 80 | }; |
wolfSSL | 14:167253f4e170 | 81 | } pk; |
wolfSSL | 14:167253f4e170 | 82 | } wc_CryptoInfo; |
wolfSSL | 14:167253f4e170 | 83 | |
wolfSSL | 14:167253f4e170 | 84 | typedef int (*CryptoDevCallbackFunc)(int devId, wc_CryptoInfo* info, void* ctx); |
wolfSSL | 14:167253f4e170 | 85 | |
wolfSSL | 14:167253f4e170 | 86 | WOLFSSL_LOCAL void wc_CryptoDev_Init(void); |
wolfSSL | 14:167253f4e170 | 87 | |
wolfSSL | 14:167253f4e170 | 88 | WOLFSSL_API int wc_CryptoDev_RegisterDevice(int devId, CryptoDevCallbackFunc cb, void* ctx); |
wolfSSL | 14:167253f4e170 | 89 | WOLFSSL_API void wc_CryptoDev_UnRegisterDevice(int devId); |
wolfSSL | 14:167253f4e170 | 90 | |
wolfSSL | 14:167253f4e170 | 91 | |
wolfSSL | 14:167253f4e170 | 92 | #ifndef NO_RSA |
wolfSSL | 14:167253f4e170 | 93 | WOLFSSL_LOCAL int wc_CryptoDev_Rsa(const byte* in, word32 inLen, byte* out, |
wolfSSL | 14:167253f4e170 | 94 | word32* outLen, int type, RsaKey* key, WC_RNG* rng); |
wolfSSL | 14:167253f4e170 | 95 | #endif /* !NO_RSA */ |
wolfSSL | 14:167253f4e170 | 96 | |
wolfSSL | 14:167253f4e170 | 97 | #ifdef HAVE_ECC |
wolfSSL | 14:167253f4e170 | 98 | WOLFSSL_LOCAL int wc_CryptoDev_Ecdh(ecc_key* private_key, ecc_key* public_key, |
wolfSSL | 14:167253f4e170 | 99 | byte* out, word32* outlen); |
wolfSSL | 14:167253f4e170 | 100 | |
wolfSSL | 14:167253f4e170 | 101 | WOLFSSL_LOCAL int wc_CryptoDev_EccSign(const byte* in, word32 inlen, byte* out, |
wolfSSL | 14:167253f4e170 | 102 | word32 *outlen, WC_RNG* rng, ecc_key* key); |
wolfSSL | 14:167253f4e170 | 103 | |
wolfSSL | 14:167253f4e170 | 104 | WOLFSSL_LOCAL int wc_CryptoDev_EccVerify(const byte* sig, word32 siglen, |
wolfSSL | 14:167253f4e170 | 105 | const byte* hash, word32 hashlen, int* res, ecc_key* key); |
wolfSSL | 14:167253f4e170 | 106 | #endif /* HAVE_ECC */ |
wolfSSL | 14:167253f4e170 | 107 | |
wolfSSL | 14:167253f4e170 | 108 | #endif /* WOLF_CRYPTO_DEV */ |
wolfSSL | 14:167253f4e170 | 109 | |
wolfSSL | 14:167253f4e170 | 110 | #ifdef __cplusplus |
wolfSSL | 14:167253f4e170 | 111 | } /* extern "C" */ |
wolfSSL | 14:167253f4e170 | 112 | #endif |
wolfSSL | 14:167253f4e170 | 113 | |
wolfSSL | 14:167253f4e170 | 114 | #endif /* _WOLF_CRYPTO_DEV_H_ */ |
wolfSSL | 14:167253f4e170 | 115 |