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.
dh.h
00001 /* dh.h 00002 * 00003 * Copyright (C) 2006-2017 wolfSSL Inc. 00004 * 00005 * This file is part of wolfSSL. 00006 * 00007 * wolfSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * wolfSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 00020 */ 00021 00022 /*! 00023 \file wolfssl/wolfcrypt/dh.h 00024 */ 00025 00026 #ifndef WOLF_CRYPT_DH_H 00027 #define WOLF_CRYPT_DH_H 00028 00029 #include <wolfcrypt/types.h> 00030 00031 #ifndef NO_DH 00032 00033 #if defined(HAVE_FIPS) && \ 00034 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 00035 #include <wolfcrypt/fips.h> 00036 #endif /* HAVE_FIPS_VERSION >= 2 */ 00037 00038 #include <wolfcrypt/integer.h> 00039 #include <wolfcrypt/random.h> 00040 00041 #ifdef __cplusplus 00042 extern "C" { 00043 #endif 00044 00045 #ifdef WOLFSSL_ASYNC_CRYPT 00046 #include <wolfcrypt/async.h> 00047 #endif 00048 typedef struct DhParams { 00049 #ifdef HAVE_FFDHE_Q 00050 const byte* q; 00051 word32 q_len; 00052 #endif /* HAVE_FFDHE_Q */ 00053 const byte* p; 00054 word32 p_len; 00055 const byte* g; 00056 word32 g_len; 00057 } DhParams; 00058 00059 /* Diffie-Hellman Key */ 00060 typedef struct DhKey { 00061 mp_int p, g, q; /* group parameters */ 00062 void* heap; 00063 #ifdef WOLFSSL_ASYNC_CRYPT 00064 WC_ASYNC_DEV asyncDev; 00065 #endif 00066 } DhKey; 00067 00068 00069 #ifdef HAVE_FFDHE_2048 00070 WOLFSSL_API const DhParams* wc_Dh_ffdhe2048_Get(void); 00071 #endif 00072 #ifdef HAVE_FFDHE_3072 00073 WOLFSSL_API const DhParams* wc_Dh_ffdhe3072_Get(void); 00074 #endif 00075 #ifdef HAVE_FFDHE_4096 00076 WOLFSSL_API const DhParams* wc_Dh_ffdhe4096_Get(void); 00077 #endif 00078 #ifdef HAVE_FFDHE_6144 00079 WOLFSSL_API const DhParams* wc_Dh_ffdhe6144_Get(void); 00080 #endif 00081 #ifdef HAVE_FFDHE_8192 00082 WOLFSSL_API const DhParams* wc_Dh_ffdhe8192_Get(void); 00083 #endif 00084 00085 WOLFSSL_API int wc_InitDhKey(DhKey* key); 00086 WOLFSSL_API int wc_InitDhKey_ex(DhKey* key, void* heap, int devId); 00087 WOLFSSL_API int wc_FreeDhKey(DhKey* key); 00088 00089 WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng, byte* priv, 00090 word32* privSz, byte* pub, word32* pubSz); 00091 WOLFSSL_API int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz, 00092 const byte* priv, word32 privSz, const byte* otherPub, 00093 word32 pubSz); 00094 00095 WOLFSSL_API int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key, 00096 word32); 00097 WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g, 00098 word32 gSz); 00099 WOLFSSL_API int wc_DhSetKey_ex(DhKey* key, const byte* p, word32 pSz, 00100 const byte* g, word32 gSz, const byte* q, word32 qSz); 00101 WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p, 00102 word32* pInOutSz, byte* g, word32* gInOutSz); 00103 WOLFSSL_API int wc_DhCheckPubKey(DhKey* key, const byte* pub, word32 pubSz); 00104 WOLFSSL_API int wc_DhCheckPubKey_ex(DhKey* key, const byte* pub, word32 pubSz, 00105 const byte* prime, word32 primeSz); 00106 WOLFSSL_API int wc_DhCheckPrivKey(DhKey* key, const byte* priv, word32 pubSz); 00107 WOLFSSL_API int wc_DhCheckPrivKey_ex(DhKey* key, const byte* priv, word32 pubSz, 00108 const byte* prime, word32 primeSz); 00109 WOLFSSL_API int wc_DhCheckKeyPair(DhKey* key, const byte* pub, word32 pubSz, 00110 const byte* priv, word32 privSz); 00111 WOLFSSL_API int wc_DhGenerateParams(WC_RNG *rng, int modSz, DhKey *dh); 00112 WOLFSSL_API int wc_DhExportParamsRaw(DhKey* dh, byte* p, word32* pSz, 00113 byte* q, word32* qSz, byte* g, word32* gSz); 00114 00115 00116 #ifdef __cplusplus 00117 } /* extern "C" */ 00118 #endif 00119 00120 #endif /* NO_DH */ 00121 #endif /* WOLF_CRYPT_DH_H */ 00122 00123
Generated on Tue Jul 12 2022 16:58:05 by
1.7.2