wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Tue May 30 01:44:10 2017 +0000
Revision:
11:cee25a834751
wolfSSL 3.11.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 11:cee25a834751 1 /* dh.h
wolfSSL 11:cee25a834751 2 *
wolfSSL 11:cee25a834751 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 11:cee25a834751 4 *
wolfSSL 11:cee25a834751 5 * This file is part of wolfSSL.
wolfSSL 11:cee25a834751 6 *
wolfSSL 11:cee25a834751 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 11:cee25a834751 8 * it under the terms of the GNU General Public License as published by
wolfSSL 11:cee25a834751 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 11:cee25a834751 10 * (at your option) any later version.
wolfSSL 11:cee25a834751 11 *
wolfSSL 11:cee25a834751 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 11:cee25a834751 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 11:cee25a834751 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 11:cee25a834751 15 * GNU General Public License for more details.
wolfSSL 11:cee25a834751 16 *
wolfSSL 11:cee25a834751 17 * You should have received a copy of the GNU General Public License
wolfSSL 11:cee25a834751 18 * along with this program; if not, write to the Free Software
wolfSSL 11:cee25a834751 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 11:cee25a834751 20 */
wolfSSL 11:cee25a834751 21
wolfSSL 11:cee25a834751 22
wolfSSL 11:cee25a834751 23 #ifndef WOLF_CRYPT_DH_H
wolfSSL 11:cee25a834751 24 #define WOLF_CRYPT_DH_H
wolfSSL 11:cee25a834751 25
wolfSSL 11:cee25a834751 26 #include <wolfssl/wolfcrypt/types.h>
wolfSSL 11:cee25a834751 27
wolfSSL 11:cee25a834751 28 #ifndef NO_DH
wolfSSL 11:cee25a834751 29
wolfSSL 11:cee25a834751 30 #include <wolfssl/wolfcrypt/integer.h>
wolfSSL 11:cee25a834751 31 #include <wolfssl/wolfcrypt/random.h>
wolfSSL 11:cee25a834751 32
wolfSSL 11:cee25a834751 33 #ifdef __cplusplus
wolfSSL 11:cee25a834751 34 extern "C" {
wolfSSL 11:cee25a834751 35 #endif
wolfSSL 11:cee25a834751 36
wolfSSL 11:cee25a834751 37 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 11:cee25a834751 38 #include <wolfssl/wolfcrypt/async.h>
wolfSSL 11:cee25a834751 39 #endif
wolfSSL 11:cee25a834751 40
wolfSSL 11:cee25a834751 41 /* Diffie-Hellman Key */
wolfSSL 11:cee25a834751 42 typedef struct DhKey {
wolfSSL 11:cee25a834751 43 mp_int p, g; /* group parameters */
wolfSSL 11:cee25a834751 44 void* heap;
wolfSSL 11:cee25a834751 45 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 11:cee25a834751 46 WC_ASYNC_DEV asyncDev;
wolfSSL 11:cee25a834751 47 #endif
wolfSSL 11:cee25a834751 48 } DhKey;
wolfSSL 11:cee25a834751 49
wolfSSL 11:cee25a834751 50
wolfSSL 11:cee25a834751 51 WOLFSSL_API int wc_InitDhKey(DhKey* key);
wolfSSL 11:cee25a834751 52 WOLFSSL_API int wc_InitDhKey_ex(DhKey* key, void* heap, int devId);
wolfSSL 11:cee25a834751 53 WOLFSSL_API void wc_FreeDhKey(DhKey* key);
wolfSSL 11:cee25a834751 54
wolfSSL 11:cee25a834751 55 WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng, byte* priv,
wolfSSL 11:cee25a834751 56 word32* privSz, byte* pub, word32* pubSz);
wolfSSL 11:cee25a834751 57 WOLFSSL_API int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz,
wolfSSL 11:cee25a834751 58 const byte* priv, word32 privSz, const byte* otherPub,
wolfSSL 11:cee25a834751 59 word32 pubSz);
wolfSSL 11:cee25a834751 60
wolfSSL 11:cee25a834751 61 WOLFSSL_API int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
wolfSSL 11:cee25a834751 62 word32);
wolfSSL 11:cee25a834751 63 WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
wolfSSL 11:cee25a834751 64 word32 gSz);
wolfSSL 11:cee25a834751 65 WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p,
wolfSSL 11:cee25a834751 66 word32* pInOutSz, byte* g, word32* gInOutSz);
wolfSSL 11:cee25a834751 67 WOLFSSL_API int wc_DhCheckPubKey(DhKey* key, const byte* pub, word32 pubSz);
wolfSSL 11:cee25a834751 68
wolfSSL 11:cee25a834751 69 #ifdef __cplusplus
wolfSSL 11:cee25a834751 70 } /* extern "C" */
wolfSSL 11:cee25a834751 71 #endif
wolfSSL 11:cee25a834751 72
wolfSSL 11:cee25a834751 73 #endif /* NO_DH */
wolfSSL 11:cee25a834751 74 #endif /* WOLF_CRYPT_DH_H */
wolfSSL 11:cee25a834751 75
wolfSSL 11:cee25a834751 76