Index: openssl/crypto/x509v3/v3_alt.c |
=================================================================== |
--- openssl/crypto/x509v3/v3_alt.c (revision 105093) |
+++ openssl/crypto/x509v3/v3_alt.c (working copy) |
@@ -82,6 +82,12 @@ |
(X509V3_EXT_I2V)i2v_GENERAL_NAMES, |
(X509V3_EXT_V2I)v2i_issuer_alt, |
NULL, NULL, NULL}, |
+ |
+{ NID_certificate_issuer, 0, ASN1_ITEM_ref(GENERAL_NAMES), |
+0,0,0,0, |
+0,0, |
+(X509V3_EXT_I2V)i2v_GENERAL_NAMES, |
+NULL, NULL, NULL, NULL}, |
}; |
STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, |
@@ -387,8 +393,8 @@ |
} |
-GENERAL_NAMES *v2i_GENERAL_NAMES(X509V3_EXT_METHOD *method, |
- X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) |
+GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, |
+ X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) |
{ |
GENERAL_NAME *gen; |
GENERAL_NAMES *gens = NULL; |
@@ -409,28 +415,22 @@ |
return NULL; |
} |
-GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, |
- CONF_VALUE *cnf) |
+GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, |
+ CONF_VALUE *cnf) |
{ |
return v2i_GENERAL_NAME_ex(NULL, method, ctx, cnf, 0); |
} |
-GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, |
- X509V3_EXT_METHOD *method, X509V3_CTX *ctx, |
- CONF_VALUE *cnf, int is_nc) |
+GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, |
+ const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, |
+ int gen_type, char *value, int is_nc) |
{ |
char is_string = 0; |
- int type; |
GENERAL_NAME *gen = NULL; |
- char *name, *value; |
- |
- name = cnf->name; |
- value = cnf->value; |
- |
if(!value) |
{ |
- X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_MISSING_VALUE); |
+ X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_MISSING_VALUE); |
return NULL; |
} |
@@ -441,74 +441,62 @@ |
gen = GENERAL_NAME_new(); |
if(gen == NULL) |
{ |
- X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,ERR_R_MALLOC_FAILURE); |
+ X509V3err(X509V3_F_A2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE); |
return NULL; |
} |
} |
- if(!name_cmp(name, "email")) |
+ switch (gen_type) |
{ |
+ case GEN_URI: |
+ case GEN_EMAIL: |
+ case GEN_DNS: |
is_string = 1; |
- type = GEN_EMAIL; |
- } |
- else if(!name_cmp(name, "URI")) |
+ break; |
+ |
+ case GEN_RID: |
{ |
- is_string = 1; |
- type = GEN_URI; |
- } |
- else if(!name_cmp(name, "DNS")) |
- { |
- is_string = 1; |
- type = GEN_DNS; |
- } |
- else if(!name_cmp(name, "RID")) |
- { |
ASN1_OBJECT *obj; |
if(!(obj = OBJ_txt2obj(value,0))) |
{ |
- X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_BAD_OBJECT); |
+ X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_BAD_OBJECT); |
ERR_add_error_data(2, "value=", value); |
goto err; |
} |
gen->d.rid = obj; |
- type = GEN_RID; |
} |
- else if(!name_cmp(name, "IP")) |
- { |
+ break; |
+ |
+ case GEN_IPADD: |
if (is_nc) |
gen->d.ip = a2i_IPADDRESS_NC(value); |
else |
gen->d.ip = a2i_IPADDRESS(value); |
if(gen->d.ip == NULL) |
{ |
- X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_BAD_IP_ADDRESS); |
+ X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_BAD_IP_ADDRESS); |
ERR_add_error_data(2, "value=", value); |
goto err; |
} |
- type = GEN_IPADD; |
- } |
- else if(!name_cmp(name, "dirName")) |
- { |
- type = GEN_DIRNAME; |
+ break; |
+ |
+ case GEN_DIRNAME: |
if (!do_dirname(gen, value, ctx)) |
{ |
- X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_DIRNAME_ERROR); |
+ X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_DIRNAME_ERROR); |
goto err; |
} |
- } |
- else if(!name_cmp(name, "otherName")) |
- { |
+ break; |
+ |
+ case GEN_OTHERNAME: |
if (!do_othername(gen, value, ctx)) |
{ |
- X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_OTHERNAME_ERROR); |
+ X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_OTHERNAME_ERROR); |
goto err; |
} |
- type = GEN_OTHERNAME; |
- } |
- else |
- { |
- X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_UNSUPPORTED_OPTION); |
- ERR_add_error_data(2, "name=", name); |
+ break; |
+ default: |
+ X509V3err(X509V3_F_A2I_GENERAL_NAME,X509V3_R_UNSUPPORTED_TYPE); |
goto err; |
} |
@@ -518,12 +506,12 @@ |
!ASN1_STRING_set(gen->d.ia5, (unsigned char*)value, |
strlen(value))) |
{ |
- X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,ERR_R_MALLOC_FAILURE); |
+ X509V3err(X509V3_F_A2I_GENERAL_NAME,ERR_R_MALLOC_FAILURE); |
goto err; |
} |
} |
- gen->type = type; |
+ gen->type = gen_type; |
return gen; |
@@ -533,6 +521,48 @@ |
return NULL; |
} |
+GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, |
+ const X509V3_EXT_METHOD *method, |
+ X509V3_CTX *ctx, CONF_VALUE *cnf, int is_nc) |
+ { |
+ int type; |
+ |
+ char *name, *value; |
+ |
+ name = cnf->name; |
+ value = cnf->value; |
+ |
+ if(!value) |
+ { |
+ X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_MISSING_VALUE); |
+ return NULL; |
+ } |
+ |
+ if(!name_cmp(name, "email")) |
+ type = GEN_EMAIL; |
+ else if(!name_cmp(name, "URI")) |
+ type = GEN_URI; |
+ else if(!name_cmp(name, "DNS")) |
+ type = GEN_DNS; |
+ else if(!name_cmp(name, "RID")) |
+ type = GEN_RID; |
+ else if(!name_cmp(name, "IP")) |
+ type = GEN_IPADD; |
+ else if(!name_cmp(name, "dirName")) |
+ type = GEN_DIRNAME; |
+ else if(!name_cmp(name, "otherName")) |
+ type = GEN_OTHERNAME; |
+ else |
+ { |
+ X509V3err(X509V3_F_V2I_GENERAL_NAME_EX,X509V3_R_UNSUPPORTED_OPTION); |
+ ERR_add_error_data(2, "name=", name); |
+ return NULL; |
+ } |
+ |
+ return a2i_GENERAL_NAME(out, method, ctx, type, value, is_nc); |
+ |
+ } |
+ |
static int do_othername(GENERAL_NAME *gen, char *value, X509V3_CTX *ctx) |
{ |
char *objtmp = NULL, *p; |
@@ -578,7 +608,6 @@ |
if (!ret) |
X509_NAME_free(nm); |
gen->d.dirn = nm; |
- |
X509V3_section_free(ctx, sk); |
return ret; |