1 /* $OpenBSD: v3_pcia.c,v 1.5 2015/02/09 16:03:11 jsing Exp $ */
2 /* Contributed to the OpenSSL Project 2004
3 * by Richard Levitte (richard@levitte.org)
5 /* Copyright (c) 2004 Kungliga Tekniska Högskolan
6 * (Royal Institute of Technology, Stockholm, Sweden).
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the Institute nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #include <openssl/asn1.h>
38 #include <openssl/asn1t.h>
39 #include <openssl/x509v3.h>
41 static const ASN1_TEMPLATE PROXY_POLICY_seq_tt
[] = {
45 .offset
= offsetof(PROXY_POLICY
, policyLanguage
),
46 .field_name
= "policyLanguage",
47 .item
= &ASN1_OBJECT_it
,
50 .flags
= ASN1_TFLG_OPTIONAL
,
52 .offset
= offsetof(PROXY_POLICY
, policy
),
53 .field_name
= "policy",
54 .item
= &ASN1_OCTET_STRING_it
,
58 const ASN1_ITEM PROXY_POLICY_it
= {
59 .itype
= ASN1_ITYPE_SEQUENCE
,
60 .utype
= V_ASN1_SEQUENCE
,
61 .templates
= PROXY_POLICY_seq_tt
,
62 .tcount
= sizeof(PROXY_POLICY_seq_tt
) / sizeof(ASN1_TEMPLATE
),
64 .size
= sizeof(PROXY_POLICY
),
65 .sname
= "PROXY_POLICY",
70 d2i_PROXY_POLICY(PROXY_POLICY
**a
, const unsigned char **in
, long len
)
72 return (PROXY_POLICY
*)ASN1_item_d2i((ASN1_VALUE
**)a
, in
, len
,
77 i2d_PROXY_POLICY(PROXY_POLICY
*a
, unsigned char **out
)
79 return ASN1_item_i2d((ASN1_VALUE
*)a
, out
, &PROXY_POLICY_it
);
83 PROXY_POLICY_new(void)
85 return (PROXY_POLICY
*)ASN1_item_new(&PROXY_POLICY_it
);
89 PROXY_POLICY_free(PROXY_POLICY
*a
)
91 ASN1_item_free((ASN1_VALUE
*)a
, &PROXY_POLICY_it
);
94 static const ASN1_TEMPLATE PROXY_CERT_INFO_EXTENSION_seq_tt
[] = {
96 .flags
= ASN1_TFLG_OPTIONAL
,
98 .offset
= offsetof(PROXY_CERT_INFO_EXTENSION
, pcPathLengthConstraint
),
99 .field_name
= "pcPathLengthConstraint",
100 .item
= &ASN1_INTEGER_it
,
105 .offset
= offsetof(PROXY_CERT_INFO_EXTENSION
, proxyPolicy
),
106 .field_name
= "proxyPolicy",
107 .item
= &PROXY_POLICY_it
,
111 const ASN1_ITEM PROXY_CERT_INFO_EXTENSION_it
= {
112 .itype
= ASN1_ITYPE_SEQUENCE
,
113 .utype
= V_ASN1_SEQUENCE
,
114 .templates
= PROXY_CERT_INFO_EXTENSION_seq_tt
,
115 .tcount
= sizeof(PROXY_CERT_INFO_EXTENSION_seq_tt
) / sizeof(ASN1_TEMPLATE
),
117 .size
= sizeof(PROXY_CERT_INFO_EXTENSION
),
118 .sname
= "PROXY_CERT_INFO_EXTENSION",
122 PROXY_CERT_INFO_EXTENSION
*
123 d2i_PROXY_CERT_INFO_EXTENSION(PROXY_CERT_INFO_EXTENSION
**a
, const unsigned char **in
, long len
)
125 return (PROXY_CERT_INFO_EXTENSION
*)ASN1_item_d2i((ASN1_VALUE
**)a
, in
, len
,
126 &PROXY_CERT_INFO_EXTENSION_it
);
130 i2d_PROXY_CERT_INFO_EXTENSION(PROXY_CERT_INFO_EXTENSION
*a
, unsigned char **out
)
132 return ASN1_item_i2d((ASN1_VALUE
*)a
, out
, &PROXY_CERT_INFO_EXTENSION_it
);
135 PROXY_CERT_INFO_EXTENSION
*
136 PROXY_CERT_INFO_EXTENSION_new(void)
138 return (PROXY_CERT_INFO_EXTENSION
*)ASN1_item_new(&PROXY_CERT_INFO_EXTENSION_it
);
142 PROXY_CERT_INFO_EXTENSION_free(PROXY_CERT_INFO_EXTENSION
*a
)
144 ASN1_item_free((ASN1_VALUE
*)a
, &PROXY_CERT_INFO_EXTENSION_it
);