summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509/x_all.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/x509/x_all.c')
-rw-r--r--src/lib/libcrypto/x509/x_all.c465
1 files changed, 465 insertions, 0 deletions
diff --git a/src/lib/libcrypto/x509/x_all.c b/src/lib/libcrypto/x509/x_all.c
new file mode 100644
index 0000000000..b7dde23e9a
--- /dev/null
+++ b/src/lib/libcrypto/x509/x_all.c
@@ -0,0 +1,465 @@
1/* crypto/x509/x_all.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#undef SSLEAY_MACROS
61#include "stack.h"
62#include "cryptlib.h"
63#include "buffer.h"
64#include "asn1.h"
65#include "evp.h"
66#include "x509.h"
67
68int X509_verify(a,r)
69X509 *a;
70EVP_PKEY *r;
71 {
72 return(ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,
73 a->signature,(char *)a->cert_info,r));
74 }
75
76int X509_REQ_verify(a,r)
77X509_REQ *a;
78EVP_PKEY *r;
79 {
80 return( ASN1_verify((int (*)())i2d_X509_REQ_INFO,
81 a->sig_alg,a->signature,(char *)a->req_info,r));
82 }
83
84int X509_CRL_verify(a,r)
85X509_CRL *a;
86EVP_PKEY *r;
87 {
88 return(ASN1_verify((int (*)())i2d_X509_CRL_INFO,
89 a->sig_alg, a->signature,(char *)a->crl,r));
90 }
91
92int NETSCAPE_SPKI_verify(a,r)
93NETSCAPE_SPKI *a;
94EVP_PKEY *r;
95 {
96 return(ASN1_verify((int (*)())i2d_NETSCAPE_SPKAC,
97 a->sig_algor,a->signature, (char *)a->spkac,r));
98 }
99
100int X509_sign(x,pkey,md)
101X509 *x;
102EVP_PKEY *pkey;
103EVP_MD *md;
104 {
105 return(ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature,
106 x->sig_alg, x->signature, (char *)x->cert_info,pkey,md));
107 }
108
109int X509_REQ_sign(x,pkey,md)
110X509_REQ *x;
111EVP_PKEY *pkey;
112EVP_MD *md;
113 {
114 return(ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL,
115 x->signature, (char *)x->req_info,pkey,md));
116 }
117
118int X509_CRL_sign(x,pkey,md)
119X509_CRL *x;
120EVP_PKEY *pkey;
121EVP_MD *md;
122 {
123 return(ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,
124 x->sig_alg, x->signature, (char *)x->crl,pkey,md));
125 }
126
127int NETSCAPE_SPKI_sign(x,pkey,md)
128NETSCAPE_SPKI *x;
129EVP_PKEY *pkey;
130EVP_MD *md;
131 {
132 return(ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL,
133 x->signature, (char *)x->spkac,pkey,md));
134 }
135
136X509 *X509_dup(x509)
137X509 *x509;
138 {
139 return((X509 *)ASN1_dup((int (*)())i2d_X509,
140 (char *(*)())d2i_X509,(char *)x509));
141 }
142
143X509_EXTENSION *X509_EXTENSION_dup(ex)
144X509_EXTENSION *ex;
145 {
146 return((X509_EXTENSION *)ASN1_dup(
147 (int (*)())i2d_X509_EXTENSION,
148 (char *(*)())d2i_X509_EXTENSION,(char *)ex));
149 }
150
151#ifndef NO_FP_API
152X509 *d2i_X509_fp(fp,x509)
153FILE *fp;
154X509 *x509;
155 {
156 return((X509 *)ASN1_d2i_fp((char *(*)())X509_new,
157 (char *(*)())d2i_X509, (fp),(unsigned char **)(x509)));
158 }
159
160int i2d_X509_fp(fp,x509)
161FILE *fp;
162X509 *x509;
163 {
164 return(ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509));
165 }
166#endif
167
168X509 *d2i_X509_bio(bp,x509)
169BIO *bp;
170X509 *x509;
171 {
172 return((X509 *)ASN1_d2i_bio((char *(*)())X509_new,
173 (char *(*)())d2i_X509, (bp),(unsigned char **)(x509)));
174 }
175
176int i2d_X509_bio(bp,x509)
177BIO *bp;
178X509 *x509;
179 {
180 return(ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509));
181 }
182
183X509_CRL *X509_CRL_dup(crl)
184X509_CRL *crl;
185 {
186 return((X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL,
187 (char *(*)())d2i_X509_CRL,(char *)crl));
188 }
189
190#ifndef NO_FP_API
191X509_CRL *d2i_X509_CRL_fp(fp,crl)
192FILE *fp;
193X509_CRL *crl;
194 {
195 return((X509_CRL *)ASN1_d2i_fp((char *(*)())
196 X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),
197 (unsigned char **)(crl)));
198 }
199
200int i2d_X509_CRL_fp(fp,crl)
201FILE *fp;
202X509_CRL *crl;
203 {
204 return(ASN1_i2d_fp(i2d_X509_CRL,fp,(unsigned char *)crl));
205 }
206#endif
207
208X509_CRL *d2i_X509_CRL_bio(bp,crl)
209BIO *bp;
210X509_CRL *crl;
211 {
212 return((X509_CRL *)ASN1_d2i_bio((char *(*)())
213 X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),
214 (unsigned char **)(crl)));
215 }
216
217int i2d_X509_CRL_bio(bp,crl)
218BIO *bp;
219X509_CRL *crl;
220 {
221 return(ASN1_i2d_bio(i2d_X509_CRL,bp,(unsigned char *)crl));
222 }
223
224PKCS7 *PKCS7_dup(p7)
225PKCS7 *p7;
226 {
227 return((PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7,
228 (char *(*)())d2i_PKCS7,(char *)p7));
229 }
230
231#ifndef NO_FP_API
232PKCS7 *d2i_PKCS7_fp(fp,p7)
233FILE *fp;
234PKCS7 *p7;
235 {
236 return((PKCS7 *)ASN1_d2i_fp((char *(*)())
237 PKCS7_new,(char *(*)())d2i_PKCS7, (fp),
238 (unsigned char **)(p7)));
239 }
240
241int i2d_PKCS7_fp(fp,p7)
242FILE *fp;
243PKCS7 *p7;
244 {
245 return(ASN1_i2d_fp(i2d_PKCS7,fp,(unsigned char *)p7));
246 }
247#endif
248
249PKCS7 *d2i_PKCS7_bio(bp,p7)
250BIO *bp;
251PKCS7 *p7;
252 {
253 return((PKCS7 *)ASN1_d2i_bio((char *(*)())
254 PKCS7_new,(char *(*)())d2i_PKCS7, (bp),
255 (unsigned char **)(p7)));
256 }
257
258int i2d_PKCS7_bio(bp,p7)
259BIO *bp;
260PKCS7 *p7;
261 {
262 return(ASN1_i2d_bio(i2d_PKCS7,bp,(unsigned char *)p7));
263 }
264
265X509_REQ *X509_REQ_dup(req)
266X509_REQ *req;
267 {
268 return((X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ,
269 (char *(*)())d2i_X509_REQ,(char *)req));
270 }
271
272#ifndef NO_FP_API
273X509_REQ *d2i_X509_REQ_fp(fp,req)
274FILE *fp;
275X509_REQ *req;
276 {
277 return((X509_REQ *)ASN1_d2i_fp((char *(*)())
278 X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),
279 (unsigned char **)(req)));
280 }
281
282int i2d_X509_REQ_fp(fp,req)
283FILE *fp;
284X509_REQ *req;
285 {
286 return(ASN1_i2d_fp(i2d_X509_REQ,fp,(unsigned char *)req));
287 }
288#endif
289
290X509_REQ *d2i_X509_REQ_bio(bp,req)
291BIO *bp;
292X509_REQ *req;
293 {
294 return((X509_REQ *)ASN1_d2i_bio((char *(*)())
295 X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),
296 (unsigned char **)(req)));
297 }
298
299int i2d_X509_REQ_bio(bp,req)
300BIO *bp;
301X509_REQ *req;
302 {
303 return(ASN1_i2d_bio(i2d_X509_REQ,bp,(unsigned char *)req));
304 }
305
306#ifndef NO_RSA
307RSA *RSAPublicKey_dup(rsa)
308RSA *rsa;
309 {
310 return((RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey,
311 (char *(*)())d2i_RSAPublicKey,(char *)rsa));
312 }
313
314RSA *RSAPrivateKey_dup(rsa)
315RSA *rsa;
316 {
317 return((RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey,
318 (char *(*)())d2i_RSAPrivateKey,(char *)rsa));
319 }
320
321#ifndef NO_FP_API
322RSA *d2i_RSAPrivateKey_fp(fp,rsa)
323FILE *fp;
324RSA *rsa;
325 {
326 return((RSA *)ASN1_d2i_fp((char *(*)())
327 RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp),
328 (unsigned char **)(rsa)));
329 }
330
331int i2d_RSAPrivateKey_fp(fp,rsa)
332FILE *fp;
333RSA *rsa;
334 {
335 return(ASN1_i2d_fp(i2d_RSAPrivateKey,fp,(unsigned char *)rsa));
336 }
337
338RSA *d2i_RSAPublicKey_fp(fp,rsa)
339FILE *fp;
340RSA *rsa;
341 {
342 return((RSA *)ASN1_d2i_fp((char *(*)())
343 RSA_new,(char *(*)())d2i_RSAPublicKey, (fp),
344 (unsigned char **)(rsa)));
345 }
346
347int i2d_RSAPublicKey_fp(fp,rsa)
348FILE *fp;
349RSA *rsa;
350 {
351 return(ASN1_i2d_fp(i2d_RSAPublicKey,fp,(unsigned char *)rsa));
352 }
353#endif
354
355RSA *d2i_RSAPrivateKey_bio(bp,rsa)
356BIO *bp;
357RSA *rsa;
358 {
359 return((RSA *)ASN1_d2i_bio((char *(*)())
360 RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp),
361 (unsigned char **)(rsa)));
362 }
363
364int i2d_RSAPrivateKey_bio(bp,rsa)
365BIO *bp;
366RSA *rsa;
367 {
368 return(ASN1_i2d_bio(i2d_RSAPrivateKey,bp,(unsigned char *)rsa));
369 }
370
371RSA *d2i_RSAPublicKey_bio(bp,rsa)
372BIO *bp;
373RSA *rsa;
374 {
375 return((RSA *)ASN1_d2i_bio((char *(*)())
376 RSA_new,(char *(*)())d2i_RSAPublicKey, (bp),
377 (unsigned char **)(rsa)));
378 }
379
380int i2d_RSAPublicKey_bio(bp,rsa)
381BIO *bp;
382RSA *rsa;
383 {
384 return(ASN1_i2d_bio(i2d_RSAPublicKey,bp,(unsigned char *)rsa));
385 }
386#endif
387
388#ifndef NO_DSA
389#ifndef NO_FP_API
390DSA *d2i_DSAPrivateKey_fp(fp,dsa)
391FILE *fp;
392DSA *dsa;
393 {
394 return((DSA *)ASN1_d2i_fp((char *(*)())
395 DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp),
396 (unsigned char **)(dsa)));
397 }
398
399int i2d_DSAPrivateKey_fp(fp,dsa)
400FILE *fp;
401DSA *dsa;
402 {
403 return(ASN1_i2d_fp(i2d_DSAPrivateKey,fp,(unsigned char *)dsa));
404 }
405#endif
406
407DSA *d2i_DSAPrivateKey_bio(bp,dsa)
408BIO *bp;
409DSA *dsa;
410 {
411 return((DSA *)ASN1_d2i_bio((char *(*)())
412 DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp),
413 (unsigned char **)(dsa)));
414 }
415
416int i2d_DSAPrivateKey_bio(bp,dsa)
417BIO *bp;
418DSA *dsa;
419 {
420 return(ASN1_i2d_bio(i2d_DSAPrivateKey,bp,(unsigned char *)dsa));
421 }
422#endif
423
424X509_NAME *X509_NAME_dup(xn)
425X509_NAME *xn;
426 {
427 return((X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME,
428 (char *(*)())d2i_X509_NAME,(char *)xn));
429 }
430
431X509_NAME_ENTRY *X509_NAME_ENTRY_dup(ne)
432X509_NAME_ENTRY *ne;
433 {
434 return((X509_NAME_ENTRY *)ASN1_dup((int (*)())i2d_X509_NAME_ENTRY,
435 (char *(*)())d2i_X509_NAME_ENTRY,(char *)ne));
436 }
437
438int X509_digest(data,type,md,len)
439X509 *data;
440EVP_MD *type;
441unsigned char *md;
442unsigned int *len;
443 {
444 return(ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len));
445 }
446
447int X509_NAME_digest(data,type,md,len)
448X509_NAME *data;
449EVP_MD *type;
450unsigned char *md;
451unsigned int *len;
452 {
453 return(ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len));
454 }
455
456int PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len)
457PKCS7_ISSUER_AND_SERIAL *data;
458EVP_MD *type;
459unsigned char *md;
460unsigned int *len;
461 {
462 return(ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,
463 (char *)data,md,len));
464 }
465