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