source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/asn1/asn_moid.c

Last change on this file 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: 2.5 KB
Line 
1/*
2 * Copyright 2002-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 <ctype.h>
12#include <openssl/crypto.h>
13#include "internal/cryptlib.h"
14#include <openssl/conf.h>
15#include <openssl/x509.h>
16#include "internal/asn1_int.h"
17#include "internal/objects.h"
18
19/* Simple ASN1 OID module: add all objects in a given section */
20
21static int do_create(const char *value, const char *name);
22
23static int oid_module_init(CONF_IMODULE *md, const CONF *cnf)
24{
25 int i;
26 const char *oid_section;
27 STACK_OF(CONF_VALUE) *sktmp;
28 CONF_VALUE *oval;
29
30 oid_section = CONF_imodule_get_value(md);
31 if ((sktmp = NCONF_get_section(cnf, oid_section)) == NULL) {
32 ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION);
33 return 0;
34 }
35 for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) {
36 oval = sk_CONF_VALUE_value(sktmp, i);
37 if (!do_create(oval->value, oval->name)) {
38 ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT);
39 return 0;
40 }
41 }
42 return 1;
43}
44
45static void oid_module_finish(CONF_IMODULE *md)
46{
47}
48
49void ASN1_add_oid_module(void)
50{
51 CONF_module_add("oid_section", oid_module_init, oid_module_finish);
52}
53
54/*-
55 * Create an OID based on a name value pair. Accept two formats.
56 * shortname = 1.2.3.4
57 * shortname = some long name, 1.2.3.4
58 */
59
60static int do_create(const char *value, const char *name)
61{
62 int nid;
63 ASN1_OBJECT *oid;
64 const char *ln, *ostr, *p;
65 char *lntmp;
66 p = strrchr(value, ',');
67 if (!p) {
68 ln = name;
69 ostr = value;
70 } else {
71 ln = NULL;
72 ostr = p + 1;
73 if (!*ostr)
74 return 0;
75 while (isspace((unsigned char)*ostr))
76 ostr++;
77 }
78
79 nid = OBJ_create(ostr, name, ln);
80
81 if (nid == NID_undef)
82 return 0;
83
84 if (p) {
85 ln = value;
86 while (isspace((unsigned char)*ln))
87 ln++;
88 p--;
89 while (isspace((unsigned char)*p)) {
90 if (p == ln)
91 return 0;
92 p--;
93 }
94 p++;
95 lntmp = OPENSSL_malloc((p - ln) + 1);
96 if (lntmp == NULL)
97 return 0;
98 memcpy(lntmp, ln, p - ln);
99 lntmp[p - ln] = 0;
100 oid = OBJ_nid2obj(nid);
101 oid->ln = lntmp;
102 }
103
104 return 1;
105}
Note: See TracBrowser for help on using the repository browser.