Xuyi Wang / wolfSSL

Dependents:   OS

Committer:
wolfSSL
Date:
Sat Aug 18 22:20:43 2018 +0000
Revision:
15:117db924cf7c
wolfSSL 3.15.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 15:117db924cf7c 1 /* dsa.h
wolfSSL 15:117db924cf7c 2 *
wolfSSL 15:117db924cf7c 3 * Copyright (C) 2006-2017 wolfSSL Inc.
wolfSSL 15:117db924cf7c 4 *
wolfSSL 15:117db924cf7c 5 * This file is part of wolfSSL.
wolfSSL 15:117db924cf7c 6 *
wolfSSL 15:117db924cf7c 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 15:117db924cf7c 8 * it under the terms of the GNU General Public License as published by
wolfSSL 15:117db924cf7c 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 15:117db924cf7c 10 * (at your option) any later version.
wolfSSL 15:117db924cf7c 11 *
wolfSSL 15:117db924cf7c 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 15:117db924cf7c 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 15:117db924cf7c 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 15:117db924cf7c 15 * GNU General Public License for more details.
wolfSSL 15:117db924cf7c 16 *
wolfSSL 15:117db924cf7c 17 * You should have received a copy of the GNU General Public License
wolfSSL 15:117db924cf7c 18 * along with this program; if not, write to the Free Software
wolfSSL 15:117db924cf7c 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 15:117db924cf7c 20 */
wolfSSL 15:117db924cf7c 21
wolfSSL 15:117db924cf7c 22 /*!
wolfSSL 15:117db924cf7c 23 \file wolfssl/wolfcrypt/dsa.h
wolfSSL 15:117db924cf7c 24 */
wolfSSL 15:117db924cf7c 25
wolfSSL 15:117db924cf7c 26 #ifndef WOLF_CRYPT_DSA_H
wolfSSL 15:117db924cf7c 27 #define WOLF_CRYPT_DSA_H
wolfSSL 15:117db924cf7c 28
wolfSSL 15:117db924cf7c 29 #include <wolfssl/wolfcrypt/types.h>
wolfSSL 15:117db924cf7c 30
wolfSSL 15:117db924cf7c 31 #ifndef NO_DSA
wolfSSL 15:117db924cf7c 32
wolfSSL 15:117db924cf7c 33 #include <wolfssl/wolfcrypt/integer.h>
wolfSSL 15:117db924cf7c 34 #include <wolfssl/wolfcrypt/random.h>
wolfSSL 15:117db924cf7c 35
wolfSSL 15:117db924cf7c 36 /* for DSA reverse compatibility */
wolfSSL 15:117db924cf7c 37 #define InitDsaKey wc_InitDsaKey
wolfSSL 15:117db924cf7c 38 #define FreeDsaKey wc_FreeDsaKey
wolfSSL 15:117db924cf7c 39 #define DsaSign wc_DsaSign
wolfSSL 15:117db924cf7c 40 #define DsaVerify wc_DsaVerify
wolfSSL 15:117db924cf7c 41 #define DsaPublicKeyDecode wc_DsaPublicKeyDecode
wolfSSL 15:117db924cf7c 42 #define DsaPrivateKeyDecode wc_DsaPrivateKeyDecode
wolfSSL 15:117db924cf7c 43 #define DsaKeyToDer wc_DsaKeyToDer
wolfSSL 15:117db924cf7c 44
wolfSSL 15:117db924cf7c 45 #ifdef __cplusplus
wolfSSL 15:117db924cf7c 46 extern "C" {
wolfSSL 15:117db924cf7c 47 #endif
wolfSSL 15:117db924cf7c 48
wolfSSL 15:117db924cf7c 49
wolfSSL 15:117db924cf7c 50 enum {
wolfSSL 15:117db924cf7c 51 DSA_PUBLIC = 0,
wolfSSL 15:117db924cf7c 52 DSA_PRIVATE = 1
wolfSSL 15:117db924cf7c 53 };
wolfSSL 15:117db924cf7c 54
wolfSSL 15:117db924cf7c 55 /* DSA */
wolfSSL 15:117db924cf7c 56 typedef struct DsaKey {
wolfSSL 15:117db924cf7c 57 mp_int p, q, g, y, x;
wolfSSL 15:117db924cf7c 58 int type; /* public or private */
wolfSSL 15:117db924cf7c 59 void* heap; /* memory hint */
wolfSSL 15:117db924cf7c 60 } DsaKey;
wolfSSL 15:117db924cf7c 61
wolfSSL 15:117db924cf7c 62 WOLFSSL_API int wc_InitDsaKey(DsaKey* key);
wolfSSL 15:117db924cf7c 63 WOLFSSL_API int wc_InitDsaKey_h(DsaKey* key, void* h);
wolfSSL 15:117db924cf7c 64 WOLFSSL_API void wc_FreeDsaKey(DsaKey* key);
wolfSSL 15:117db924cf7c 65 WOLFSSL_API int wc_DsaSign(const byte* digest, byte* out,
wolfSSL 15:117db924cf7c 66 DsaKey* key, WC_RNG* rng);
wolfSSL 15:117db924cf7c 67 WOLFSSL_API int wc_DsaVerify(const byte* digest, const byte* sig,
wolfSSL 15:117db924cf7c 68 DsaKey* key, int* answer);
wolfSSL 15:117db924cf7c 69 WOLFSSL_API int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx,
wolfSSL 15:117db924cf7c 70 DsaKey*, word32);
wolfSSL 15:117db924cf7c 71 WOLFSSL_API int wc_DsaPrivateKeyDecode(const byte* input, word32* inOutIdx,
wolfSSL 15:117db924cf7c 72 DsaKey*, word32);
wolfSSL 15:117db924cf7c 73 WOLFSSL_API int wc_DsaKeyToDer(DsaKey* key, byte* output, word32 inLen);
wolfSSL 15:117db924cf7c 74
wolfSSL 15:117db924cf7c 75 #ifdef WOLFSSL_KEY_GEN
wolfSSL 15:117db924cf7c 76 WOLFSSL_API int wc_MakeDsaKey(WC_RNG *rng, DsaKey *dsa);
wolfSSL 15:117db924cf7c 77 WOLFSSL_API int wc_MakeDsaParameters(WC_RNG *rng, int modulus_size, DsaKey *dsa);
wolfSSL 15:117db924cf7c 78 #endif
wolfSSL 15:117db924cf7c 79
wolfSSL 15:117db924cf7c 80 /* raw export functions */
wolfSSL 15:117db924cf7c 81 WOLFSSL_API int wc_DsaImportParamsRaw(DsaKey* dsa, const char* p,
wolfSSL 15:117db924cf7c 82 const char* q, const char* g);
wolfSSL 15:117db924cf7c 83 WOLFSSL_API int wc_DsaExportParamsRaw(DsaKey* dsa, byte* p, word32* pSz,
wolfSSL 15:117db924cf7c 84 byte* q, word32* qSz, byte* g,
wolfSSL 15:117db924cf7c 85 word32* gSz);
wolfSSL 15:117db924cf7c 86 WOLFSSL_API int wc_DsaExportKeyRaw(DsaKey* dsa, byte* x, word32* xSz, byte* y,
wolfSSL 15:117db924cf7c 87 word32* ySz);
wolfSSL 15:117db924cf7c 88 #ifdef __cplusplus
wolfSSL 15:117db924cf7c 89 } /* extern "C" */
wolfSSL 15:117db924cf7c 90 #endif
wolfSSL 15:117db924cf7c 91
wolfSSL 15:117db924cf7c 92 #endif /* NO_DSA */
wolfSSL 15:117db924cf7c 93 #endif /* WOLF_CRYPT_DSA_H */
wolfSSL 15:117db924cf7c 94
wolfSSL 15:117db924cf7c 95