wolf SSL / wolfSSL-TLS13-Beta

Fork of wolfSSL by wolf SSL

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dh.h Source File

dh.h

00001 /* dh.h
00002  *
00003  * Copyright (C) 2006-2016 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 #ifndef WOLF_CRYPT_DH_H
00024 #define WOLF_CRYPT_DH_H
00025 
00026 #include <wolfssl/wolfcrypt/types.h>
00027 
00028 #ifndef NO_DH
00029 
00030 #include <wolfssl/wolfcrypt/integer.h>
00031 #include <wolfssl/wolfcrypt/random.h>
00032 
00033 #ifdef __cplusplus
00034     extern "C" {
00035 #endif
00036 
00037 #ifdef WOLFSSL_ASYNC_CRYPT
00038     #include <wolfssl/wolfcrypt/async.h>
00039 #endif
00040 typedef struct DhParams {
00041     const byte* p;
00042     word32      p_len;
00043     const byte* g;
00044     word32      g_len;
00045 } DhParams;
00046 
00047 /* Diffie-Hellman Key */
00048 typedef struct DhKey {
00049     mp_int p, g;                            /* group parameters  */
00050     void* heap;
00051 #ifdef WOLFSSL_ASYNC_CRYPT
00052     WC_ASYNC_DEV asyncDev;
00053 #endif
00054 } DhKey;
00055 
00056 
00057 #ifdef HAVE_FFDHE_2048
00058 WOLFSSL_API const DhParams* wc_Dh_ffdhe2048_Get(void);
00059 #endif
00060 #ifdef HAVE_FFDHE_3072
00061 WOLFSSL_API const DhParams* wc_Dh_ffdhe3072_Get(void);
00062 #endif
00063 #ifdef HAVE_FFDHE_4096
00064 WOLFSSL_API const DhParams* wc_Dh_ffdhe4096_Get(void);
00065 #endif
00066 #ifdef HAVE_FFDHE_6144
00067 WOLFSSL_API const DhParams* wc_Dh_ffdhe6144_Get(void);
00068 #endif
00069 #ifdef HAVE_FFDHE_8192
00070 WOLFSSL_API const DhParams* wc_Dh_ffdhe8192_Get(void);
00071 #endif
00072 
00073 WOLFSSL_API int wc_InitDhKey(DhKey* key);
00074 WOLFSSL_API int wc_InitDhKey_ex(DhKey* key, void* heap, int devId);
00075 WOLFSSL_API void wc_FreeDhKey(DhKey* key);
00076 
00077 WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng, byte* priv,
00078                                  word32* privSz, byte* pub, word32* pubSz);
00079 WOLFSSL_API int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz,
00080                        const byte* priv, word32 privSz, const byte* otherPub,
00081                        word32 pubSz);
00082 
00083 WOLFSSL_API int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
00084                            word32);
00085 WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
00086                         word32 gSz);
00087 WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p,
00088                             word32* pInOutSz, byte* g, word32* gInOutSz);
00089 WOLFSSL_API int wc_DhCheckPubKey(DhKey* key, const byte* pub, word32 pubSz);
00090 
00091 #ifdef __cplusplus
00092     } /* extern "C" */
00093 #endif
00094 
00095 #endif /* NO_DH */
00096 #endif /* WOLF_CRYPT_DH_H */
00097 
00098