提交 07a38fd2 编写于 作者: F FdaSilvaYY 提交者: Matt Caswell

Fix some style and indent issue

simplify some code.
Reviewed-by: NRich Salz <rsalz@openssl.org>
Reviewed-by: NMatt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1618)
上级 d2a56999
...@@ -1385,8 +1385,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, ...@@ -1385,8 +1385,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
ASN1_STRING *str, *str2; ASN1_STRING *str, *str2;
ASN1_OBJECT *obj; ASN1_OBJECT *obj;
X509 *ret = NULL; X509 *ret = NULL;
X509_NAME_ENTRY *ne; X509_NAME_ENTRY *ne, *tne;
X509_NAME_ENTRY *tne, *push;
EVP_PKEY *pktmp; EVP_PKEY *pktmp;
int ok = -1, i, j, last, nid; int ok = -1, i, j, last, nid;
const char *p; const char *p;
...@@ -1419,41 +1418,37 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, ...@@ -1419,41 +1418,37 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
ne = X509_NAME_get_entry(name, i); ne = X509_NAME_get_entry(name, i);
str = X509_NAME_ENTRY_get_data(ne); str = X509_NAME_ENTRY_get_data(ne);
obj = X509_NAME_ENTRY_get_object(ne); obj = X509_NAME_ENTRY_get_object(ne);
nid = OBJ_obj2nid(obj);
if (msie_hack) { if (msie_hack) {
/* assume all type should be strings */ /* assume all type should be strings */
nid = OBJ_obj2nid(X509_NAME_ENTRY_get_object(ne));
if (str->type == V_ASN1_UNIVERSALSTRING) if (str->type == V_ASN1_UNIVERSALSTRING)
ASN1_UNIVERSALSTRING_to_string(str); ASN1_UNIVERSALSTRING_to_string(str);
if ((str->type == V_ASN1_IA5STRING) && if (str->type == V_ASN1_IA5STRING && nid != NID_pkcs9_emailAddress)
(nid != NID_pkcs9_emailAddress))
str->type = V_ASN1_T61STRING; str->type = V_ASN1_T61STRING;
if ((nid == NID_pkcs9_emailAddress) && if (nid == NID_pkcs9_emailAddress
(str->type == V_ASN1_PRINTABLESTRING)) && str->type == V_ASN1_PRINTABLESTRING)
str->type = V_ASN1_IA5STRING; str->type = V_ASN1_IA5STRING;
} }
/* If no EMAIL is wanted in the subject */ /* If no EMAIL is wanted in the subject */
if ((OBJ_obj2nid(obj) == NID_pkcs9_emailAddress) && (!email_dn)) if (nid == NID_pkcs9_emailAddress && !email_dn)
continue; continue;
/* check some things */ /* check some things */
if ((OBJ_obj2nid(obj) == NID_pkcs9_emailAddress) && if (nid == NID_pkcs9_emailAddress && str->type != V_ASN1_IA5STRING) {
(str->type != V_ASN1_IA5STRING)) {
BIO_printf(bio_err, BIO_printf(bio_err,
"\nemailAddress type needs to be of type IA5STRING\n"); "\nemailAddress type needs to be of type IA5STRING\n");
goto end; goto end;
} }
if ((str->type != V_ASN1_BMPSTRING) if (str->type != V_ASN1_BMPSTRING && str->type != V_ASN1_UTF8STRING) {
&& (str->type != V_ASN1_UTF8STRING)) {
j = ASN1_PRINTABLE_type(str->data, str->length); j = ASN1_PRINTABLE_type(str->data, str->length);
if (((j == V_ASN1_T61STRING) && if ((j == V_ASN1_T61STRING && str->type != V_ASN1_T61STRING) ||
(str->type != V_ASN1_T61STRING)) || (j == V_ASN1_IA5STRING && str->type == V_ASN1_PRINTABLESTRING))
((j == V_ASN1_IA5STRING) && {
(str->type == V_ASN1_PRINTABLESTRING))) {
BIO_printf(bio_err, BIO_printf(bio_err,
"\nThe string contains characters that are illegal for the ASN.1 type\n"); "\nThe string contains characters that are illegal for the ASN.1 type\n");
goto end; goto end;
...@@ -1491,6 +1486,8 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, ...@@ -1491,6 +1486,8 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
last = -1; last = -1;
for (;;) { for (;;) {
X509_NAME_ENTRY *push = NULL;
/* lookup the object in the supplied name list */ /* lookup the object in the supplied name list */
j = X509_NAME_get_index_by_OBJ(name, obj, last); j = X509_NAME_get_index_by_OBJ(name, obj, last);
if (j < 0) { if (j < 0) {
...@@ -1503,7 +1500,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, ...@@ -1503,7 +1500,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
last = j; last = j;
/* depending on the 'policy', decide what to do. */ /* depending on the 'policy', decide what to do. */
push = NULL;
if (strcmp(cv->value, "optional") == 0) { if (strcmp(cv->value, "optional") == 0) {
if (tne != NULL) if (tne != NULL)
push = tne; push = tne;
...@@ -1584,10 +1580,9 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, ...@@ -1584,10 +1580,9 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
BIO_printf(bio_err, BIO_printf(bio_err,
"The subject name appears to be ok, checking data base for clashes\n"); "The subject name appears to be ok, checking data base for clashes\n");
/* Build the correct Subject if no e-mail is wanted in the subject */
/* /*
* and add it later on because of the method extensions are added * Build the correct Subject if no e-mail is wanted in the subject.
* (altName) * And add it later on because of the method extensions are added (altName)
*/ */
if (email_dn) if (email_dn)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册