Renesas / SecureDweet
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 
00038 /* Diffie-Hellman Key */
00039 typedef struct DhKey {
00040     mp_int p, g;                            /* group parameters  */
00041 } DhKey;
00042 
00043 
00044 WOLFSSL_API void wc_InitDhKey(DhKey* key);
00045 WOLFSSL_API void wc_FreeDhKey(DhKey* key);
00046 
00047 WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng, byte* priv,
00048                                  word32* privSz, byte* pub, word32* pubSz);
00049 WOLFSSL_API int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz,
00050                        const byte* priv, word32 privSz, const byte* otherPub,
00051                        word32 pubSz);
00052 
00053 WOLFSSL_API int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
00054                            word32);
00055 WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
00056                         word32 gSz);
00057 WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p,
00058                             word32* pInOutSz, byte* g, word32* gInOutSz);
00059 
00060 
00061 #ifdef __cplusplus
00062     } /* extern "C" */
00063 #endif
00064 
00065 #endif /* NO_DH */
00066 #endif /* WOLF_CRYPT_DH_H */
00067 
00068