summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/asn_moid.c
diff options
context:
space:
mode:
authordjm <>2008-09-06 12:17:54 +0000
committerdjm <>2008-09-06 12:17:54 +0000
commit38ce604e3cc97706b876b0525ddff0121115456d (patch)
tree7ccc28afe1789ea3dbedf72365f955d5b8e105b5 /src/lib/libcrypto/asn1/asn_moid.c
parent12867252827c8efaa8ddd1fa3b3d6e321e2bcdef (diff)
downloadopenbsd-38ce604e3cc97706b876b0525ddff0121115456d.tar.gz
openbsd-38ce604e3cc97706b876b0525ddff0121115456d.tar.bz2
openbsd-38ce604e3cc97706b876b0525ddff0121115456d.zip
resolve conflicts
Diffstat (limited to 'src/lib/libcrypto/asn1/asn_moid.c')
-rw-r--r--src/lib/libcrypto/asn1/asn_moid.c64
1 files changed, 62 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/asn_moid.c b/src/lib/libcrypto/asn1/asn_moid.c
index edb44c988f..9132350f10 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 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2001-2004 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,6 +57,7 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <ctype.h>
60#include <openssl/crypto.h> 61#include <openssl/crypto.h>
61#include "cryptlib.h" 62#include "cryptlib.h"
62#include <openssl/conf.h> 63#include <openssl/conf.h>
@@ -65,6 +66,8 @@
65 66
66/* Simple ASN1 OID module: add all objects in a given section */ 67/* Simple ASN1 OID module: add all objects in a given section */
67 68
69static int do_create(char *value, char *name);
70
68static int oid_module_init(CONF_IMODULE *md, const CONF *cnf) 71static int oid_module_init(CONF_IMODULE *md, const CONF *cnf)
69 { 72 {
70 int i; 73 int i;
@@ -80,7 +83,7 @@ static int oid_module_init(CONF_IMODULE *md, const CONF *cnf)
80 for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++) 83 for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++)
81 { 84 {
82 oval = sk_CONF_VALUE_value(sktmp, i); 85 oval = sk_CONF_VALUE_value(sktmp, i);
83 if(OBJ_create(oval->value, oval->name, oval->name) == NID_undef) 86 if(!do_create(oval->value, oval->name))
84 { 87 {
85 ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT); 88 ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT);
86 return 0; 89 return 0;
@@ -98,3 +101,60 @@ void ASN1_add_oid_module(void)
98 { 101 {
99 CONF_module_add("oid_section", oid_module_init, oid_module_finish); 102 CONF_module_add("oid_section", oid_module_init, oid_module_finish);
100 } 103 }
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
111static 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