source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/x509v3/v3_pcons.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 3.2 KB
Line 
1/*
2 * Copyright 2003-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
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
8 */
9
10#include <stdio.h>
11#include "internal/cryptlib.h"
12#include <openssl/asn1.h>
13#include <openssl/asn1t.h>
14#include <openssl/conf.h>
15#include <openssl/x509v3.h>
16#include "ext_dat.h"
17
18static STACK_OF(CONF_VALUE) *i2v_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD
19 *method, void *bcons, STACK_OF(CONF_VALUE)
20 *extlist);
21static void *v2i_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method,
22 X509V3_CTX *ctx,
23 STACK_OF(CONF_VALUE) *values);
24
25const X509V3_EXT_METHOD v3_policy_constraints = {
26 NID_policy_constraints, 0,
27 ASN1_ITEM_ref(POLICY_CONSTRAINTS),
28 0, 0, 0, 0,
29 0, 0,
30 i2v_POLICY_CONSTRAINTS,
31 v2i_POLICY_CONSTRAINTS,
32 NULL, NULL,
33 NULL
34};
35
36ASN1_SEQUENCE(POLICY_CONSTRAINTS) = {
37 ASN1_IMP_OPT(POLICY_CONSTRAINTS, requireExplicitPolicy, ASN1_INTEGER,0),
38 ASN1_IMP_OPT(POLICY_CONSTRAINTS, inhibitPolicyMapping, ASN1_INTEGER,1)
39} ASN1_SEQUENCE_END(POLICY_CONSTRAINTS)
40
41IMPLEMENT_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)
42
43static STACK_OF(CONF_VALUE) *i2v_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD
44 *method, void *a, STACK_OF(CONF_VALUE)
45 *extlist)
46{
47 POLICY_CONSTRAINTS *pcons = a;
48 X509V3_add_value_int("Require Explicit Policy",
49 pcons->requireExplicitPolicy, &extlist);
50 X509V3_add_value_int("Inhibit Policy Mapping",
51 pcons->inhibitPolicyMapping, &extlist);
52 return extlist;
53}
54
55static void *v2i_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method,
56 X509V3_CTX *ctx,
57 STACK_OF(CONF_VALUE) *values)
58{
59 POLICY_CONSTRAINTS *pcons = NULL;
60 CONF_VALUE *val;
61 int i;
62
63 if ((pcons = POLICY_CONSTRAINTS_new()) == NULL) {
64 X509V3err(X509V3_F_V2I_POLICY_CONSTRAINTS, ERR_R_MALLOC_FAILURE);
65 return NULL;
66 }
67 for (i = 0; i < sk_CONF_VALUE_num(values); i++) {
68 val = sk_CONF_VALUE_value(values, i);
69 if (strcmp(val->name, "requireExplicitPolicy") == 0) {
70 if (!X509V3_get_value_int(val, &pcons->requireExplicitPolicy))
71 goto err;
72 } else if (strcmp(val->name, "inhibitPolicyMapping") == 0) {
73 if (!X509V3_get_value_int(val, &pcons->inhibitPolicyMapping))
74 goto err;
75 } else {
76 X509V3err(X509V3_F_V2I_POLICY_CONSTRAINTS, X509V3_R_INVALID_NAME);
77 X509V3_conf_err(val);
78 goto err;
79 }
80 }
81 if (!pcons->inhibitPolicyMapping && !pcons->requireExplicitPolicy) {
82 X509V3err(X509V3_F_V2I_POLICY_CONSTRAINTS,
83 X509V3_R_ILLEGAL_EMPTY_EXTENSION);
84 goto err;
85 }
86
87 return pcons;
88 err:
89 POLICY_CONSTRAINTS_free(pcons);
90 return NULL;
91}
Note: See TracBrowser for help on using the repository browser.