2 * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include "internal/cryptlib.h"
12 #include <openssl/asn1t.h>
13 #include <openssl/conf.h>
14 #include <openssl/x509v3.h>
17 static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method,
19 STACK_OF(CONF_VALUE) *nval);
20 static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD
21 *method, void *eku, STACK_OF(CONF_VALUE)
24 const X509V3_EXT_METHOD v3_ext_ku = {
26 ASN1_ITEM_ref(EXTENDED_KEY_USAGE),
29 i2v_EXTENDED_KEY_USAGE,
30 v2i_EXTENDED_KEY_USAGE,
35 /* NB OCSP acceptable responses also is a SEQUENCE OF OBJECT */
36 const X509V3_EXT_METHOD v3_ocsp_accresp = {
37 NID_id_pkix_OCSP_acceptableResponses, 0,
38 ASN1_ITEM_ref(EXTENDED_KEY_USAGE),
41 i2v_EXTENDED_KEY_USAGE,
42 v2i_EXTENDED_KEY_USAGE,
47 ASN1_ITEM_TEMPLATE(EXTENDED_KEY_USAGE) =
48 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, EXTENDED_KEY_USAGE, ASN1_OBJECT)
49 ASN1_ITEM_TEMPLATE_END(EXTENDED_KEY_USAGE)
51 IMPLEMENT_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)
53 static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD
54 *method, void *a, STACK_OF(CONF_VALUE)
57 EXTENDED_KEY_USAGE *eku = a;
61 for (i = 0; i < sk_ASN1_OBJECT_num(eku); i++) {
62 obj = sk_ASN1_OBJECT_value(eku, i);
63 i2t_ASN1_OBJECT(obj_tmp, 80, obj);
64 X509V3_add_value(NULL, obj_tmp, &ext_list);
69 static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method,
71 STACK_OF(CONF_VALUE) *nval)
73 EXTENDED_KEY_USAGE *extku;
79 if ((extku = sk_ASN1_OBJECT_new_null()) == NULL) {
80 X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, ERR_R_MALLOC_FAILURE);
84 for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
85 val = sk_CONF_VALUE_value(nval, i);
90 if ((objtmp = OBJ_txt2obj(extval, 0)) == NULL) {
91 sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free);
92 X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE,
93 X509V3_R_INVALID_OBJECT_IDENTIFIER);
97 sk_ASN1_OBJECT_push(extku, objtmp);