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

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

Committer:
wolfSSL
Date:
Thu Apr 28 00:57:21 2016 +0000
Revision:
4:1b0d80432c79
wolfSSL 3.9.0

Who changed what in which revision?

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