]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/pem/pem_all.c
Add a few extended key usage OIDs.
[thirdparty/openssl.git] / crypto / pem / pem_all.c
CommitLineData
d02b48c6 1/* crypto/pem/pem_all.c */
58964a49 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
d02b48c6
RE
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
58964a49 61#include "cryptlib.h"
d02b48c6
RE
62#include "bio.h"
63#include "evp.h"
64#include "x509.h"
65#include "pkcs7.h"
66#include "pem.h"
67
58964a49 68#ifndef NO_FP_API
d02b48c6
RE
69/* The X509 functions */
70X509 *PEM_read_X509(fp,x,cb)
71FILE *fp;
72X509 **x;
73int (*cb)();
74 {
75 return((X509 *)PEM_ASN1_read((char *(*)())d2i_X509,
76 PEM_STRING_X509,fp,(char **)x,cb));
77 }
78#endif
79
80X509 *PEM_read_bio_X509(bp,x,cb)
81BIO *bp;
82X509 **x;
83int (*cb)();
84 {
85 return((X509 *)PEM_ASN1_read_bio((char *(*)())d2i_X509,
86 PEM_STRING_X509,bp,(char **)x,cb));
87 }
88
58964a49 89#ifndef NO_FP_API
d02b48c6
RE
90int PEM_write_X509(fp,x)
91FILE *fp;
92X509 *x;
93 {
94 return(PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp,
95 (char *)x, NULL,NULL,0,NULL));
96 }
97#endif
98
99int PEM_write_bio_X509(bp,x)
100BIO *bp;
101X509 *x;
102 {
103 return(PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp,
104 (char *)x, NULL,NULL,0,NULL));
105 }
106
58964a49 107#ifndef NO_FP_API
d02b48c6
RE
108/* The X509_REQ functions */
109X509_REQ *PEM_read_X509_REQ(fp,x,cb)
110FILE *fp;
111X509_REQ **x;
112int (*cb)();
113 {
114 return((X509_REQ *)PEM_ASN1_read((char *(*)())d2i_X509_REQ,
115 PEM_STRING_X509_REQ,fp,(char **)x,cb));
116 }
117#endif
118
119X509_REQ *PEM_read_bio_X509_REQ(bp,x,cb)
120BIO *bp;
121X509_REQ **x;
122int (*cb)();
123 {
124 return((X509_REQ *)PEM_ASN1_read_bio((char *(*)())d2i_X509_REQ,
125 PEM_STRING_X509_REQ,bp,(char **)x,cb));
126 }
127
58964a49 128#ifndef NO_FP_API
d02b48c6
RE
129int PEM_write_X509_REQ(fp,x)
130FILE *fp;
131X509_REQ *x;
132 {
133 return(PEM_ASN1_write((int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,
134 (char *)x, NULL,NULL,0,NULL));
135 }
136#endif
137
138int PEM_write_bio_X509_REQ(bp,x)
139BIO *bp;
140X509_REQ *x;
141 {
142 return(PEM_ASN1_write_bio((int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,
143 bp,(char *)x, NULL,NULL,0,NULL));
144 }
145
58964a49 146#ifndef NO_FP_API
d02b48c6
RE
147/* The X509_CRL functions */
148X509_CRL *PEM_read_X509_CRL(fp,x,cb)
149FILE *fp;
150X509_CRL **x;
151int (*cb)();
152 {
153 return((X509_CRL *)PEM_ASN1_read((char *(*)())d2i_X509_CRL,
154 PEM_STRING_X509_CRL,fp,(char **)x,cb));
155 }
156#endif
157
158X509_CRL *PEM_read_bio_X509_CRL(bp,x,cb)
159BIO *bp;
160X509_CRL **x;
161int (*cb)();
162 {
163 return((X509_CRL *)PEM_ASN1_read_bio((char *(*)())d2i_X509_CRL,
164 PEM_STRING_X509_CRL,bp,(char **)x,cb));
165 }
166
58964a49 167#ifndef NO_FP_API
d02b48c6
RE
168int PEM_write_X509_CRL(fp,x)
169FILE *fp;
170X509_CRL *x;
171 {
172 return(PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,fp,
173 (char *)x, NULL,NULL,0,NULL));
174 }
175#endif
176
177int PEM_write_bio_X509_CRL(bp,x)
178BIO *bp;
179X509_CRL *x;
180 {
181 return(PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,
182 bp,(char *)x, NULL,NULL,0,NULL));
183 }
184
185#ifndef NO_RSA
58964a49 186#ifndef NO_FP_API
d02b48c6
RE
187/* The RSAPrivateKey functions */
188RSA *PEM_read_RSAPrivateKey(fp,x,cb)
189FILE *fp;
190RSA **x;
191int (*cb)();
192 {
193 return((RSA *)PEM_ASN1_read((char *(*)())d2i_RSAPrivateKey,
194 PEM_STRING_RSA,fp,(char **)x,cb));
195 }
196
197RSA *PEM_read_RSAPublicKey(fp,x,cb)
198FILE *fp;
199RSA **x;
200int (*cb)();
201 {
202 return((RSA *)PEM_ASN1_read((char *(*)())d2i_RSAPublicKey,
203 PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb));
204 }
205#endif
206
207RSA *PEM_read_bio_RSAPrivateKey(bp,x,cb)
208BIO *bp;
209RSA **x;
210int (*cb)();
211 {
212 return((RSA *)PEM_ASN1_read_bio((char *(*)())d2i_RSAPrivateKey,
213 PEM_STRING_RSA,bp,(char **)x,cb));
214 }
215
216RSA *PEM_read_bio_RSAPublicKey(bp,x,cb)
217BIO *bp;
218RSA **x;
219int (*cb)();
220 {
221 return((RSA *)PEM_ASN1_read_bio((char *(*)())d2i_RSAPublicKey,
222 PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb));
223 }
224
58964a49 225#ifndef NO_FP_API
d02b48c6
RE
226int PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb)
227FILE *fp;
228RSA *x;
229EVP_CIPHER *enc;
230unsigned char *kstr;
231int klen;
232int (*cb)();
233 {
234 return(PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,
235 (char *)x,enc,kstr,klen,cb));
236 }
237
238int PEM_write_RSAPublicKey(fp,x)
239FILE *fp;
240RSA *x;
241 {
242 return(PEM_ASN1_write((int (*)())i2d_RSAPublicKey,
243 PEM_STRING_RSA_PUBLIC,fp,
244 (char *)x,NULL,NULL,0,NULL));
245 }
246#endif
247
248int PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb)
249BIO *bp;
250RSA *x;
251EVP_CIPHER *enc;
252unsigned char *kstr;
253int klen;
254int (*cb)();
255 {
256 return(PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,
257 bp,(char *)x,enc,kstr,klen,cb));
258 }
259
260int PEM_write_bio_RSAPublicKey(bp,x)
261BIO *bp;
262RSA *x;
263 {
264 return(PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey,
265 PEM_STRING_RSA_PUBLIC,
266 bp,(char *)x,NULL,NULL,0,NULL));
267 }
268#endif /* !NO_RSA */
269
270#ifndef NO_DSA
58964a49 271#ifndef NO_FP_API
d02b48c6
RE
272/* The DSAPrivateKey functions */
273DSA *PEM_read_DSAPrivateKey(fp,x,cb)
274FILE *fp;
275DSA **x;
276int (*cb)();
277 {
278 return((DSA *)PEM_ASN1_read((char *(*)())d2i_DSAPrivateKey,
279 PEM_STRING_DSA,fp,(char **)x,cb));
280 }
281#endif
282
283DSA *PEM_read_bio_DSAPrivateKey(bp,x,cb)
284BIO *bp;
285DSA **x;
286int (*cb)();
287 {
288 return((DSA *)PEM_ASN1_read_bio((char *(*)())d2i_DSAPrivateKey,
289 PEM_STRING_DSA,bp,(char **)x,cb));
290 }
291
58964a49 292#ifndef NO_FP_API
d02b48c6
RE
293int PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb)
294FILE *fp;
295DSA *x;
296EVP_CIPHER *enc;
297unsigned char *kstr;
298int klen;
299int (*cb)();
300 {
301 return(PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,
302 (char *)x,enc,kstr,klen,cb));
303 }
304#endif
305
306int PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb)
307BIO *bp;
308DSA *x;
309EVP_CIPHER *enc;
310unsigned char *kstr;
311int klen;
312int (*cb)();
313 {
314 return(PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,
315 bp,(char *)x,enc,kstr,klen,cb));
316 }
317#endif
318
58964a49 319#ifndef NO_FP_API
d02b48c6
RE
320/* The PrivateKey functions */
321EVP_PKEY *PEM_read_PrivateKey(fp,x,cb)
322FILE *fp;
323EVP_PKEY **x;
324int (*cb)();
325 {
326 return((EVP_PKEY *)PEM_ASN1_read((char *(*)())d2i_PrivateKey,
327 PEM_STRING_EVP_PKEY,fp,(char **)x,cb));
328 }
329#endif
330
331EVP_PKEY *PEM_read_bio_PrivateKey(bp,x,cb)
332BIO *bp;
333EVP_PKEY **x;
334int (*cb)();
335 {
336 return((EVP_PKEY *)PEM_ASN1_read_bio((char *(*)())d2i_PrivateKey,
337 PEM_STRING_EVP_PKEY,bp,(char **)x,cb));
338 }
339
58964a49 340#ifndef NO_FP_API
d02b48c6
RE
341int PEM_write_PrivateKey(fp,x,enc,kstr,klen,cb)
342FILE *fp;
343EVP_PKEY *x;
344EVP_CIPHER *enc;
345unsigned char *kstr;
346int klen;
347int (*cb)();
348 {
349 return(PEM_ASN1_write((int (*)())i2d_PrivateKey,
350 ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),
351 fp,(char *)x,enc,kstr,klen,cb));
352 }
353#endif
354
355int PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb)
356BIO *bp;
357EVP_PKEY *x;
358EVP_CIPHER *enc;
359unsigned char *kstr;
360int klen;
361int (*cb)();
362 {
363 return(PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,
364 ((x->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),
365 bp,(char *)x,enc,kstr,klen,cb));
366 }
367
58964a49 368#ifndef NO_FP_API
d02b48c6
RE
369/* The PKCS7 functions */
370PKCS7 *PEM_read_PKCS7(fp,x,cb)
371FILE *fp;
372PKCS7 **x;
373int (*cb)();
374 {
375 return((PKCS7 *)PEM_ASN1_read((char *(*)())d2i_PKCS7,
376 PEM_STRING_PKCS7,fp,(char **)x,cb));
377 }
378#endif
379
380PKCS7 *PEM_read_bio_PKCS7(bp,x,cb)
381BIO *bp;
382PKCS7 **x;
383int (*cb)();
384 {
385 return((PKCS7 *)PEM_ASN1_read_bio((char *(*)())d2i_PKCS7,
386 PEM_STRING_PKCS7,bp,(char **)x,cb));
387 }
388
58964a49 389#ifndef NO_FP_API
d02b48c6
RE
390int PEM_write_PKCS7(fp,x)
391FILE *fp;
392PKCS7 *x;
393 {
394 return(PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp,
395 (char *)x, NULL,NULL,0,NULL));
396 }
397#endif
398
399int PEM_write_bio_PKCS7(bp,x)
400BIO *bp;
401PKCS7 *x;
402 {
403 return(PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp,
404 (char *)x, NULL,NULL,0,NULL));
405 }
406
407#ifndef NO_DH
58964a49 408#ifndef NO_FP_API
d02b48c6
RE
409/* The DHparams functions */
410DH *PEM_read_DHparams(fp,x,cb)
411FILE *fp;
412DH **x;
413int (*cb)();
414 {
415 return((DH *)PEM_ASN1_read((char *(*)())d2i_DHparams,
416 PEM_STRING_DHPARAMS,fp,(char **)x,cb));
417 }
418#endif
419
420DH *PEM_read_bio_DHparams(bp,x,cb)
421BIO *bp;
422DH **x;
423int (*cb)();
424 {
425 return((DH *)PEM_ASN1_read_bio((char *(*)())d2i_DHparams,
426 PEM_STRING_DHPARAMS,bp,(char **)x,cb));
427 }
428
58964a49 429#ifndef NO_FP_API
d02b48c6
RE
430int PEM_write_DHparams(fp,x)
431FILE *fp;
432DH *x;
433 {
434 return(PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,
435 (char *)x, NULL,NULL,0,NULL));
436 }
437#endif
438
439int PEM_write_bio_DHparams(bp,x)
440BIO *bp;
441DH *x;
442 {
443 return(PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,
444 bp,(char *)x, NULL,NULL,0,NULL));
445 }
446#endif
447
448#ifndef NO_DSA
58964a49 449#ifndef NO_FP_API
d02b48c6
RE
450/* The DSAparams functions */
451DSA *PEM_read_DSAparams(fp,x,cb)
452FILE *fp;
453DSA **x;
454int (*cb)();
455 {
456 return((DSA *)PEM_ASN1_read((char *(*)())d2i_DSAparams,
457 PEM_STRING_DSAPARAMS,fp,(char **)x,cb));
458 }
459#endif
460
461DSA *PEM_read_bio_DSAparams(bp,x,cb)
462BIO *bp;
463DSA **x;
464int (*cb)();
465 {
466 return((DSA *)PEM_ASN1_read_bio((char *(*)())d2i_DSAparams,
467 PEM_STRING_DSAPARAMS,bp,(char **)x,cb));
468 }
469
58964a49 470#ifndef NO_FP_API
d02b48c6
RE
471int PEM_write_DSAparams(fp,x)
472FILE *fp;
473DSA *x;
474 {
475 return(PEM_ASN1_write((int (*)())i2d_DSAparams,PEM_STRING_DSAPARAMS,fp,
476 (char *)x, NULL,NULL,0,NULL));
477 }
478#endif
479
480int PEM_write_bio_DSAparams(bp,x)
481BIO *bp;
482DSA *x;
483 {
484 return(PEM_ASN1_write_bio((int (*)())i2d_DSAparams,PEM_STRING_DSAPARAMS,
485 bp,(char *)x, NULL,NULL,0,NULL));
486 }
487#endif
488