fork of cyassl-lib
Dependents: TLS_cyassl TLS_cyassl
cyassl/ctaocrypt/dh.h@0:714293de3836, 2013-09-05 (annotated)
- Committer:
- ashleymills
- Date:
- Thu Sep 05 10:33:04 2013 +0000
- Revision:
- 0:714293de3836
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ashleymills | 0:714293de3836 | 1 | /* dh.h |
ashleymills | 0:714293de3836 | 2 | * |
ashleymills | 0:714293de3836 | 3 | * Copyright (C) 2006-2013 wolfSSL Inc. |
ashleymills | 0:714293de3836 | 4 | * |
ashleymills | 0:714293de3836 | 5 | * This file is part of CyaSSL. |
ashleymills | 0:714293de3836 | 6 | * |
ashleymills | 0:714293de3836 | 7 | * CyaSSL is free software; you can redistribute it and/or modify |
ashleymills | 0:714293de3836 | 8 | * it under the terms of the GNU General Public License as published by |
ashleymills | 0:714293de3836 | 9 | * the Free Software Foundation; either version 2 of the License, or |
ashleymills | 0:714293de3836 | 10 | * (at your option) any later version. |
ashleymills | 0:714293de3836 | 11 | * |
ashleymills | 0:714293de3836 | 12 | * CyaSSL is distributed in the hope that it will be useful, |
ashleymills | 0:714293de3836 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ashleymills | 0:714293de3836 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ashleymills | 0:714293de3836 | 15 | * GNU General Public License for more details. |
ashleymills | 0:714293de3836 | 16 | * |
ashleymills | 0:714293de3836 | 17 | * You should have received a copy of the GNU General Public License |
ashleymills | 0:714293de3836 | 18 | * along with this program; if not, write to the Free Software |
ashleymills | 0:714293de3836 | 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
ashleymills | 0:714293de3836 | 20 | */ |
ashleymills | 0:714293de3836 | 21 | |
ashleymills | 0:714293de3836 | 22 | |
ashleymills | 0:714293de3836 | 23 | #ifndef NO_DH |
ashleymills | 0:714293de3836 | 24 | |
ashleymills | 0:714293de3836 | 25 | #ifndef CTAO_CRYPT_DH_H |
ashleymills | 0:714293de3836 | 26 | #define CTAO_CRYPT_DH_H |
ashleymills | 0:714293de3836 | 27 | |
ashleymills | 0:714293de3836 | 28 | #include <cyassl/ctaocrypt/types.h> |
ashleymills | 0:714293de3836 | 29 | #include <cyassl/ctaocrypt/integer.h> |
ashleymills | 0:714293de3836 | 30 | #include <cyassl/ctaocrypt/random.h> |
ashleymills | 0:714293de3836 | 31 | |
ashleymills | 0:714293de3836 | 32 | #ifdef __cplusplus |
ashleymills | 0:714293de3836 | 33 | extern "C" { |
ashleymills | 0:714293de3836 | 34 | #endif |
ashleymills | 0:714293de3836 | 35 | |
ashleymills | 0:714293de3836 | 36 | |
ashleymills | 0:714293de3836 | 37 | /* Diffie-Hellman Key */ |
ashleymills | 0:714293de3836 | 38 | typedef struct DhKey { |
ashleymills | 0:714293de3836 | 39 | mp_int p, g; /* group parameters */ |
ashleymills | 0:714293de3836 | 40 | } DhKey; |
ashleymills | 0:714293de3836 | 41 | |
ashleymills | 0:714293de3836 | 42 | |
ashleymills | 0:714293de3836 | 43 | CYASSL_API void InitDhKey(DhKey* key); |
ashleymills | 0:714293de3836 | 44 | CYASSL_API void FreeDhKey(DhKey* key); |
ashleymills | 0:714293de3836 | 45 | |
ashleymills | 0:714293de3836 | 46 | CYASSL_API int DhGenerateKeyPair(DhKey* key, RNG* rng, byte* priv, |
ashleymills | 0:714293de3836 | 47 | word32* privSz, byte* pub, word32* pubSz); |
ashleymills | 0:714293de3836 | 48 | CYASSL_API int DhAgree(DhKey* key, byte* agree, word32* agreeSz, |
ashleymills | 0:714293de3836 | 49 | const byte* priv, word32 privSz, const byte* otherPub, |
ashleymills | 0:714293de3836 | 50 | word32 pubSz); |
ashleymills | 0:714293de3836 | 51 | |
ashleymills | 0:714293de3836 | 52 | CYASSL_API int DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key, |
ashleymills | 0:714293de3836 | 53 | word32); |
ashleymills | 0:714293de3836 | 54 | CYASSL_API int DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g, |
ashleymills | 0:714293de3836 | 55 | word32 gSz); |
ashleymills | 0:714293de3836 | 56 | CYASSL_API int DhParamsLoad(const byte* input, word32 inSz, byte* p, |
ashleymills | 0:714293de3836 | 57 | word32* pInOutSz, byte* g, word32* gInOutSz); |
ashleymills | 0:714293de3836 | 58 | |
ashleymills | 0:714293de3836 | 59 | |
ashleymills | 0:714293de3836 | 60 | #ifdef __cplusplus |
ashleymills | 0:714293de3836 | 61 | } /* extern "C" */ |
ashleymills | 0:714293de3836 | 62 | #endif |
ashleymills | 0:714293de3836 | 63 | |
ashleymills | 0:714293de3836 | 64 | #endif /* CTAO_CRYPT_DH_H */ |
ashleymills | 0:714293de3836 | 65 | |
ashleymills | 0:714293de3836 | 66 | #endif /* NO_DH */ |
ashleymills | 0:714293de3836 | 67 |