source: azure_iot_hub/trunk/wolfssl-3.15.7/wolfssl/wolfcrypt/dh.h@ 388

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

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 4.2 KB
Line 
1/* dh.h
2 *
3 * Copyright (C) 2006-2017 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 */
60typedef struct DhKey {
61 mp_int p, g, q; /* group parameters */
62 void* heap;
63#ifdef WOLFSSL_ASYNC_CRYPT
64 WC_ASYNC_DEV asyncDev;
65#endif
66} DhKey;
67
68
69#ifdef HAVE_FFDHE_2048
70WOLFSSL_API const DhParams* wc_Dh_ffdhe2048_Get(void);
71#endif
72#ifdef HAVE_FFDHE_3072
73WOLFSSL_API const DhParams* wc_Dh_ffdhe3072_Get(void);
74#endif
75#ifdef HAVE_FFDHE_4096
76WOLFSSL_API const DhParams* wc_Dh_ffdhe4096_Get(void);
77#endif
78#ifdef HAVE_FFDHE_6144
79WOLFSSL_API const DhParams* wc_Dh_ffdhe6144_Get(void);
80#endif
81#ifdef HAVE_FFDHE_8192
82WOLFSSL_API const DhParams* wc_Dh_ffdhe8192_Get(void);
83#endif
84
85WOLFSSL_API int wc_InitDhKey(DhKey* key);
86WOLFSSL_API int wc_InitDhKey_ex(DhKey* key, void* heap, int devId);
87WOLFSSL_API int wc_FreeDhKey(DhKey* key);
88
89WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng, byte* priv,
90 word32* privSz, byte* pub, word32* pubSz);
91WOLFSSL_API int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz,
92 const byte* priv, word32 privSz, const byte* otherPub,
93 word32 pubSz);
94
95WOLFSSL_API int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
96 word32);
97WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
98 word32 gSz);
99WOLFSSL_API int wc_DhSetKey_ex(DhKey* key, const byte* p, word32 pSz,
100 const byte* g, word32 gSz, const byte* q, word32 qSz);
101WOLFSSL_API int wc_DhSetCheckKey(DhKey* key, const byte* p, word32 pSz,
102 const byte* g, word32 gSz, const byte* q, word32 qSz,
103 int trusted, WC_RNG* rng);
104WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p,
105 word32* pInOutSz, byte* g, word32* gInOutSz);
106WOLFSSL_API int wc_DhCheckPubKey(DhKey* key, const byte* pub, word32 pubSz);
107WOLFSSL_API int wc_DhCheckPubKey_ex(DhKey* key, const byte* pub, word32 pubSz,
108 const byte* prime, word32 primeSz);
109WOLFSSL_API int wc_DhCheckPrivKey(DhKey* key, const byte* priv, word32 pubSz);
110WOLFSSL_API int wc_DhCheckPrivKey_ex(DhKey* key, const byte* priv, word32 pubSz,
111 const byte* prime, word32 primeSz);
112WOLFSSL_API int wc_DhCheckKeyPair(DhKey* key, const byte* pub, word32 pubSz,
113 const byte* priv, word32 privSz);
114WOLFSSL_API int wc_DhGenerateParams(WC_RNG *rng, int modSz, DhKey *dh);
115WOLFSSL_API int wc_DhExportParamsRaw(DhKey* dh, byte* p, word32* pSz,
116 byte* q, word32* qSz, byte* g, word32* gSz);
117
118
119#ifdef __cplusplus
120 } /* extern "C" */
121#endif
122
123#endif /* NO_DH */
124#endif /* WOLF_CRYPT_DH_H */
125
Note: See TracBrowser for help on using the repository browser.