2 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
9 #pragma ident "%Z%%M% %I% %E% SMI"
16 * Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
17 * All rights reserved.
19 * This package is an SSL implementation written
20 * by Eric Young (eay@cryptsoft.com).
21 * The implementation was written so as to conform with Netscapes SSL.
23 * This library is free for commercial and non-commercial use as long as
24 * the following conditions are aheared to. The following conditions
25 * apply to all code found in this distribution, be it the RC4, RSA,
26 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
27 * included with this distribution is covered by the same copyright terms
28 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
30 * Copyright remains Eric Young's, and as such any Copyright notices in
31 * the code are not to be removed.
32 * If this package is used in a product, Eric Young should be given attribution
33 * as the author of the parts of the library used.
34 * This can be in the form of a textual message at program startup or
35 * in documentation (online or textual) provided with the package.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * "This product includes cryptographic software written by
48 * Eric Young (eay@cryptsoft.com)"
49 * The word 'cryptographic' can be left out if the rouines from the library
50 * being used are not cryptographic related :-).
51 * 4. If you include any Windows specific code (or a derivative thereof) from
52 * the apps directory (application code) you must include an acknowledgement:
53 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
55 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 * The licence and distribution terms for any publically available version or
68 * derivative of this code cannot be changed. i.e. this code cannot simply be
69 * copied and put under another distribution licence
70 * [including the GNU Public Licence.]
72 #define PEM_STRING_X509 "CERTIFICATE"
73 #define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
74 #define PEM_STRING_X509_CRL "X509 CRL"
75 #define PEM_BUFSIZE 1024
79 * 0xF1 is ignore but next needs to be 0xF0 (for \r\n processing).
81 * 0xE0 is ignore at start of line.
89 #define B64_ERROR 0xFF
90 #define B64_NOT_BASE64(a) (((a)|0x13) == 0xF3)
92 typedef struct pem_encode_ctx_st
94 int num
; /* number saved in a partial encode/decode */
96 * The length is either the output line length
97 * (in input bytes) or the shortest input line
98 * length that is ok. Once decoding begins,
99 * the length is adjusted up each time a longer
103 unsigned char enc_data
[80]; /* data to encode */
104 int line_num
; /* number read on current line */
109 Der2Pem(KMF_OBJECT_TYPE
, unsigned char *, int, unsigned char **, int *);
112 Pem2Der(unsigned char *, int, unsigned char **, int *);
117 #endif /* _PEM_ENCODE_H */