ssh lib

Dependents:   OS

Committer:
sPymbed
Date:
Mon Nov 25 14:23:49 2019 +0000
Revision:
1:e4ea39eba2fb
Parent:
0:1387ff3eed4a
improved

Who changed what in which revision?

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