1 | /* dsa.h
|
---|
2 | *
|
---|
3 | * Copyright (C) 2006-2020 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 | /* dsa.h for openSSL */
|
---|
23 |
|
---|
24 |
|
---|
25 | #ifndef WOLFSSL_DSA_H_
|
---|
26 | #define WOLFSSL_DSA_H_
|
---|
27 |
|
---|
28 | #include <wolfssl/openssl/bn.h>
|
---|
29 |
|
---|
30 | #ifdef __cplusplus
|
---|
31 | extern "C" {
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | typedef struct WOLFSSL_DSA_SIG {
|
---|
35 | WOLFSSL_BIGNUM *r;
|
---|
36 | WOLFSSL_BIGNUM *s;
|
---|
37 | } WOLFSSL_DSA_SIG;
|
---|
38 |
|
---|
39 | #ifndef WOLFSSL_DSA_TYPE_DEFINED /* guard on redeclaration */
|
---|
40 | typedef struct WOLFSSL_DSA WOLFSSL_DSA;
|
---|
41 | #define WOLFSSL_DSA_TYPE_DEFINED
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | typedef WOLFSSL_DSA DSA;
|
---|
45 |
|
---|
46 | struct WOLFSSL_DSA {
|
---|
47 | WOLFSSL_BIGNUM* p;
|
---|
48 | WOLFSSL_BIGNUM* q;
|
---|
49 | WOLFSSL_BIGNUM* g;
|
---|
50 | WOLFSSL_BIGNUM* pub_key; /* our y */
|
---|
51 | WOLFSSL_BIGNUM* priv_key; /* our x */
|
---|
52 | void* internal; /* our Dsa Key */
|
---|
53 | char inSet; /* internal set from external ? */
|
---|
54 | char exSet; /* external set from internal ? */
|
---|
55 | };
|
---|
56 |
|
---|
57 |
|
---|
58 | WOLFSSL_API WOLFSSL_DSA* wolfSSL_DSA_new(void);
|
---|
59 | WOLFSSL_API void wolfSSL_DSA_free(WOLFSSL_DSA*);
|
---|
60 |
|
---|
61 | WOLFSSL_API int wolfSSL_DSA_generate_key(WOLFSSL_DSA*);
|
---|
62 |
|
---|
63 | typedef void (*WOLFSSL_BN_CB)(int i, int j, void* exArg);
|
---|
64 | WOLFSSL_API WOLFSSL_DSA* wolfSSL_DSA_generate_parameters(int bits,
|
---|
65 | unsigned char* seed, int seedLen, int* counterRet,
|
---|
66 | unsigned long* hRet, WOLFSSL_BN_CB cb, void* CBArg);
|
---|
67 | WOLFSSL_API int wolfSSL_DSA_generate_parameters_ex(WOLFSSL_DSA*, int bits,
|
---|
68 | unsigned char* seed, int seedLen, int* counterRet,
|
---|
69 | unsigned long* hRet, void* cb);
|
---|
70 |
|
---|
71 | WOLFSSL_API int wolfSSL_DSA_LoadDer(WOLFSSL_DSA*, const unsigned char*, int sz);
|
---|
72 |
|
---|
73 | WOLFSSL_API int wolfSSL_DSA_LoadDer_ex(WOLFSSL_DSA*, const unsigned char*,
|
---|
74 | int sz, int opt);
|
---|
75 |
|
---|
76 | WOLFSSL_API int wolfSSL_DSA_do_sign(const unsigned char* d,
|
---|
77 | unsigned char* sigRet, WOLFSSL_DSA* dsa);
|
---|
78 |
|
---|
79 | WOLFSSL_API int wolfSSL_DSA_do_verify(const unsigned char* d,
|
---|
80 | unsigned char* sig,
|
---|
81 | WOLFSSL_DSA* dsa, int *dsacheck);
|
---|
82 |
|
---|
83 | WOLFSSL_API WOLFSSL_DSA_SIG* wolfSSL_DSA_SIG_new(void);
|
---|
84 | WOLFSSL_API void wolfSSL_DSA_SIG_free(WOLFSSL_DSA_SIG *sig);
|
---|
85 | WOLFSSL_API WOLFSSL_DSA_SIG* wolfSSL_DSA_do_sign_ex(const unsigned char* digest,
|
---|
86 | int outLen, WOLFSSL_DSA* dsa);
|
---|
87 | WOLFSSL_API int wolfSSL_DSA_do_verify_ex(const unsigned char* digest, int digest_len,
|
---|
88 | WOLFSSL_DSA_SIG* sig, WOLFSSL_DSA* dsa);
|
---|
89 |
|
---|
90 | #define WOLFSSL_DSA_LOAD_PRIVATE 1
|
---|
91 | #define WOLFSSL_DSA_LOAD_PUBLIC 2
|
---|
92 |
|
---|
93 | #define DSA_new wolfSSL_DSA_new
|
---|
94 | #define DSA_free wolfSSL_DSA_free
|
---|
95 |
|
---|
96 | #define DSA_LoadDer wolfSSL_DSA_LoadDer
|
---|
97 | #define DSA_generate_key wolfSSL_DSA_generate_key
|
---|
98 | #define DSA_generate_parameters wolfSSL_DSA_generate_parameters
|
---|
99 | #define DSA_generate_parameters_ex wolfSSL_DSA_generate_parameters_ex
|
---|
100 |
|
---|
101 | #define DSA_SIG_new wolfSSL_DSA_SIG_new
|
---|
102 | #define DSA_SIG_free wolfSSL_DSA_SIG_free
|
---|
103 | #define DSA_do_sign wolfSSL_DSA_do_sign_ex
|
---|
104 | #define DSA_do_verify wolfSSL_DSA_do_verify_ex
|
---|
105 |
|
---|
106 |
|
---|
107 | #define DSA_SIG WOLFSSL_DSA_SIG
|
---|
108 |
|
---|
109 | #ifdef __cplusplus
|
---|
110 | } /* extern "C" */
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | #endif /* header */
|
---|