wolfSSL 3.11.1 for TLS1.3 beta
Fork of wolfSSL by
wolfssl/wolfcrypt/dsa.h@13:80fb167dafdf, 2017-05-30 (annotated)
- Committer:
- wolfSSL
- Date:
- Tue May 30 06:16:19 2017 +0000
- Revision:
- 13:80fb167dafdf
- Parent:
- 11:cee25a834751
wolfSSL 3.11.1: TLS1.3 Beta
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 11:cee25a834751 | 1 | /* dsa.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_DSA_H |
wolfSSL | 11:cee25a834751 | 24 | #define WOLF_CRYPT_DSA_H |
wolfSSL | 11:cee25a834751 | 25 | |
wolfSSL | 11:cee25a834751 | 26 | #include <wolfssl/wolfcrypt/types.h> |
wolfSSL | 11:cee25a834751 | 27 | |
wolfSSL | 11:cee25a834751 | 28 | #ifndef NO_DSA |
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 | /* for DSA reverse compatibility */ |
wolfSSL | 11:cee25a834751 | 34 | #define InitDsaKey wc_InitDsaKey |
wolfSSL | 11:cee25a834751 | 35 | #define FreeDsaKey wc_FreeDsaKey |
wolfSSL | 11:cee25a834751 | 36 | #define DsaSign wc_DsaSign |
wolfSSL | 11:cee25a834751 | 37 | #define DsaVerify wc_DsaVerify |
wolfSSL | 11:cee25a834751 | 38 | #define DsaPublicKeyDecode wc_DsaPublicKeyDecode |
wolfSSL | 11:cee25a834751 | 39 | #define DsaPrivateKeyDecode wc_DsaPrivateKeyDecode |
wolfSSL | 11:cee25a834751 | 40 | #define DsaKeyToDer wc_DsaKeyToDer |
wolfSSL | 11:cee25a834751 | 41 | |
wolfSSL | 11:cee25a834751 | 42 | #ifdef __cplusplus |
wolfSSL | 11:cee25a834751 | 43 | extern "C" { |
wolfSSL | 11:cee25a834751 | 44 | #endif |
wolfSSL | 11:cee25a834751 | 45 | |
wolfSSL | 11:cee25a834751 | 46 | |
wolfSSL | 11:cee25a834751 | 47 | enum { |
wolfSSL | 11:cee25a834751 | 48 | DSA_PUBLIC = 0, |
wolfSSL | 11:cee25a834751 | 49 | DSA_PRIVATE = 1 |
wolfSSL | 11:cee25a834751 | 50 | }; |
wolfSSL | 11:cee25a834751 | 51 | |
wolfSSL | 11:cee25a834751 | 52 | /* DSA */ |
wolfSSL | 11:cee25a834751 | 53 | typedef struct DsaKey { |
wolfSSL | 11:cee25a834751 | 54 | mp_int p, q, g, y, x; |
wolfSSL | 11:cee25a834751 | 55 | int type; /* public or private */ |
wolfSSL | 11:cee25a834751 | 56 | void* heap; /* memory hint */ |
wolfSSL | 11:cee25a834751 | 57 | } DsaKey; |
wolfSSL | 11:cee25a834751 | 58 | |
wolfSSL | 11:cee25a834751 | 59 | WOLFSSL_API int wc_InitDsaKey(DsaKey* key); |
wolfSSL | 11:cee25a834751 | 60 | WOLFSSL_API int wc_InitDsaKey_h(DsaKey* key, void* h); |
wolfSSL | 11:cee25a834751 | 61 | WOLFSSL_API void wc_FreeDsaKey(DsaKey* key); |
wolfSSL | 11:cee25a834751 | 62 | WOLFSSL_API int wc_DsaSign(const byte* digest, byte* out, |
wolfSSL | 11:cee25a834751 | 63 | DsaKey* key, WC_RNG* rng); |
wolfSSL | 11:cee25a834751 | 64 | WOLFSSL_API int wc_DsaVerify(const byte* digest, const byte* sig, |
wolfSSL | 11:cee25a834751 | 65 | DsaKey* key, int* answer); |
wolfSSL | 11:cee25a834751 | 66 | WOLFSSL_API int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx, |
wolfSSL | 11:cee25a834751 | 67 | DsaKey*, word32); |
wolfSSL | 11:cee25a834751 | 68 | WOLFSSL_API int wc_DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, |
wolfSSL | 11:cee25a834751 | 69 | DsaKey*, word32); |
wolfSSL | 11:cee25a834751 | 70 | WOLFSSL_API int wc_DsaKeyToDer(DsaKey* key, byte* output, word32 inLen); |
wolfSSL | 11:cee25a834751 | 71 | |
wolfSSL | 11:cee25a834751 | 72 | #ifdef WOLFSSL_KEY_GEN |
wolfSSL | 11:cee25a834751 | 73 | WOLFSSL_API int wc_MakeDsaKey(WC_RNG *rng, DsaKey *dsa); |
wolfSSL | 11:cee25a834751 | 74 | WOLFSSL_API int wc_MakeDsaParameters(WC_RNG *rng, int modulus_size, DsaKey *dsa); |
wolfSSL | 11:cee25a834751 | 75 | #endif |
wolfSSL | 11:cee25a834751 | 76 | |
wolfSSL | 11:cee25a834751 | 77 | #ifdef __cplusplus |
wolfSSL | 11:cee25a834751 | 78 | } /* extern "C" */ |
wolfSSL | 11:cee25a834751 | 79 | #endif |
wolfSSL | 11:cee25a834751 | 80 | |
wolfSSL | 11:cee25a834751 | 81 | #endif /* NO_DSA */ |
wolfSSL | 11:cee25a834751 | 82 | #endif /* WOLF_CRYPT_DSA_H */ |
wolfSSL | 11:cee25a834751 | 83 | |
wolfSSL | 11:cee25a834751 | 84 |