diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/asn_moid.c')
-rw-r--r-- | src/lib/libcrypto/asn1/asn_moid.c | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/src/lib/libcrypto/asn1/asn_moid.c b/src/lib/libcrypto/asn1/asn_moid.c index 9132350f10..edb44c988f 100644 --- a/src/lib/libcrypto/asn1/asn_moid.c +++ b/src/lib/libcrypto/asn1/asn_moid.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * project 2001. | 3 | * project 2001. |
4 | */ | 4 | */ |
5 | /* ==================================================================== | 5 | /* ==================================================================== |
6 | * Copyright (c) 2001-2004 The OpenSSL Project. All rights reserved. | 6 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions |
@@ -57,7 +57,6 @@ | |||
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <ctype.h> | ||
61 | #include <openssl/crypto.h> | 60 | #include <openssl/crypto.h> |
62 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
63 | #include <openssl/conf.h> | 62 | #include <openssl/conf.h> |
@@ -66,8 +65,6 @@ | |||
66 | 65 | ||
67 | /* Simple ASN1 OID module: add all objects in a given section */ | 66 | /* Simple ASN1 OID module: add all objects in a given section */ |
68 | 67 | ||
69 | static int do_create(char *value, char *name); | ||
70 | |||
71 | static int oid_module_init(CONF_IMODULE *md, const CONF *cnf) | 68 | static int oid_module_init(CONF_IMODULE *md, const CONF *cnf) |
72 | { | 69 | { |
73 | int i; | 70 | int i; |
@@ -83,7 +80,7 @@ static int oid_module_init(CONF_IMODULE *md, const CONF *cnf) | |||
83 | for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++) | 80 | for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++) |
84 | { | 81 | { |
85 | oval = sk_CONF_VALUE_value(sktmp, i); | 82 | oval = sk_CONF_VALUE_value(sktmp, i); |
86 | if(!do_create(oval->value, oval->name)) | 83 | if(OBJ_create(oval->value, oval->name, oval->name) == NID_undef) |
87 | { | 84 | { |
88 | ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT); | 85 | ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT); |
89 | return 0; | 86 | return 0; |
@@ -101,60 +98,3 @@ void ASN1_add_oid_module(void) | |||
101 | { | 98 | { |
102 | CONF_module_add("oid_section", oid_module_init, oid_module_finish); | 99 | CONF_module_add("oid_section", oid_module_init, oid_module_finish); |
103 | } | 100 | } |
104 | |||
105 | /* Create an OID based on a name value pair. Accept two formats. | ||
106 | * shortname = 1.2.3.4 | ||
107 | * shortname = some long name, 1.2.3.4 | ||
108 | */ | ||
109 | |||
110 | |||
111 | static int do_create(char *value, char *name) | ||
112 | { | ||
113 | int nid; | ||
114 | ASN1_OBJECT *oid; | ||
115 | char *ln, *ostr, *p, *lntmp; | ||
116 | p = strrchr(value, ','); | ||
117 | if (!p) | ||
118 | { | ||
119 | ln = name; | ||
120 | ostr = value; | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | ln = NULL; | ||
125 | ostr = p + 1; | ||
126 | if (!*ostr) | ||
127 | return 0; | ||
128 | while(isspace((unsigned char)*ostr)) ostr++; | ||
129 | } | ||
130 | |||
131 | nid = OBJ_create(ostr, name, ln); | ||
132 | |||
133 | if (nid == NID_undef) | ||
134 | return 0; | ||
135 | |||
136 | if (p) | ||
137 | { | ||
138 | ln = value; | ||
139 | while(isspace((unsigned char)*ln)) ln++; | ||
140 | p--; | ||
141 | while(isspace((unsigned char)*p)) | ||
142 | { | ||
143 | if (p == ln) | ||
144 | return 0; | ||
145 | p--; | ||
146 | } | ||
147 | p++; | ||
148 | lntmp = OPENSSL_malloc((p - ln) + 1); | ||
149 | if (lntmp == NULL) | ||
150 | return 0; | ||
151 | memcpy(lntmp, ln, p - ln); | ||
152 | lntmp[p - ln] = 0; | ||
153 | oid = OBJ_nid2obj(nid); | ||
154 | oid->ln = lntmp; | ||
155 | } | ||
156 | |||
157 | return 1; | ||
158 | } | ||
159 | |||
160 | |||