source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/x509v3/v3_bitst.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.1 KB
Line 
1/*
2 * Copyright 1999-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/conf.h>
13#include <openssl/x509v3.h>
14#include "ext_dat.h"
15
16static BIT_STRING_BITNAME ns_cert_type_table[] = {
17 {0, "SSL Client", "client"},
18 {1, "SSL Server", "server"},
19 {2, "S/MIME", "email"},
20 {3, "Object Signing", "objsign"},
21 {4, "Unused", "reserved"},
22 {5, "SSL CA", "sslCA"},
23 {6, "S/MIME CA", "emailCA"},
24 {7, "Object Signing CA", "objCA"},
25 {-1, NULL, NULL}
26};
27
28static BIT_STRING_BITNAME key_usage_type_table[] = {
29 {0, "Digital Signature", "digitalSignature"},
30 {1, "Non Repudiation", "nonRepudiation"},
31 {2, "Key Encipherment", "keyEncipherment"},
32 {3, "Data Encipherment", "dataEncipherment"},
33 {4, "Key Agreement", "keyAgreement"},
34 {5, "Certificate Sign", "keyCertSign"},
35 {6, "CRL Sign", "cRLSign"},
36 {7, "Encipher Only", "encipherOnly"},
37 {8, "Decipher Only", "decipherOnly"},
38 {-1, NULL, NULL}
39};
40
41const X509V3_EXT_METHOD v3_nscert =
42EXT_BITSTRING(NID_netscape_cert_type, ns_cert_type_table);
43const X509V3_EXT_METHOD v3_key_usage =
44EXT_BITSTRING(NID_key_usage, key_usage_type_table);
45
46STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
47 ASN1_BIT_STRING *bits,
48 STACK_OF(CONF_VALUE) *ret)
49{
50 BIT_STRING_BITNAME *bnam;
51 for (bnam = method->usr_data; bnam->lname; bnam++) {
52 if (ASN1_BIT_STRING_get_bit(bits, bnam->bitnum))
53 X509V3_add_value(bnam->lname, NULL, &ret);
54 }
55 return ret;
56}
57
58ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
59 X509V3_CTX *ctx,
60 STACK_OF(CONF_VALUE) *nval)
61{
62 CONF_VALUE *val;
63 ASN1_BIT_STRING *bs;
64 int i;
65 BIT_STRING_BITNAME *bnam;
66 if ((bs = ASN1_BIT_STRING_new()) == NULL) {
67 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, ERR_R_MALLOC_FAILURE);
68 return NULL;
69 }
70 for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
71 val = sk_CONF_VALUE_value(nval, i);
72 for (bnam = method->usr_data; bnam->lname; bnam++) {
73 if (strcmp(bnam->sname, val->name) == 0
74 || strcmp(bnam->lname, val->name) == 0) {
75 if (!ASN1_BIT_STRING_set_bit(bs, bnam->bitnum, 1)) {
76 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,
77 ERR_R_MALLOC_FAILURE);
78 ASN1_BIT_STRING_free(bs);
79 return NULL;
80 }
81 break;
82 }
83 }
84 if (!bnam->lname) {
85 X509V3err(X509V3_F_V2I_ASN1_BIT_STRING,
86 X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT);
87 X509V3_conf_err(val);
88 ASN1_BIT_STRING_free(bs);
89 return NULL;
90 }
91 }
92 return bs;
93}
Note: See TracBrowser for help on using the repository browser.