summaryrefslogtreecommitdiff
path: root/sbin/isakmpd/asn_useful.c
blob: 39a949f863a14b7758e5fc2e1b61d9d085149046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*	$OpenBSD: asn_useful.c,v 1.5 1998/11/17 11:10:07 niklas Exp $	*/
/*	$EOM: asn_useful.c,v 1.8 1998/08/21 13:47:58 provos Exp $	*/

/*
 * Copyright (c) 1998 Niels Provos.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by Ericsson Radio Systems.
 * 4. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * This code was written under funding by Ericsson Radio Systems.
 */

#include <sys/param.h>

#include "asn.h"
#include "asn_useful.h"

struct norm_type AlgorithmIdentifier[] = {
  {TAG_OBJECTID, UNIVERSAL, "algorithm", 0, NULL},
  {TAG_ANY, UNIVERSAL, "parameters", 0, NULL},
  {TAG_STOP, UNIVERSAL, NULL, 0, NULL}};

struct norm_type Signed[] = {
  {TAG_RAW, UNIVERSAL, "data", 0, NULL},
  SEQ("algorithm", AlgorithmIdentifier),
  {TAG_BITSTRING, UNIVERSAL, "encrypted", 0, NULL},
  {TAG_STOP, UNIVERSAL, NULL, 0, NULL}};

struct norm_type Validity[] = {
  {TAG_UTCTIME, UNIVERSAL, "notBefore", 0, NULL},
  {TAG_UTCTIME, UNIVERSAL, "notAfter", 0, NULL},
  {TAG_STOP, UNIVERSAL, NULL, 0, NULL}};

struct norm_type AttributeValueAssertion[] = {
  {TAG_OBJECTID, UNIVERSAL, "AttributeType", 0, NULL},
  {TAG_ANY, UNIVERSAL, "AttributeValue", 0, NULL},
  {TAG_STOP, UNIVERSAL, NULL, 0, NULL}};

struct norm_type RelativeDistinguishedName[] = {
  SEQ ("AttributeValueAssertion", AttributeValueAssertion),
  {TAG_STOP}};

/* 
 * For decoding this structure is dynamically resized, we add two Names
 * only for encoding purposes.
 */
struct norm_type RDNSequence[] = {
  SETOF ("RelativeDistinguishedName", RelativeDistinguishedName),
  SETOF ("RelativeDistinguishedName", RelativeDistinguishedName),
  {TAG_STOP}};

struct norm_type SubjectPublicKeyInfo[] = {
  SEQ ("algorithm", AlgorithmIdentifier),
  {TAG_BITSTRING, UNIVERSAL, "subjectPublicKey", 0, NULL},
  {TAG_STOP}};

struct norm_type Extension[] = {
  {TAG_OBJECTID, UNIVERSAL, "extnId", 0, NULL},
  {TAG_BOOL, UNIVERSAL, "critical", 0, NULL},
  {TAG_OCTETSTRING, UNIVERSAL, "extnValue", 0, NULL},
  {TAG_STOP}};

struct norm_type Extensions[] = {
  SEQ ("extension", Extension),
  {TAG_STOP}};

struct norm_type Certificate[] = {
  /* We need to add an explicit tag, HACK XXX */
  {TAG_INTEGER, ADD_EXP(0, UNIVERSAL), "version", 0, NULL},
  {TAG_INTEGER, UNIVERSAL, "serialNumber", 0, NULL},
  SEQ ("signature", AlgorithmIdentifier),
  SEQOF ("issuer", RDNSequence),
  SEQ ("validity", Validity),
  SEQOF ("subject", RDNSequence),
  SEQ ("subjectPublicKeyInfo", SubjectPublicKeyInfo),
  {TAG_RAW, UNIVERSAL, "extension", 0, NULL},
  {TAG_STOP}};

struct norm_type DigestInfo[] = {
  SEQ ("digestAlgorithm", AlgorithmIdentifier),
  {TAG_OCTETSTRING, UNIVERSAL, "digest", 0, NULL},
  {TAG_STOP}};

struct asn_objectid asn_ids[] = {
  {"AttributeType", ASN_ID_ATTRIBUTE_TYPE},
  {"CountryName", ASN_ID_COUNTRY_NAME},
  {"LocalityName", ASN_ID_LOCALITY_NAME},
  {"StateOrProvinceName", ASN_ID_STATE_NAME},
  {"OrganizationName", ASN_ID_ORGANIZATION_NAME},
  {"OrganizationUnitName", ASN_ID_ORGUNIT_NAME},
  {"CommonUnitName", ASN_ID_COMMONUNIT_NAME},
  {"pkcs-1", ASN_ID_PKCS},
  {"rsaEncryption", ASN_ID_RSAENCRYPTION},
  {"md2WithRSAEncryption", ASN_ID_MD2WITHRSAENC},
  {"md4WithRSAEncryption", ASN_ID_MD4WITHRSAENC},
  {"md5WithRSAEncryption", ASN_ID_MD5WITHRSAENC},
  {"md2", ASN_ID_MD2},
  {"md4", ASN_ID_MD4},
  {"md5", ASN_ID_MD5},
  {"emailAddress", ASN_ID_EMAILADDRESS},
  {"id-ce", ASN_ID_CE},
  {"subjectAltName", ASN_ID_SUBJECT_ALT_NAME},
  {"issuerAltName", ASN_ID_ISSUER_ALT_NAME},
  {"basicConstraints", ASN_ID_BASIC_CONSTRAINTS},
  {NULL, NULL} };