1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
.Dd $Mdocdate: November 5 2016 $
.Dt DSA 3
.Os
.Sh NAME
.Nm dsa
.Nd Digital Signature Algorithm
.Sh SYNOPSIS
.In openssl/dsa.h
.In openssl/engine.h
.Ft DSA *
.Fn DSA_new void
.Ft void
.Fo DSA_free
.Fa "DSA *dsa"
.Fc
.Ft int
.Fo DSA_size
.Fa "const DSA *dsa"
.Fc
.Ft DSA *
.Fo DSA_generate_parameters
.Fa "int bits"
.Fa "unsigned char *seed"
.Fa "int seed_len"
.Fa "int *counter_ret"
.Fa "unsigned long *h_ret"
.Fa "void (*callback)(int, int, void *)"
.Fa "void *cb_arg"
.Fc
.Ft DH *
.Fo DSA_dup_DH
.Fa "const DSA *r"
.Fc
.Ft int
.Fo DSA_generate_key
.Fa "DSA *dsa"
.Fc
.Ft int
.Fo DSA_sign
.Fa "int dummy"
.Fa "const unsigned char *dgst"
.Fa "int len"
.Fa "unsigned char *sigret"
.Fa "unsigned int *siglen"
.Fa "DSA *dsa"
.Fc
.Ft int
.Fo DSA_sign_setup
.Fa "DSA *dsa"
.Fa "BN_CTX *ctx"
.Fa "BIGNUM **kinvp"
.Fa "BIGNUM **rp"
.Fc
.Ft int
.Fo DSA_verify
.Fa "int dummy"
.Fa "const unsigned char *dgst"
.Fa "int len"
.Fa "const unsigned char *sigbuf"
.Fa "int siglen"
.Fa "DSA *dsa"
.Fc
.Ft void
.Fo DSA_set_default_method
.Fa "const DSA_METHOD *meth"
.Fc
.Ft const DSA_METHOD *
.Fn DSA_get_default_method void
.Ft int
.Fo DSA_set_method
.Fa "DSA *dsa"
.Fa "const DSA_METHOD *meth"
.Fc
.Ft DSA *
.Fo DSA_new_method
.Fa "ENGINE *engine"
.Fc
.Ft const DSA_METHOD *
.Fn DSA_OpenSSL void
.Ft int
.Fo DSA_get_ex_new_index
.Fa "long argl"
.Fa "char *argp"
.Fa "int (*new_func)()"
.Fa "int (*dup_func)()"
.Fa "void (*free_func)()"
.Fc
.Ft int
.Fo DSA_set_ex_data
.Fa "DSA *d"
.Fa "int idx"
.Fa "char *arg"
.Fc
.Ft char *
.Fo DSA_get_ex_data
.Fa "DSA *d"
.Fa "int idx"
.Fc
.Ft DSA_SIG *
.Fn DSA_SIG_new void
.Ft void
.Fo DSA_SIG_free
.Fa "DSA_SIG *a"
.Fc
.Ft int
.Fo i2d_DSA_SIG
.Fa "const DSA_SIG *a"
.Fa "unsigned char **pp"
.Fc
.Ft DSA_SIG *
.Fo d2i_DSA_SIG
.Fa "DSA_SIG **v"
.Fa "unsigned char **pp"
.Fa "long length"
.Fc
.Ft DSA_SIG *
.Fo DSA_do_sign
.Fa "const unsigned char *dgst"
.Fa "int dlen"
.Fa "DSA *dsa"
.Fc
.Ft int
.Fo DSA_do_verify
.Fa "const unsigned char *dgst"
.Fa "int dgst_len"
.Fa "DSA_SIG *sig"
.Fa "DSA *dsa"
.Fc
.Ft DSA *
.Fo d2i_DSAPublicKey
.Fa "DSA **a"
.Fa "unsigned char **pp"
.Fa "long length"
.Fc
.Ft DSA *
.Fo d2i_DSAPrivateKey
.Fa "DSA **a"
.Fa "unsigned char **pp"
.Fa "long length"
.Fc
.Ft DSA *
.Fo d2i_DSAparams
.Fa "DSA **a"
.Fa "unsigned char **pp"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_DSAPublicKey
.Fa "const DSA *a"
.Fa "unsigned char **pp"
.Fc
.Ft int
.Fo i2d_DSAPrivateKey
.Fa "const DSA *a"
.Fa "unsigned char **pp"
.Fc
.Ft int
.Fo i2d_DSAparams
.Fa "const DSA *a"
.Fa "unsigned char **pp"
.Fc
.Ft int
.Fo DSAparams_print
.Fa "BIO *bp"
.Fa "const DSA *x"
.Fc
.Ft int
.Fo DSAparams_print_fp
.Fa "FILE *fp"
.Fa "const DSA *x"
.Fc
.Ft int
.Fo DSA_print
.Fa "BIO *bp"
.Fa "const DSA *x"
.Fa "int off"
.Fc
.Ft int
.Fo DSA_print_fp
.Fa "FILE *bp"
.Fa "const DSA *x"
.Fa "int off"
.Fc
.Sh DESCRIPTION
These functions implement the Digital Signature Algorithm (DSA).
The generation of shared DSA parameters is described in
.Xr DSA_generate_parameters 3 ;
.Xr DSA_generate_key 3
describes how to generate a signature key.
Signature generation and verification are described in
.Xr DSA_sign 3 .
.Pp
The
.Vt DSA
structure consists of several BIGNUM components.
.Bd -literal
typedef struct {
BIGNUM *p; // prime number (public)
BIGNUM *q; // 160-bit subprime, q | p-1 (public)
BIGNUM *g; // generator of subgroup (public)
BIGNUM *priv_key; // private key x
BIGNUM *pub_key; // public key y = g^x
// ...
} DSA;
.Ed
.Pp
In public keys,
.Fa priv_key
is
.Dv NULL .
.Pp
Note that DSA keys may use non-standard
.Vt DSA_METHOD
implementations, either directly or by the use of
.Vt ENGINE
modules.
In some cases (eg. an
.Vt ENGINE
providing support for hardware-embedded keys), these
.Vt BIGNUM
values will not be used by the implementation or may be used for
alternative data storage.
For this reason, applications should generally avoid using
.Vt DSA
structure elements directly and instead use API functions to query
or modify keys.
.Sh SEE ALSO
.Xr bn 3 ,
.Xr dh 3 ,
.Xr DSA_dup_DH 3 ,
.Xr DSA_generate_key 3 ,
.Xr DSA_generate_parameters 3 ,
.Xr DSA_get_ex_new_index 3 ,
.Xr DSA_new 3 ,
.Xr DSA_set_method 3 ,
.Xr DSA_sign 3 ,
.Xr DSA_size 3 ,
.Xr engine 3 ,
.Xr err 3 ,
.Xr rsa 3 ,
.Xr RSA_print 3
.Sh STANDARDS
US Federal Information Processing Standard FIPS 186 (Digital Signature
Standard, DSS), ANSI X9.30
|