wolfSSL SSL/TLS library, support up to TLS1.3
Dependents: CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more
wolfssl/wolfcrypt/dh.h@13:f67a6c6013ca, 2017-08-22 (annotated)
- Committer:
- wolfSSL
- Date:
- Tue Aug 22 10:48:22 2017 +0000
- Revision:
- 13:f67a6c6013ca
wolfSSL3.12.0 with TLS1.3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 13:f67a6c6013ca | 1 | /* dh.h |
wolfSSL | 13:f67a6c6013ca | 2 | * |
wolfSSL | 13:f67a6c6013ca | 3 | * Copyright (C) 2006-2016 wolfSSL Inc. |
wolfSSL | 13:f67a6c6013ca | 4 | * |
wolfSSL | 13:f67a6c6013ca | 5 | * This file is part of wolfSSL. |
wolfSSL | 13:f67a6c6013ca | 6 | * |
wolfSSL | 13:f67a6c6013ca | 7 | * wolfSSL is free software; you can redistribute it and/or modify |
wolfSSL | 13:f67a6c6013ca | 8 | * it under the terms of the GNU General Public License as published by |
wolfSSL | 13:f67a6c6013ca | 9 | * the Free Software Foundation; either version 2 of the License, or |
wolfSSL | 13:f67a6c6013ca | 10 | * (at your option) any later version. |
wolfSSL | 13:f67a6c6013ca | 11 | * |
wolfSSL | 13:f67a6c6013ca | 12 | * wolfSSL is distributed in the hope that it will be useful, |
wolfSSL | 13:f67a6c6013ca | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wolfSSL | 13:f67a6c6013ca | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wolfSSL | 13:f67a6c6013ca | 15 | * GNU General Public License for more details. |
wolfSSL | 13:f67a6c6013ca | 16 | * |
wolfSSL | 13:f67a6c6013ca | 17 | * You should have received a copy of the GNU General Public License |
wolfSSL | 13:f67a6c6013ca | 18 | * along with this program; if not, write to the Free Software |
wolfSSL | 13:f67a6c6013ca | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
wolfSSL | 13:f67a6c6013ca | 20 | */ |
wolfSSL | 13:f67a6c6013ca | 21 | |
wolfSSL | 13:f67a6c6013ca | 22 | |
wolfSSL | 13:f67a6c6013ca | 23 | #ifndef WOLF_CRYPT_DH_H |
wolfSSL | 13:f67a6c6013ca | 24 | #define WOLF_CRYPT_DH_H |
wolfSSL | 13:f67a6c6013ca | 25 | |
wolfSSL | 13:f67a6c6013ca | 26 | #include <wolfssl/wolfcrypt/types.h> |
wolfSSL | 13:f67a6c6013ca | 27 | |
wolfSSL | 13:f67a6c6013ca | 28 | #ifndef NO_DH |
wolfSSL | 13:f67a6c6013ca | 29 | |
wolfSSL | 13:f67a6c6013ca | 30 | #include <wolfssl/wolfcrypt/integer.h> |
wolfSSL | 13:f67a6c6013ca | 31 | #include <wolfssl/wolfcrypt/random.h> |
wolfSSL | 13:f67a6c6013ca | 32 | |
wolfSSL | 13:f67a6c6013ca | 33 | #ifdef __cplusplus |
wolfSSL | 13:f67a6c6013ca | 34 | extern "C" { |
wolfSSL | 13:f67a6c6013ca | 35 | #endif |
wolfSSL | 13:f67a6c6013ca | 36 | |
wolfSSL | 13:f67a6c6013ca | 37 | #ifdef WOLFSSL_ASYNC_CRYPT |
wolfSSL | 13:f67a6c6013ca | 38 | #include <wolfssl/wolfcrypt/async.h> |
wolfSSL | 13:f67a6c6013ca | 39 | #endif |
wolfSSL | 13:f67a6c6013ca | 40 | typedef struct DhParams { |
wolfSSL | 13:f67a6c6013ca | 41 | const byte* p; |
wolfSSL | 13:f67a6c6013ca | 42 | word32 p_len; |
wolfSSL | 13:f67a6c6013ca | 43 | const byte* g; |
wolfSSL | 13:f67a6c6013ca | 44 | word32 g_len; |
wolfSSL | 13:f67a6c6013ca | 45 | } DhParams; |
wolfSSL | 13:f67a6c6013ca | 46 | |
wolfSSL | 13:f67a6c6013ca | 47 | /* Diffie-Hellman Key */ |
wolfSSL | 13:f67a6c6013ca | 48 | typedef struct DhKey { |
wolfSSL | 13:f67a6c6013ca | 49 | mp_int p, g; /* group parameters */ |
wolfSSL | 13:f67a6c6013ca | 50 | void* heap; |
wolfSSL | 13:f67a6c6013ca | 51 | #ifdef WOLFSSL_ASYNC_CRYPT |
wolfSSL | 13:f67a6c6013ca | 52 | WC_ASYNC_DEV asyncDev; |
wolfSSL | 13:f67a6c6013ca | 53 | #endif |
wolfSSL | 13:f67a6c6013ca | 54 | } DhKey; |
wolfSSL | 13:f67a6c6013ca | 55 | |
wolfSSL | 13:f67a6c6013ca | 56 | |
wolfSSL | 13:f67a6c6013ca | 57 | #ifdef HAVE_FFDHE_2048 |
wolfSSL | 13:f67a6c6013ca | 58 | WOLFSSL_API const DhParams* wc_Dh_ffdhe2048_Get(void); |
wolfSSL | 13:f67a6c6013ca | 59 | #endif |
wolfSSL | 13:f67a6c6013ca | 60 | #ifdef HAVE_FFDHE_3072 |
wolfSSL | 13:f67a6c6013ca | 61 | WOLFSSL_API const DhParams* wc_Dh_ffdhe3072_Get(void); |
wolfSSL | 13:f67a6c6013ca | 62 | #endif |
wolfSSL | 13:f67a6c6013ca | 63 | #ifdef HAVE_FFDHE_4096 |
wolfSSL | 13:f67a6c6013ca | 64 | WOLFSSL_API const DhParams* wc_Dh_ffdhe4096_Get(void); |
wolfSSL | 13:f67a6c6013ca | 65 | #endif |
wolfSSL | 13:f67a6c6013ca | 66 | #ifdef HAVE_FFDHE_6144 |
wolfSSL | 13:f67a6c6013ca | 67 | WOLFSSL_API const DhParams* wc_Dh_ffdhe6144_Get(void); |
wolfSSL | 13:f67a6c6013ca | 68 | #endif |
wolfSSL | 13:f67a6c6013ca | 69 | #ifdef HAVE_FFDHE_8192 |
wolfSSL | 13:f67a6c6013ca | 70 | WOLFSSL_API const DhParams* wc_Dh_ffdhe8192_Get(void); |
wolfSSL | 13:f67a6c6013ca | 71 | #endif |
wolfSSL | 13:f67a6c6013ca | 72 | |
wolfSSL | 13:f67a6c6013ca | 73 | WOLFSSL_API int wc_InitDhKey(DhKey* key); |
wolfSSL | 13:f67a6c6013ca | 74 | WOLFSSL_API int wc_InitDhKey_ex(DhKey* key, void* heap, int devId); |
wolfSSL | 13:f67a6c6013ca | 75 | WOLFSSL_API void wc_FreeDhKey(DhKey* key); |
wolfSSL | 13:f67a6c6013ca | 76 | |
wolfSSL | 13:f67a6c6013ca | 77 | WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng, byte* priv, |
wolfSSL | 13:f67a6c6013ca | 78 | word32* privSz, byte* pub, word32* pubSz); |
wolfSSL | 13:f67a6c6013ca | 79 | WOLFSSL_API int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz, |
wolfSSL | 13:f67a6c6013ca | 80 | const byte* priv, word32 privSz, const byte* otherPub, |
wolfSSL | 13:f67a6c6013ca | 81 | word32 pubSz); |
wolfSSL | 13:f67a6c6013ca | 82 | |
wolfSSL | 13:f67a6c6013ca | 83 | WOLFSSL_API int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key, |
wolfSSL | 13:f67a6c6013ca | 84 | word32); |
wolfSSL | 13:f67a6c6013ca | 85 | WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g, |
wolfSSL | 13:f67a6c6013ca | 86 | word32 gSz); |
wolfSSL | 13:f67a6c6013ca | 87 | WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p, |
wolfSSL | 13:f67a6c6013ca | 88 | word32* pInOutSz, byte* g, word32* gInOutSz); |
wolfSSL | 13:f67a6c6013ca | 89 | WOLFSSL_API int wc_DhCheckPubKey(DhKey* key, const byte* pub, word32 pubSz); |
wolfSSL | 13:f67a6c6013ca | 90 | |
wolfSSL | 13:f67a6c6013ca | 91 | #ifdef __cplusplus |
wolfSSL | 13:f67a6c6013ca | 92 | } /* extern "C" */ |
wolfSSL | 13:f67a6c6013ca | 93 | #endif |
wolfSSL | 13:f67a6c6013ca | 94 | |
wolfSSL | 13:f67a6c6013ca | 95 | #endif /* NO_DH */ |
wolfSSL | 13:f67a6c6013ca | 96 | #endif /* WOLF_CRYPT_DH_H */ |
wolfSSL | 13:f67a6c6013ca | 97 | |
wolfSSL | 13:f67a6c6013ca | 98 |