1*0a6a1f1dSLionel Sambuc /*
2*0a6a1f1dSLionel Sambuc * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
3*0a6a1f1dSLionel Sambuc * 2006.
4ebfedea0SLionel Sambuc */
5ebfedea0SLionel Sambuc /* ====================================================================
6ebfedea0SLionel Sambuc * Copyright (c) 2006 The OpenSSL Project. All rights reserved.
7ebfedea0SLionel Sambuc *
8ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without
9ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions
10ebfedea0SLionel Sambuc * are met:
11ebfedea0SLionel Sambuc *
12ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
13ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer.
14ebfedea0SLionel Sambuc *
15ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
16ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer in
17ebfedea0SLionel Sambuc * the documentation and/or other materials provided with the
18ebfedea0SLionel Sambuc * distribution.
19ebfedea0SLionel Sambuc *
20ebfedea0SLionel Sambuc * 3. All advertising materials mentioning features or use of this
21ebfedea0SLionel Sambuc * software must display the following acknowledgment:
22ebfedea0SLionel Sambuc * "This product includes software developed by the OpenSSL Project
23ebfedea0SLionel Sambuc * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24ebfedea0SLionel Sambuc *
25ebfedea0SLionel Sambuc * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26ebfedea0SLionel Sambuc * endorse or promote products derived from this software without
27ebfedea0SLionel Sambuc * prior written permission. For written permission, please contact
28ebfedea0SLionel Sambuc * licensing@OpenSSL.org.
29ebfedea0SLionel Sambuc *
30ebfedea0SLionel Sambuc * 5. Products derived from this software may not be called "OpenSSL"
31ebfedea0SLionel Sambuc * nor may "OpenSSL" appear in their names without prior written
32ebfedea0SLionel Sambuc * permission of the OpenSSL Project.
33ebfedea0SLionel Sambuc *
34ebfedea0SLionel Sambuc * 6. Redistributions of any form whatsoever must retain the following
35ebfedea0SLionel Sambuc * acknowledgment:
36ebfedea0SLionel Sambuc * "This product includes software developed by the OpenSSL Project
37ebfedea0SLionel Sambuc * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38ebfedea0SLionel Sambuc *
39ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40ebfedea0SLionel Sambuc * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41ebfedea0SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42ebfedea0SLionel Sambuc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43ebfedea0SLionel Sambuc * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44ebfedea0SLionel Sambuc * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45ebfedea0SLionel Sambuc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46ebfedea0SLionel Sambuc * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48ebfedea0SLionel Sambuc * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49ebfedea0SLionel Sambuc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50ebfedea0SLionel Sambuc * OF THE POSSIBILITY OF SUCH DAMAGE.
51ebfedea0SLionel Sambuc * ====================================================================
52ebfedea0SLionel Sambuc *
53ebfedea0SLionel Sambuc * This product includes cryptographic software written by Eric Young
54ebfedea0SLionel Sambuc * (eay@cryptsoft.com). This product includes software written by Tim
55ebfedea0SLionel Sambuc * Hudson (tjh@cryptsoft.com).
56ebfedea0SLionel Sambuc *
57ebfedea0SLionel Sambuc */
58ebfedea0SLionel Sambuc
59ebfedea0SLionel Sambuc #include <stdio.h>
60ebfedea0SLionel Sambuc #include "cryptlib.h"
61ebfedea0SLionel Sambuc #include <openssl/x509.h>
62ebfedea0SLionel Sambuc #include <openssl/asn1.h>
63ebfedea0SLionel Sambuc #include <openssl/dsa.h>
64ebfedea0SLionel Sambuc #include <openssl/bn.h>
65ebfedea0SLionel Sambuc #ifndef OPENSSL_NO_CMS
66ebfedea0SLionel Sambuc # include <openssl/cms.h>
67ebfedea0SLionel Sambuc #endif
68ebfedea0SLionel Sambuc #include "asn1_locl.h"
69ebfedea0SLionel Sambuc
dsa_pub_decode(EVP_PKEY * pkey,X509_PUBKEY * pubkey)70ebfedea0SLionel Sambuc static int dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
71ebfedea0SLionel Sambuc {
72ebfedea0SLionel Sambuc const unsigned char *p, *pm;
73ebfedea0SLionel Sambuc int pklen, pmlen;
74ebfedea0SLionel Sambuc int ptype;
75ebfedea0SLionel Sambuc void *pval;
76ebfedea0SLionel Sambuc ASN1_STRING *pstr;
77ebfedea0SLionel Sambuc X509_ALGOR *palg;
78ebfedea0SLionel Sambuc ASN1_INTEGER *public_key = NULL;
79ebfedea0SLionel Sambuc
80ebfedea0SLionel Sambuc DSA *dsa = NULL;
81ebfedea0SLionel Sambuc
82ebfedea0SLionel Sambuc if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey))
83ebfedea0SLionel Sambuc return 0;
84ebfedea0SLionel Sambuc X509_ALGOR_get0(NULL, &ptype, &pval, palg);
85ebfedea0SLionel Sambuc
86*0a6a1f1dSLionel Sambuc if (ptype == V_ASN1_SEQUENCE) {
87ebfedea0SLionel Sambuc pstr = pval;
88ebfedea0SLionel Sambuc pm = pstr->data;
89ebfedea0SLionel Sambuc pmlen = pstr->length;
90ebfedea0SLionel Sambuc
91*0a6a1f1dSLionel Sambuc if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) {
92ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR);
93ebfedea0SLionel Sambuc goto err;
94ebfedea0SLionel Sambuc }
95ebfedea0SLionel Sambuc
96*0a6a1f1dSLionel Sambuc } else if ((ptype == V_ASN1_NULL) || (ptype == V_ASN1_UNDEF)) {
97*0a6a1f1dSLionel Sambuc if (!(dsa = DSA_new())) {
98ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PUB_DECODE, ERR_R_MALLOC_FAILURE);
99ebfedea0SLionel Sambuc goto err;
100ebfedea0SLionel Sambuc }
101*0a6a1f1dSLionel Sambuc } else {
102ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_PARAMETER_ENCODING_ERROR);
103ebfedea0SLionel Sambuc goto err;
104ebfedea0SLionel Sambuc }
105ebfedea0SLionel Sambuc
106*0a6a1f1dSLionel Sambuc if (!(public_key = d2i_ASN1_INTEGER(NULL, &p, pklen))) {
107ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR);
108ebfedea0SLionel Sambuc goto err;
109ebfedea0SLionel Sambuc }
110ebfedea0SLionel Sambuc
111*0a6a1f1dSLionel Sambuc if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) {
112ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_BN_DECODE_ERROR);
113ebfedea0SLionel Sambuc goto err;
114ebfedea0SLionel Sambuc }
115ebfedea0SLionel Sambuc
116ebfedea0SLionel Sambuc ASN1_INTEGER_free(public_key);
117ebfedea0SLionel Sambuc EVP_PKEY_assign_DSA(pkey, dsa);
118ebfedea0SLionel Sambuc return 1;
119ebfedea0SLionel Sambuc
120ebfedea0SLionel Sambuc err:
121ebfedea0SLionel Sambuc if (public_key)
122ebfedea0SLionel Sambuc ASN1_INTEGER_free(public_key);
123ebfedea0SLionel Sambuc if (dsa)
124ebfedea0SLionel Sambuc DSA_free(dsa);
125ebfedea0SLionel Sambuc return 0;
126ebfedea0SLionel Sambuc
127ebfedea0SLionel Sambuc }
128ebfedea0SLionel Sambuc
dsa_pub_encode(X509_PUBKEY * pk,const EVP_PKEY * pkey)129ebfedea0SLionel Sambuc static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
130ebfedea0SLionel Sambuc {
131ebfedea0SLionel Sambuc DSA *dsa;
132ebfedea0SLionel Sambuc int ptype;
133ebfedea0SLionel Sambuc unsigned char *penc = NULL;
134ebfedea0SLionel Sambuc int penclen;
135*0a6a1f1dSLionel Sambuc ASN1_STRING *str = NULL;
136ebfedea0SLionel Sambuc
137ebfedea0SLionel Sambuc dsa = pkey->pkey.dsa;
138*0a6a1f1dSLionel Sambuc if (pkey->save_parameters && dsa->p && dsa->q && dsa->g) {
139ebfedea0SLionel Sambuc str = ASN1_STRING_new();
140*0a6a1f1dSLionel Sambuc if (!str) {
141ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
142ebfedea0SLionel Sambuc goto err;
143ebfedea0SLionel Sambuc }
144*0a6a1f1dSLionel Sambuc str->length = i2d_DSAparams(dsa, &str->data);
145*0a6a1f1dSLionel Sambuc if (str->length <= 0) {
146*0a6a1f1dSLionel Sambuc DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
147*0a6a1f1dSLionel Sambuc goto err;
148ebfedea0SLionel Sambuc }
149*0a6a1f1dSLionel Sambuc ptype = V_ASN1_SEQUENCE;
150*0a6a1f1dSLionel Sambuc } else
151ebfedea0SLionel Sambuc ptype = V_ASN1_UNDEF;
152ebfedea0SLionel Sambuc
153ebfedea0SLionel Sambuc dsa->write_params = 0;
154ebfedea0SLionel Sambuc
155ebfedea0SLionel Sambuc penclen = i2d_DSAPublicKey(dsa, &penc);
156ebfedea0SLionel Sambuc
157*0a6a1f1dSLionel Sambuc if (penclen <= 0) {
158ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
159ebfedea0SLionel Sambuc goto err;
160ebfedea0SLionel Sambuc }
161ebfedea0SLionel Sambuc
162ebfedea0SLionel Sambuc if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_DSA),
163*0a6a1f1dSLionel Sambuc ptype, str, penc, penclen))
164ebfedea0SLionel Sambuc return 1;
165ebfedea0SLionel Sambuc
166ebfedea0SLionel Sambuc err:
167ebfedea0SLionel Sambuc if (penc)
168ebfedea0SLionel Sambuc OPENSSL_free(penc);
169*0a6a1f1dSLionel Sambuc if (str)
170*0a6a1f1dSLionel Sambuc ASN1_STRING_free(str);
171ebfedea0SLionel Sambuc
172ebfedea0SLionel Sambuc return 0;
173ebfedea0SLionel Sambuc }
174ebfedea0SLionel Sambuc
175*0a6a1f1dSLionel Sambuc /*
176*0a6a1f1dSLionel Sambuc * In PKCS#8 DSA: you just get a private key integer and parameters in the
177ebfedea0SLionel Sambuc * AlgorithmIdentifier the pubkey must be recalculated.
178ebfedea0SLionel Sambuc */
179ebfedea0SLionel Sambuc
dsa_priv_decode(EVP_PKEY * pkey,PKCS8_PRIV_KEY_INFO * p8)180ebfedea0SLionel Sambuc static int dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8)
181ebfedea0SLionel Sambuc {
182ebfedea0SLionel Sambuc const unsigned char *p, *pm;
183ebfedea0SLionel Sambuc int pklen, pmlen;
184ebfedea0SLionel Sambuc int ptype;
185ebfedea0SLionel Sambuc void *pval;
186ebfedea0SLionel Sambuc ASN1_STRING *pstr;
187ebfedea0SLionel Sambuc X509_ALGOR *palg;
188ebfedea0SLionel Sambuc ASN1_INTEGER *privkey = NULL;
189ebfedea0SLionel Sambuc BN_CTX *ctx = NULL;
190ebfedea0SLionel Sambuc
191ebfedea0SLionel Sambuc STACK_OF(ASN1_TYPE) *ndsa = NULL;
192ebfedea0SLionel Sambuc DSA *dsa = NULL;
193ebfedea0SLionel Sambuc
194ebfedea0SLionel Sambuc if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8))
195ebfedea0SLionel Sambuc return 0;
196ebfedea0SLionel Sambuc X509_ALGOR_get0(NULL, &ptype, &pval, palg);
197ebfedea0SLionel Sambuc
198ebfedea0SLionel Sambuc /* Check for broken DSA PKCS#8, UGH! */
199*0a6a1f1dSLionel Sambuc if (*p == (V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED)) {
200ebfedea0SLionel Sambuc ASN1_TYPE *t1, *t2;
201ebfedea0SLionel Sambuc if (!(ndsa = d2i_ASN1_SEQUENCE_ANY(NULL, &p, pklen)))
202ebfedea0SLionel Sambuc goto decerr;
203ebfedea0SLionel Sambuc if (sk_ASN1_TYPE_num(ndsa) != 2)
204ebfedea0SLionel Sambuc goto decerr;
205*0a6a1f1dSLionel Sambuc /*-
206*0a6a1f1dSLionel Sambuc * Handle Two broken types:
207ebfedea0SLionel Sambuc * SEQUENCE {parameters, priv_key}
208ebfedea0SLionel Sambuc * SEQUENCE {pub_key, priv_key}
209ebfedea0SLionel Sambuc */
210ebfedea0SLionel Sambuc
211ebfedea0SLionel Sambuc t1 = sk_ASN1_TYPE_value(ndsa, 0);
212ebfedea0SLionel Sambuc t2 = sk_ASN1_TYPE_value(ndsa, 1);
213*0a6a1f1dSLionel Sambuc if (t1->type == V_ASN1_SEQUENCE) {
214ebfedea0SLionel Sambuc p8->broken = PKCS8_EMBEDDED_PARAM;
215ebfedea0SLionel Sambuc pval = t1->value.ptr;
216*0a6a1f1dSLionel Sambuc } else if (ptype == V_ASN1_SEQUENCE)
217ebfedea0SLionel Sambuc p8->broken = PKCS8_NS_DB;
218ebfedea0SLionel Sambuc else
219ebfedea0SLionel Sambuc goto decerr;
220ebfedea0SLionel Sambuc
221ebfedea0SLionel Sambuc if (t2->type != V_ASN1_INTEGER)
222ebfedea0SLionel Sambuc goto decerr;
223ebfedea0SLionel Sambuc
224ebfedea0SLionel Sambuc privkey = t2->value.integer;
225*0a6a1f1dSLionel Sambuc } else {
226ebfedea0SLionel Sambuc const unsigned char *q = p;
227ebfedea0SLionel Sambuc if (!(privkey = d2i_ASN1_INTEGER(NULL, &p, pklen)))
228ebfedea0SLionel Sambuc goto decerr;
229*0a6a1f1dSLionel Sambuc if (privkey->type == V_ASN1_NEG_INTEGER) {
230ebfedea0SLionel Sambuc p8->broken = PKCS8_NEG_PRIVKEY;
231*0a6a1f1dSLionel Sambuc ASN1_STRING_clear_free(privkey);
232ebfedea0SLionel Sambuc if (!(privkey = d2i_ASN1_UINTEGER(NULL, &q, pklen)))
233ebfedea0SLionel Sambuc goto decerr;
234ebfedea0SLionel Sambuc }
235ebfedea0SLionel Sambuc if (ptype != V_ASN1_SEQUENCE)
236ebfedea0SLionel Sambuc goto decerr;
237ebfedea0SLionel Sambuc }
238ebfedea0SLionel Sambuc
239ebfedea0SLionel Sambuc pstr = pval;
240ebfedea0SLionel Sambuc pm = pstr->data;
241ebfedea0SLionel Sambuc pmlen = pstr->length;
242ebfedea0SLionel Sambuc if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen)))
243ebfedea0SLionel Sambuc goto decerr;
244ebfedea0SLionel Sambuc /* We have parameters now set private key */
245*0a6a1f1dSLionel Sambuc if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) {
246ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_BN_ERROR);
247ebfedea0SLionel Sambuc goto dsaerr;
248ebfedea0SLionel Sambuc }
249ebfedea0SLionel Sambuc /* Calculate public key */
250*0a6a1f1dSLionel Sambuc if (!(dsa->pub_key = BN_new())) {
251ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE);
252ebfedea0SLionel Sambuc goto dsaerr;
253ebfedea0SLionel Sambuc }
254*0a6a1f1dSLionel Sambuc if (!(ctx = BN_CTX_new())) {
255ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE);
256ebfedea0SLionel Sambuc goto dsaerr;
257ebfedea0SLionel Sambuc }
258ebfedea0SLionel Sambuc
259*0a6a1f1dSLionel Sambuc if (!BN_mod_exp(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) {
260ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_BN_ERROR);
261ebfedea0SLionel Sambuc goto dsaerr;
262ebfedea0SLionel Sambuc }
263ebfedea0SLionel Sambuc
264ebfedea0SLionel Sambuc EVP_PKEY_assign_DSA(pkey, dsa);
265ebfedea0SLionel Sambuc BN_CTX_free(ctx);
266ebfedea0SLionel Sambuc if (ndsa)
267ebfedea0SLionel Sambuc sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
268ebfedea0SLionel Sambuc else
269*0a6a1f1dSLionel Sambuc ASN1_STRING_clear_free(privkey);
270ebfedea0SLionel Sambuc
271ebfedea0SLionel Sambuc return 1;
272ebfedea0SLionel Sambuc
273ebfedea0SLionel Sambuc decerr:
274ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PRIV_DECODE, EVP_R_DECODE_ERROR);
275ebfedea0SLionel Sambuc dsaerr:
276ebfedea0SLionel Sambuc BN_CTX_free(ctx);
277ebfedea0SLionel Sambuc if (privkey)
278*0a6a1f1dSLionel Sambuc ASN1_STRING_clear_free(privkey);
279ebfedea0SLionel Sambuc sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
280ebfedea0SLionel Sambuc DSA_free(dsa);
281ebfedea0SLionel Sambuc return 0;
282ebfedea0SLionel Sambuc }
283ebfedea0SLionel Sambuc
dsa_priv_encode(PKCS8_PRIV_KEY_INFO * p8,const EVP_PKEY * pkey)284ebfedea0SLionel Sambuc static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
285ebfedea0SLionel Sambuc {
286ebfedea0SLionel Sambuc ASN1_STRING *params = NULL;
287ebfedea0SLionel Sambuc ASN1_INTEGER *prkey = NULL;
288ebfedea0SLionel Sambuc unsigned char *dp = NULL;
289ebfedea0SLionel Sambuc int dplen;
290ebfedea0SLionel Sambuc
291*0a6a1f1dSLionel Sambuc if (!pkey->pkey.dsa || !pkey->pkey.dsa->priv_key) {
292*0a6a1f1dSLionel Sambuc DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_MISSING_PARAMETERS);
293*0a6a1f1dSLionel Sambuc goto err;
294*0a6a1f1dSLionel Sambuc }
295*0a6a1f1dSLionel Sambuc
296ebfedea0SLionel Sambuc params = ASN1_STRING_new();
297ebfedea0SLionel Sambuc
298*0a6a1f1dSLionel Sambuc if (!params) {
299ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);
300ebfedea0SLionel Sambuc goto err;
301ebfedea0SLionel Sambuc }
302ebfedea0SLionel Sambuc
303ebfedea0SLionel Sambuc params->length = i2d_DSAparams(pkey->pkey.dsa, ¶ms->data);
304*0a6a1f1dSLionel Sambuc if (params->length <= 0) {
305ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);
306ebfedea0SLionel Sambuc goto err;
307ebfedea0SLionel Sambuc }
308ebfedea0SLionel Sambuc params->type = V_ASN1_SEQUENCE;
309ebfedea0SLionel Sambuc
310ebfedea0SLionel Sambuc /* Get private key into integer */
311ebfedea0SLionel Sambuc prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, NULL);
312ebfedea0SLionel Sambuc
313*0a6a1f1dSLionel Sambuc if (!prkey) {
314ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_BN_ERROR);
315ebfedea0SLionel Sambuc goto err;
316ebfedea0SLionel Sambuc }
317ebfedea0SLionel Sambuc
318ebfedea0SLionel Sambuc dplen = i2d_ASN1_INTEGER(prkey, &dp);
319ebfedea0SLionel Sambuc
320*0a6a1f1dSLionel Sambuc ASN1_STRING_clear_free(prkey);
321ebfedea0SLionel Sambuc
322ebfedea0SLionel Sambuc if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_dsa), 0,
323ebfedea0SLionel Sambuc V_ASN1_SEQUENCE, params, dp, dplen))
324ebfedea0SLionel Sambuc goto err;
325ebfedea0SLionel Sambuc
326ebfedea0SLionel Sambuc return 1;
327ebfedea0SLionel Sambuc
328ebfedea0SLionel Sambuc err:
329ebfedea0SLionel Sambuc if (dp != NULL)
330ebfedea0SLionel Sambuc OPENSSL_free(dp);
331ebfedea0SLionel Sambuc if (params != NULL)
332ebfedea0SLionel Sambuc ASN1_STRING_free(params);
333ebfedea0SLionel Sambuc if (prkey != NULL)
334*0a6a1f1dSLionel Sambuc ASN1_STRING_clear_free(prkey);
335ebfedea0SLionel Sambuc return 0;
336ebfedea0SLionel Sambuc }
337ebfedea0SLionel Sambuc
int_dsa_size(const EVP_PKEY * pkey)338ebfedea0SLionel Sambuc static int int_dsa_size(const EVP_PKEY *pkey)
339ebfedea0SLionel Sambuc {
340ebfedea0SLionel Sambuc return (DSA_size(pkey->pkey.dsa));
341ebfedea0SLionel Sambuc }
342ebfedea0SLionel Sambuc
dsa_bits(const EVP_PKEY * pkey)343ebfedea0SLionel Sambuc static int dsa_bits(const EVP_PKEY *pkey)
344ebfedea0SLionel Sambuc {
345ebfedea0SLionel Sambuc return BN_num_bits(pkey->pkey.dsa->p);
346ebfedea0SLionel Sambuc }
347ebfedea0SLionel Sambuc
dsa_missing_parameters(const EVP_PKEY * pkey)348ebfedea0SLionel Sambuc static int dsa_missing_parameters(const EVP_PKEY *pkey)
349ebfedea0SLionel Sambuc {
350ebfedea0SLionel Sambuc DSA *dsa;
351ebfedea0SLionel Sambuc dsa = pkey->pkey.dsa;
352ebfedea0SLionel Sambuc if ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL))
353ebfedea0SLionel Sambuc return 1;
354ebfedea0SLionel Sambuc return 0;
355ebfedea0SLionel Sambuc }
356ebfedea0SLionel Sambuc
dsa_copy_parameters(EVP_PKEY * to,const EVP_PKEY * from)357ebfedea0SLionel Sambuc static int dsa_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
358ebfedea0SLionel Sambuc {
359ebfedea0SLionel Sambuc BIGNUM *a;
360ebfedea0SLionel Sambuc
361ebfedea0SLionel Sambuc if ((a = BN_dup(from->pkey.dsa->p)) == NULL)
362ebfedea0SLionel Sambuc return 0;
363ebfedea0SLionel Sambuc if (to->pkey.dsa->p != NULL)
364ebfedea0SLionel Sambuc BN_free(to->pkey.dsa->p);
365ebfedea0SLionel Sambuc to->pkey.dsa->p = a;
366ebfedea0SLionel Sambuc
367ebfedea0SLionel Sambuc if ((a = BN_dup(from->pkey.dsa->q)) == NULL)
368ebfedea0SLionel Sambuc return 0;
369ebfedea0SLionel Sambuc if (to->pkey.dsa->q != NULL)
370ebfedea0SLionel Sambuc BN_free(to->pkey.dsa->q);
371ebfedea0SLionel Sambuc to->pkey.dsa->q = a;
372ebfedea0SLionel Sambuc
373ebfedea0SLionel Sambuc if ((a = BN_dup(from->pkey.dsa->g)) == NULL)
374ebfedea0SLionel Sambuc return 0;
375ebfedea0SLionel Sambuc if (to->pkey.dsa->g != NULL)
376ebfedea0SLionel Sambuc BN_free(to->pkey.dsa->g);
377ebfedea0SLionel Sambuc to->pkey.dsa->g = a;
378ebfedea0SLionel Sambuc return 1;
379ebfedea0SLionel Sambuc }
380ebfedea0SLionel Sambuc
dsa_cmp_parameters(const EVP_PKEY * a,const EVP_PKEY * b)381ebfedea0SLionel Sambuc static int dsa_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
382ebfedea0SLionel Sambuc {
383ebfedea0SLionel Sambuc if (BN_cmp(a->pkey.dsa->p, b->pkey.dsa->p) ||
384ebfedea0SLionel Sambuc BN_cmp(a->pkey.dsa->q, b->pkey.dsa->q) ||
385ebfedea0SLionel Sambuc BN_cmp(a->pkey.dsa->g, b->pkey.dsa->g))
386ebfedea0SLionel Sambuc return 0;
387ebfedea0SLionel Sambuc else
388ebfedea0SLionel Sambuc return 1;
389ebfedea0SLionel Sambuc }
390ebfedea0SLionel Sambuc
dsa_pub_cmp(const EVP_PKEY * a,const EVP_PKEY * b)391ebfedea0SLionel Sambuc static int dsa_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
392ebfedea0SLionel Sambuc {
393ebfedea0SLionel Sambuc if (BN_cmp(b->pkey.dsa->pub_key, a->pkey.dsa->pub_key) != 0)
394ebfedea0SLionel Sambuc return 0;
395ebfedea0SLionel Sambuc else
396ebfedea0SLionel Sambuc return 1;
397ebfedea0SLionel Sambuc }
398ebfedea0SLionel Sambuc
int_dsa_free(EVP_PKEY * pkey)399ebfedea0SLionel Sambuc static void int_dsa_free(EVP_PKEY *pkey)
400ebfedea0SLionel Sambuc {
401ebfedea0SLionel Sambuc DSA_free(pkey->pkey.dsa);
402ebfedea0SLionel Sambuc }
403ebfedea0SLionel Sambuc
update_buflen(const BIGNUM * b,size_t * pbuflen)404ebfedea0SLionel Sambuc static void update_buflen(const BIGNUM *b, size_t *pbuflen)
405ebfedea0SLionel Sambuc {
406ebfedea0SLionel Sambuc size_t i;
407ebfedea0SLionel Sambuc if (!b)
408ebfedea0SLionel Sambuc return;
409ebfedea0SLionel Sambuc if (*pbuflen < (i = (size_t)BN_num_bytes(b)))
410ebfedea0SLionel Sambuc *pbuflen = i;
411ebfedea0SLionel Sambuc }
412ebfedea0SLionel Sambuc
do_dsa_print(BIO * bp,const DSA * x,int off,int ptype)413ebfedea0SLionel Sambuc static int do_dsa_print(BIO *bp, const DSA *x, int off, int ptype)
414ebfedea0SLionel Sambuc {
415ebfedea0SLionel Sambuc unsigned char *m = NULL;
416ebfedea0SLionel Sambuc int ret = 0;
417ebfedea0SLionel Sambuc size_t buf_len = 0;
418ebfedea0SLionel Sambuc const char *ktype = NULL;
419ebfedea0SLionel Sambuc
420ebfedea0SLionel Sambuc const BIGNUM *priv_key, *pub_key;
421ebfedea0SLionel Sambuc
422ebfedea0SLionel Sambuc if (ptype == 2)
423ebfedea0SLionel Sambuc priv_key = x->priv_key;
424ebfedea0SLionel Sambuc else
425ebfedea0SLionel Sambuc priv_key = NULL;
426ebfedea0SLionel Sambuc
427ebfedea0SLionel Sambuc if (ptype > 0)
428ebfedea0SLionel Sambuc pub_key = x->pub_key;
429ebfedea0SLionel Sambuc else
430ebfedea0SLionel Sambuc pub_key = NULL;
431ebfedea0SLionel Sambuc
432ebfedea0SLionel Sambuc if (ptype == 2)
433ebfedea0SLionel Sambuc ktype = "Private-Key";
434ebfedea0SLionel Sambuc else if (ptype == 1)
435ebfedea0SLionel Sambuc ktype = "Public-Key";
436ebfedea0SLionel Sambuc else
437ebfedea0SLionel Sambuc ktype = "DSA-Parameters";
438ebfedea0SLionel Sambuc
439ebfedea0SLionel Sambuc update_buflen(x->p, &buf_len);
440ebfedea0SLionel Sambuc update_buflen(x->q, &buf_len);
441ebfedea0SLionel Sambuc update_buflen(x->g, &buf_len);
442ebfedea0SLionel Sambuc update_buflen(priv_key, &buf_len);
443ebfedea0SLionel Sambuc update_buflen(pub_key, &buf_len);
444ebfedea0SLionel Sambuc
445ebfedea0SLionel Sambuc m = (unsigned char *)OPENSSL_malloc(buf_len + 10);
446*0a6a1f1dSLionel Sambuc if (m == NULL) {
447ebfedea0SLionel Sambuc DSAerr(DSA_F_DO_DSA_PRINT, ERR_R_MALLOC_FAILURE);
448ebfedea0SLionel Sambuc goto err;
449ebfedea0SLionel Sambuc }
450ebfedea0SLionel Sambuc
451*0a6a1f1dSLionel Sambuc if (priv_key) {
452ebfedea0SLionel Sambuc if (!BIO_indent(bp, off, 128))
453ebfedea0SLionel Sambuc goto err;
454ebfedea0SLionel Sambuc if (BIO_printf(bp, "%s: (%d bit)\n", ktype, BN_num_bits(x->p))
455*0a6a1f1dSLionel Sambuc <= 0)
456*0a6a1f1dSLionel Sambuc goto err;
457ebfedea0SLionel Sambuc }
458ebfedea0SLionel Sambuc
459ebfedea0SLionel Sambuc if (!ASN1_bn_print(bp, "priv:", priv_key, m, off))
460ebfedea0SLionel Sambuc goto err;
461ebfedea0SLionel Sambuc if (!ASN1_bn_print(bp, "pub: ", pub_key, m, off))
462ebfedea0SLionel Sambuc goto err;
463*0a6a1f1dSLionel Sambuc if (!ASN1_bn_print(bp, "P: ", x->p, m, off))
464*0a6a1f1dSLionel Sambuc goto err;
465*0a6a1f1dSLionel Sambuc if (!ASN1_bn_print(bp, "Q: ", x->q, m, off))
466*0a6a1f1dSLionel Sambuc goto err;
467*0a6a1f1dSLionel Sambuc if (!ASN1_bn_print(bp, "G: ", x->g, m, off))
468*0a6a1f1dSLionel Sambuc goto err;
469ebfedea0SLionel Sambuc ret = 1;
470ebfedea0SLionel Sambuc err:
471*0a6a1f1dSLionel Sambuc if (m != NULL)
472*0a6a1f1dSLionel Sambuc OPENSSL_free(m);
473ebfedea0SLionel Sambuc return (ret);
474ebfedea0SLionel Sambuc }
475ebfedea0SLionel Sambuc
dsa_param_decode(EVP_PKEY * pkey,const unsigned char ** pder,int derlen)476ebfedea0SLionel Sambuc static int dsa_param_decode(EVP_PKEY *pkey,
477ebfedea0SLionel Sambuc const unsigned char **pder, int derlen)
478ebfedea0SLionel Sambuc {
479ebfedea0SLionel Sambuc DSA *dsa;
480*0a6a1f1dSLionel Sambuc if (!(dsa = d2i_DSAparams(NULL, pder, derlen))) {
481ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_PARAM_DECODE, ERR_R_DSA_LIB);
482ebfedea0SLionel Sambuc return 0;
483ebfedea0SLionel Sambuc }
484ebfedea0SLionel Sambuc EVP_PKEY_assign_DSA(pkey, dsa);
485ebfedea0SLionel Sambuc return 1;
486ebfedea0SLionel Sambuc }
487ebfedea0SLionel Sambuc
dsa_param_encode(const EVP_PKEY * pkey,unsigned char ** pder)488ebfedea0SLionel Sambuc static int dsa_param_encode(const EVP_PKEY *pkey, unsigned char **pder)
489ebfedea0SLionel Sambuc {
490ebfedea0SLionel Sambuc return i2d_DSAparams(pkey->pkey.dsa, pder);
491ebfedea0SLionel Sambuc }
492ebfedea0SLionel Sambuc
dsa_param_print(BIO * bp,const EVP_PKEY * pkey,int indent,ASN1_PCTX * ctx)493ebfedea0SLionel Sambuc static int dsa_param_print(BIO *bp, const EVP_PKEY *pkey, int indent,
494ebfedea0SLionel Sambuc ASN1_PCTX *ctx)
495ebfedea0SLionel Sambuc {
496ebfedea0SLionel Sambuc return do_dsa_print(bp, pkey->pkey.dsa, indent, 0);
497ebfedea0SLionel Sambuc }
498ebfedea0SLionel Sambuc
dsa_pub_print(BIO * bp,const EVP_PKEY * pkey,int indent,ASN1_PCTX * ctx)499ebfedea0SLionel Sambuc static int dsa_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent,
500ebfedea0SLionel Sambuc ASN1_PCTX *ctx)
501ebfedea0SLionel Sambuc {
502ebfedea0SLionel Sambuc return do_dsa_print(bp, pkey->pkey.dsa, indent, 1);
503ebfedea0SLionel Sambuc }
504ebfedea0SLionel Sambuc
dsa_priv_print(BIO * bp,const EVP_PKEY * pkey,int indent,ASN1_PCTX * ctx)505ebfedea0SLionel Sambuc static int dsa_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent,
506ebfedea0SLionel Sambuc ASN1_PCTX *ctx)
507ebfedea0SLionel Sambuc {
508ebfedea0SLionel Sambuc return do_dsa_print(bp, pkey->pkey.dsa, indent, 2);
509ebfedea0SLionel Sambuc }
510ebfedea0SLionel Sambuc
old_dsa_priv_decode(EVP_PKEY * pkey,const unsigned char ** pder,int derlen)511ebfedea0SLionel Sambuc static int old_dsa_priv_decode(EVP_PKEY *pkey,
512ebfedea0SLionel Sambuc const unsigned char **pder, int derlen)
513ebfedea0SLionel Sambuc {
514ebfedea0SLionel Sambuc DSA *dsa;
515*0a6a1f1dSLionel Sambuc if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) {
516ebfedea0SLionel Sambuc DSAerr(DSA_F_OLD_DSA_PRIV_DECODE, ERR_R_DSA_LIB);
517ebfedea0SLionel Sambuc return 0;
518ebfedea0SLionel Sambuc }
519ebfedea0SLionel Sambuc EVP_PKEY_assign_DSA(pkey, dsa);
520ebfedea0SLionel Sambuc return 1;
521ebfedea0SLionel Sambuc }
522ebfedea0SLionel Sambuc
old_dsa_priv_encode(const EVP_PKEY * pkey,unsigned char ** pder)523ebfedea0SLionel Sambuc static int old_dsa_priv_encode(const EVP_PKEY *pkey, unsigned char **pder)
524ebfedea0SLionel Sambuc {
525ebfedea0SLionel Sambuc return i2d_DSAPrivateKey(pkey->pkey.dsa, pder);
526ebfedea0SLionel Sambuc }
527ebfedea0SLionel Sambuc
dsa_sig_print(BIO * bp,const X509_ALGOR * sigalg,const ASN1_STRING * sig,int indent,ASN1_PCTX * pctx)528ebfedea0SLionel Sambuc static int dsa_sig_print(BIO *bp, const X509_ALGOR *sigalg,
529*0a6a1f1dSLionel Sambuc const ASN1_STRING *sig, int indent, ASN1_PCTX *pctx)
530ebfedea0SLionel Sambuc {
531ebfedea0SLionel Sambuc DSA_SIG *dsa_sig;
532ebfedea0SLionel Sambuc const unsigned char *p;
533*0a6a1f1dSLionel Sambuc if (!sig) {
534ebfedea0SLionel Sambuc if (BIO_puts(bp, "\n") <= 0)
535ebfedea0SLionel Sambuc return 0;
536ebfedea0SLionel Sambuc else
537ebfedea0SLionel Sambuc return 1;
538ebfedea0SLionel Sambuc }
539ebfedea0SLionel Sambuc p = sig->data;
540ebfedea0SLionel Sambuc dsa_sig = d2i_DSA_SIG(NULL, &p, sig->length);
541*0a6a1f1dSLionel Sambuc if (dsa_sig) {
542ebfedea0SLionel Sambuc int rv = 0;
543ebfedea0SLionel Sambuc size_t buf_len = 0;
544ebfedea0SLionel Sambuc unsigned char *m = NULL;
545ebfedea0SLionel Sambuc update_buflen(dsa_sig->r, &buf_len);
546ebfedea0SLionel Sambuc update_buflen(dsa_sig->s, &buf_len);
547ebfedea0SLionel Sambuc m = OPENSSL_malloc(buf_len + 10);
548*0a6a1f1dSLionel Sambuc if (m == NULL) {
549ebfedea0SLionel Sambuc DSAerr(DSA_F_DSA_SIG_PRINT, ERR_R_MALLOC_FAILURE);
550ebfedea0SLionel Sambuc goto err;
551ebfedea0SLionel Sambuc }
552ebfedea0SLionel Sambuc
553ebfedea0SLionel Sambuc if (BIO_write(bp, "\n", 1) != 1)
554ebfedea0SLionel Sambuc goto err;
555ebfedea0SLionel Sambuc
556ebfedea0SLionel Sambuc if (!ASN1_bn_print(bp, "r: ", dsa_sig->r, m, indent))
557ebfedea0SLionel Sambuc goto err;
558ebfedea0SLionel Sambuc if (!ASN1_bn_print(bp, "s: ", dsa_sig->s, m, indent))
559ebfedea0SLionel Sambuc goto err;
560ebfedea0SLionel Sambuc rv = 1;
561ebfedea0SLionel Sambuc err:
562ebfedea0SLionel Sambuc if (m)
563ebfedea0SLionel Sambuc OPENSSL_free(m);
564ebfedea0SLionel Sambuc DSA_SIG_free(dsa_sig);
565ebfedea0SLionel Sambuc return rv;
566ebfedea0SLionel Sambuc }
567ebfedea0SLionel Sambuc return X509_signature_dump(bp, sig, indent);
568ebfedea0SLionel Sambuc }
569ebfedea0SLionel Sambuc
dsa_pkey_ctrl(EVP_PKEY * pkey,int op,long arg1,void * arg2)570ebfedea0SLionel Sambuc static int dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
571ebfedea0SLionel Sambuc {
572*0a6a1f1dSLionel Sambuc switch (op) {
573ebfedea0SLionel Sambuc case ASN1_PKEY_CTRL_PKCS7_SIGN:
574*0a6a1f1dSLionel Sambuc if (arg1 == 0) {
575ebfedea0SLionel Sambuc int snid, hnid;
576ebfedea0SLionel Sambuc X509_ALGOR *alg1, *alg2;
577ebfedea0SLionel Sambuc PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, &alg1, &alg2);
578ebfedea0SLionel Sambuc if (alg1 == NULL || alg1->algorithm == NULL)
579ebfedea0SLionel Sambuc return -1;
580ebfedea0SLionel Sambuc hnid = OBJ_obj2nid(alg1->algorithm);
581ebfedea0SLionel Sambuc if (hnid == NID_undef)
582ebfedea0SLionel Sambuc return -1;
583ebfedea0SLionel Sambuc if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey)))
584ebfedea0SLionel Sambuc return -1;
585ebfedea0SLionel Sambuc X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0);
586ebfedea0SLionel Sambuc }
587ebfedea0SLionel Sambuc return 1;
588ebfedea0SLionel Sambuc #ifndef OPENSSL_NO_CMS
589ebfedea0SLionel Sambuc case ASN1_PKEY_CTRL_CMS_SIGN:
590*0a6a1f1dSLionel Sambuc if (arg1 == 0) {
591ebfedea0SLionel Sambuc int snid, hnid;
592ebfedea0SLionel Sambuc X509_ALGOR *alg1, *alg2;
593ebfedea0SLionel Sambuc CMS_SignerInfo_get0_algs(arg2, NULL, NULL, &alg1, &alg2);
594ebfedea0SLionel Sambuc if (alg1 == NULL || alg1->algorithm == NULL)
595ebfedea0SLionel Sambuc return -1;
596ebfedea0SLionel Sambuc hnid = OBJ_obj2nid(alg1->algorithm);
597ebfedea0SLionel Sambuc if (hnid == NID_undef)
598ebfedea0SLionel Sambuc return -1;
599ebfedea0SLionel Sambuc if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey)))
600ebfedea0SLionel Sambuc return -1;
601ebfedea0SLionel Sambuc X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0);
602ebfedea0SLionel Sambuc }
603ebfedea0SLionel Sambuc return 1;
604ebfedea0SLionel Sambuc #endif
605ebfedea0SLionel Sambuc
606ebfedea0SLionel Sambuc case ASN1_PKEY_CTRL_DEFAULT_MD_NID:
607ebfedea0SLionel Sambuc *(int *)arg2 = NID_sha1;
608ebfedea0SLionel Sambuc return 2;
609ebfedea0SLionel Sambuc
610ebfedea0SLionel Sambuc default:
611ebfedea0SLionel Sambuc return -2;
612ebfedea0SLionel Sambuc
613ebfedea0SLionel Sambuc }
614ebfedea0SLionel Sambuc
615ebfedea0SLionel Sambuc }
616ebfedea0SLionel Sambuc
617ebfedea0SLionel Sambuc /* NB these are sorted in pkey_id order, lowest first */
618ebfedea0SLionel Sambuc
619*0a6a1f1dSLionel Sambuc const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = {
620ebfedea0SLionel Sambuc
621ebfedea0SLionel Sambuc {
622ebfedea0SLionel Sambuc EVP_PKEY_DSA2,
623ebfedea0SLionel Sambuc EVP_PKEY_DSA,
624*0a6a1f1dSLionel Sambuc ASN1_PKEY_ALIAS},
625ebfedea0SLionel Sambuc
626ebfedea0SLionel Sambuc {
627ebfedea0SLionel Sambuc EVP_PKEY_DSA1,
628ebfedea0SLionel Sambuc EVP_PKEY_DSA,
629*0a6a1f1dSLionel Sambuc ASN1_PKEY_ALIAS},
630ebfedea0SLionel Sambuc
631ebfedea0SLionel Sambuc {
632ebfedea0SLionel Sambuc EVP_PKEY_DSA4,
633ebfedea0SLionel Sambuc EVP_PKEY_DSA,
634*0a6a1f1dSLionel Sambuc ASN1_PKEY_ALIAS},
635ebfedea0SLionel Sambuc
636ebfedea0SLionel Sambuc {
637ebfedea0SLionel Sambuc EVP_PKEY_DSA3,
638ebfedea0SLionel Sambuc EVP_PKEY_DSA,
639*0a6a1f1dSLionel Sambuc ASN1_PKEY_ALIAS},
640ebfedea0SLionel Sambuc
641ebfedea0SLionel Sambuc {
642ebfedea0SLionel Sambuc EVP_PKEY_DSA,
643ebfedea0SLionel Sambuc EVP_PKEY_DSA,
644ebfedea0SLionel Sambuc 0,
645ebfedea0SLionel Sambuc
646ebfedea0SLionel Sambuc "DSA",
647ebfedea0SLionel Sambuc "OpenSSL DSA method",
648ebfedea0SLionel Sambuc
649ebfedea0SLionel Sambuc dsa_pub_decode,
650ebfedea0SLionel Sambuc dsa_pub_encode,
651ebfedea0SLionel Sambuc dsa_pub_cmp,
652ebfedea0SLionel Sambuc dsa_pub_print,
653ebfedea0SLionel Sambuc
654ebfedea0SLionel Sambuc dsa_priv_decode,
655ebfedea0SLionel Sambuc dsa_priv_encode,
656ebfedea0SLionel Sambuc dsa_priv_print,
657ebfedea0SLionel Sambuc
658ebfedea0SLionel Sambuc int_dsa_size,
659ebfedea0SLionel Sambuc dsa_bits,
660ebfedea0SLionel Sambuc
661ebfedea0SLionel Sambuc dsa_param_decode,
662ebfedea0SLionel Sambuc dsa_param_encode,
663ebfedea0SLionel Sambuc dsa_missing_parameters,
664ebfedea0SLionel Sambuc dsa_copy_parameters,
665ebfedea0SLionel Sambuc dsa_cmp_parameters,
666ebfedea0SLionel Sambuc dsa_param_print,
667ebfedea0SLionel Sambuc dsa_sig_print,
668ebfedea0SLionel Sambuc
669ebfedea0SLionel Sambuc int_dsa_free,
670ebfedea0SLionel Sambuc dsa_pkey_ctrl,
671ebfedea0SLionel Sambuc old_dsa_priv_decode,
672*0a6a1f1dSLionel Sambuc old_dsa_priv_encode}
673ebfedea0SLionel Sambuc };
674