source: azure_iot_hub_f767zi/trunk/wolfssl-4.4.0/wolfssl/wolfcrypt/dh.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 4.7 KB
Line 
1/* dh.h
2 *
3 * Copyright (C) 2006-2020 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL.
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 */
21
22/*!
23 \file wolfssl/wolfcrypt/dh.h
24*/
25
26#ifndef WOLF_CRYPT_DH_H
27#define WOLF_CRYPT_DH_H
28
29#include <wolfssl/wolfcrypt/types.h>
30
31#ifndef NO_DH
32
33#if defined(HAVE_FIPS) && \
34 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
35 #include <wolfssl/wolfcrypt/fips.h>
36#endif /* HAVE_FIPS_VERSION >= 2 */
37
38#include <wolfssl/wolfcrypt/integer.h>
39#include <wolfssl/wolfcrypt/random.h>
40
41#ifdef __cplusplus
42 extern "C" {
43#endif
44
45#ifdef WOLFSSL_ASYNC_CRYPT
46 #include <wolfssl/wolfcrypt/async.h>
47#endif
48typedef struct DhParams {
49 #ifdef HAVE_FFDHE_Q
50 const byte* q;
51 word32 q_len;
52 #endif /* HAVE_FFDHE_Q */
53 const byte* p;
54 word32 p_len;
55 const byte* g;
56 word32 g_len;
57} DhParams;
58
59/* Diffie-Hellman Key */
60struct DhKey {
61 mp_int p, g, q; /* group parameters */
62#if defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_OPENSSH)
63 mp_int pub;
64 mp_int priv;
65#endif
66 void* heap;
67#ifdef WOLFSSL_ASYNC_CRYPT
68 WC_ASYNC_DEV asyncDev;
69#endif
70};
71
72#ifndef WC_DH_TYPE_DEFINED
73 typedef struct DhKey DhKey;
74 #define WC_DH_TYPE_DEFINED
75#endif
76
77#ifdef HAVE_FFDHE_2048
78WOLFSSL_API const DhParams* wc_Dh_ffdhe2048_Get(void);
79#endif
80#ifdef HAVE_FFDHE_3072
81WOLFSSL_API const DhParams* wc_Dh_ffdhe3072_Get(void);
82#endif
83#ifdef HAVE_FFDHE_4096
84WOLFSSL_API const DhParams* wc_Dh_ffdhe4096_Get(void);
85#endif
86#ifdef HAVE_FFDHE_6144
87WOLFSSL_API const DhParams* wc_Dh_ffdhe6144_Get(void);
88#endif
89#ifdef HAVE_FFDHE_8192
90WOLFSSL_API const DhParams* wc_Dh_ffdhe8192_Get(void);
91#endif
92
93WOLFSSL_API int wc_InitDhKey(DhKey* key);
94WOLFSSL_API int wc_InitDhKey_ex(DhKey* key, void* heap, int devId);
95WOLFSSL_API int wc_FreeDhKey(DhKey* key);
96
97WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng, byte* priv,
98 word32* privSz, byte* pub, word32* pubSz);
99WOLFSSL_API int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz,
100 const byte* priv, word32 privSz, const byte* otherPub,
101 word32 pubSz);
102
103WOLFSSL_API int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
104 word32);
105WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
106 word32 gSz);
107WOLFSSL_API int wc_DhSetKey_ex(DhKey* key, const byte* p, word32 pSz,
108 const byte* g, word32 gSz, const byte* q, word32 qSz);
109#if defined(WOLFSSL_QT) || defined(OPENSSL_ALL)
110WOLFSSL_LOCAL int wc_DhSetFullKeys(DhKey* key,const byte* priv_key,word32 privSz,
111 const byte* pub_key, word32 pubSz);
112#endif
113WOLFSSL_API int wc_DhSetCheckKey(DhKey* key, const byte* p, word32 pSz,
114 const byte* g, word32 gSz, const byte* q, word32 qSz,
115 int trusted, WC_RNG* rng);
116WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p,
117 word32* pInOutSz, byte* g, word32* gInOutSz);
118WOLFSSL_API int wc_DhCheckPubKey(DhKey* key, const byte* pub, word32 pubSz);
119WOLFSSL_API int wc_DhCheckPubKey_ex(DhKey* key, const byte* pub, word32 pubSz,
120 const byte* prime, word32 primeSz);
121WOLFSSL_API int wc_DhCheckPubValue(const byte* prime, word32 primeSz,
122 const byte* pub, word32 pubSz);
123WOLFSSL_API int wc_DhCheckPrivKey(DhKey* key, const byte* priv, word32 pubSz);
124WOLFSSL_API int wc_DhCheckPrivKey_ex(DhKey* key, const byte* priv, word32 pubSz,
125 const byte* prime, word32 primeSz);
126WOLFSSL_API int wc_DhCheckKeyPair(DhKey* key, const byte* pub, word32 pubSz,
127 const byte* priv, word32 privSz);
128WOLFSSL_API int wc_DhGenerateParams(WC_RNG *rng, int modSz, DhKey *dh);
129WOLFSSL_API int wc_DhExportParamsRaw(DhKey* dh, byte* p, word32* pSz,
130 byte* q, word32* qSz, byte* g, word32* gSz);
131
132
133#ifdef __cplusplus
134 } /* extern "C" */
135#endif
136
137#endif /* NO_DH */
138#endif /* WOLF_CRYPT_DH_H */
139
Note: See TracBrowser for help on using the repository browser.