2 * Copyright (C) 2000-2002 Andreas Steffen, Zuercher Hochschule Winterthur
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * RCSID $Id: asn1.h,v 0.1 2002/04/12 00:00:00 as Exp $
17 /* Defines some primitive ASN1 types */
23 ASN1_BIT_STRING = 0x03,
24 ASN1_OCTET_STRING = 0x04,
27 ASN1_UTF8STRING = 0x0C,
28 ASN1_NUMERICSTRING = 0x12,
29 ASN1_PRINTABLESTRING = 0x13,
30 ASN1_T61STRING = 0x14,
31 ASN1_VIDEOTEXSTRING = 0x15,
32 ASN1_IA5STRING = 0x16,
34 ASN1_GENERALIZEDTIME = 0x18,
35 ASN1_GRAPHICSTRING = 0x19,
36 ASN1_VISIBLESTRING = 0x1A,
37 ASN1_GENERALSTRING = 0x1B,
38 ASN1_UNIVERSALSTRING = 0x1C,
39 ASN1_BMPSTRING = 0x1E,
41 ASN1_CONSTRUCTED = 0x20,
47 ASN1_CONTEXT_S_0 = 0x80,
48 ASN1_CONTEXT_S_1 = 0x81,
49 ASN1_CONTEXT_S_2 = 0x82,
50 ASN1_CONTEXT_S_3 = 0x83,
51 ASN1_CONTEXT_S_4 = 0x84,
52 ASN1_CONTEXT_S_5 = 0x85,
53 ASN1_CONTEXT_S_6 = 0x86,
54 ASN1_CONTEXT_S_7 = 0x87,
55 ASN1_CONTEXT_S_8 = 0x88,
57 ASN1_CONTEXT_C_0 = 0xA0,
58 ASN1_CONTEXT_C_1 = 0xA1,
59 ASN1_CONTEXT_C_2 = 0xA2,
60 ASN1_CONTEXT_C_3 = 0xA3,
61 ASN1_CONTEXT_C_4 = 0xA4,
62 ASN1_CONTEXT_C_5 = 0xA5
65 /* Definition of ASN1 flags */
67 #define ASN1_NONE 0x00
70 #define ASN1_LOOP 0x04
73 #define ASN1_BODY 0x20
75 #define ASN1_INVALID_LENGTH 0xffffffff
77 /* definition of an ASN.1 object */
86 /* defines a node in a the hierarchical OID tree */
95 /* Some well known object identifiers (OIDs) */
97 extern const oid_t oid_names[];
99 #define OID_SUBJECT_ALT_NAME 19
100 #define OID_BASIC_CONSTRAINTS 21
101 #define OID_CRL_DISTRIBUTION_POINTS 23
102 #define OID_RSA_ENCRYPTION 35
103 #define OID_MD2_WITH_RSA 36
104 #define OID_MD5_WITH_RSA 37
105 #define OID_SHA1_WITH_RSA 38
106 #define OID_SHA256_WITH_RSA 39
107 #define OID_SHA384_WITH_RSA 40
108 #define OID_SHA512_WITH_RSA 41
109 #define OID_PKCS7_DATA 43
110 #define OID_PKCS7_SIGNED_DATA 44
111 #define OID_PKCS9_EMAIL 50
116 /* internal context of ASN.1 parser */
118 #define ASN1_MAX_LEVEL 20
124 u_int loopAddr[ASN1_MAX_LEVEL+1];
125 chunk_t blobs[ASN1_MAX_LEVEL+2];
128 extern int known_oid(chunk_t object);
129 extern u_int asn1_length(chunk_t *blob);
130 extern bool is_printablestring(chunk_t str);
131 extern time_t asn1totime(const chunk_t *utctime, asn1_t type);
132 extern void asn1_init(asn1_ctx_t *ctx, chunk_t blob,
133 u_int level0, bool implicit, u_int cond);
134 extern bool extract_object(asn1Object_t const *objects,
135 u_int *objectID, chunk_t *object, asn1_ctx_t *ctx);
136 extern bool load_asn1_file(const char* filename, const char* passphrase,
137 const char* type, chunk_t *blob);