From 323b4b18ae2f01eb4aa753eaa0d903fffe60e2a6 Mon Sep 17 00:00:00 2001 From: jsing Date: Mon, 21 Apr 2014 16:49:02 +0000 Subject: [PATCH] KNF. --- lib/libcrypto/x509v3/tabtest.c | 22 +++--- lib/libcrypto/x509v3/v3_enum.c | 52 +++++++------- lib/libcrypto/x509v3/v3_extku.c | 56 ++++++++------- lib/libcrypto/x509v3/v3_genn.c | 91 +++++++++++++------------ lib/libssl/src/crypto/x509v3/tabtest.c | 22 +++--- lib/libssl/src/crypto/x509v3/v3_enum.c | 52 +++++++------- lib/libssl/src/crypto/x509v3/v3_extku.c | 56 ++++++++------- lib/libssl/src/crypto/x509v3/v3_genn.c | 91 +++++++++++++------------ 8 files changed, 238 insertions(+), 204 deletions(-) diff --git a/lib/libcrypto/x509v3/tabtest.c b/lib/libcrypto/x509v3/tabtest.c index 5ed6eb68911..6b8a211e5d9 100644 --- a/lib/libcrypto/x509v3/tabtest.c +++ b/lib/libcrypto/x509v3/tabtest.c @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -70,19 +70,23 @@ main() { int i, prev = -1, bad = 0; X509V3_EXT_METHOD **tmp; + i = sizeof(standard_exts) / sizeof(X509V3_EXT_METHOD *); - if(i != STANDARD_EXTENSION_COUNT) + if (i != STANDARD_EXTENSION_COUNT) fprintf(stderr, "Extension number invalid expecting %d\n", i); tmp = standard_exts; - for(i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) { - if((*tmp)->ext_nid < prev) bad = 1; + for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) { + if ((*tmp)->ext_nid < prev) + bad = 1; prev = (*tmp)->ext_nid; - + } - if(bad) { + if (bad) { tmp = standard_exts; fprintf(stderr, "Extensions out of order!\n"); - for(i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) - printf("%d : %s\n", (*tmp)->ext_nid, OBJ_nid2sn((*tmp)->ext_nid)); - } else fprintf(stderr, "Order OK\n"); + for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) + printf("%d : %s\n", (*tmp)->ext_nid, + OBJ_nid2sn((*tmp)->ext_nid)); + } else + fprintf(stderr, "Order OK\n"); } diff --git a/lib/libcrypto/x509v3/v3_enum.c b/lib/libcrypto/x509v3/v3_enum.c index c0575e368d3..b546014b2bb 100644 --- a/lib/libcrypto/x509v3/v3_enum.c +++ b/lib/libcrypto/x509v3/v3_enum.c @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -61,37 +61,39 @@ #include static ENUMERATED_NAMES crl_reasons[] = { -{CRL_REASON_UNSPECIFIED, "Unspecified", "unspecified"}, -{CRL_REASON_KEY_COMPROMISE, "Key Compromise", "keyCompromise"}, -{CRL_REASON_CA_COMPROMISE, "CA Compromise", "CACompromise"}, -{CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", "affiliationChanged"}, -{CRL_REASON_SUPERSEDED, "Superseded", "superseded"}, -{CRL_REASON_CESSATION_OF_OPERATION, - "Cessation Of Operation", "cessationOfOperation"}, -{CRL_REASON_CERTIFICATE_HOLD, "Certificate Hold", "certificateHold"}, -{CRL_REASON_REMOVE_FROM_CRL, "Remove From CRL", "removeFromCRL"}, -{CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", "privilegeWithdrawn"}, -{CRL_REASON_AA_COMPROMISE, "AA Compromise", "AACompromise"}, -{-1, NULL, NULL} + {CRL_REASON_UNSPECIFIED, "Unspecified", "unspecified"}, + {CRL_REASON_KEY_COMPROMISE, "Key Compromise", "keyCompromise"}, + {CRL_REASON_CA_COMPROMISE, "CA Compromise", "CACompromise"}, + {CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", "affiliationChanged"}, + {CRL_REASON_SUPERSEDED, "Superseded", "superseded"}, + {CRL_REASON_CESSATION_OF_OPERATION, + "Cessation Of Operation", "cessationOfOperation"}, + {CRL_REASON_CERTIFICATE_HOLD, "Certificate Hold", "certificateHold"}, + {CRL_REASON_REMOVE_FROM_CRL, "Remove From CRL", "removeFromCRL"}, + {CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", "privilegeWithdrawn"}, + {CRL_REASON_AA_COMPROMISE, "AA Compromise", "AACompromise"}, + {-1, NULL, NULL} }; -const X509V3_EXT_METHOD v3_crl_reason = { -NID_crl_reason, 0, ASN1_ITEM_ref(ASN1_ENUMERATED), -0,0,0,0, -(X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE, -0, -0,0,0,0, -crl_reasons}; - +const X509V3_EXT_METHOD v3_crl_reason = { + NID_crl_reason, 0, ASN1_ITEM_ref(ASN1_ENUMERATED), + 0, 0, 0, 0, + (X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE, + 0, + 0, 0, 0, 0, + crl_reasons +}; -char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, - ASN1_ENUMERATED *e) +char * +i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *e) { ENUMERATED_NAMES *enam; long strval; + strval = ASN1_ENUMERATED_get(e); - for(enam = method->usr_data; enam->lname; enam++) { - if(strval == enam->bitnum) return BUF_strdup(enam->lname); + for (enam = method->usr_data; enam->lname; enam++) { + if (strval == enam->bitnum) + return BUF_strdup(enam->lname); } return i2s_ASN1_ENUMERATED(method, e); } diff --git a/lib/libcrypto/x509v3/v3_extku.c b/lib/libcrypto/x509v3/v3_extku.c index 1c665327570..30d800d3abc 100644 --- a/lib/libcrypto/x509v3/v3_extku.c +++ b/lib/libcrypto/x509v3/v3_extku.c @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -64,19 +64,18 @@ #include static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, - STACK_OF(CONF_VALUE) *nval); -static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, - void *eku, STACK_OF(CONF_VALUE) *extlist); + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); +static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE( + const X509V3_EXT_METHOD *method, void *eku, STACK_OF(CONF_VALUE) *extlist); const X509V3_EXT_METHOD v3_ext_ku = { NID_ext_key_usage, 0, ASN1_ITEM_ref(EXTENDED_KEY_USAGE), - 0,0,0,0, - 0,0, + 0, 0, 0, 0, + 0, 0, i2v_EXTENDED_KEY_USAGE, v2i_EXTENDED_KEY_USAGE, - 0,0, + 0, 0, NULL }; @@ -84,29 +83,31 @@ const X509V3_EXT_METHOD v3_ext_ku = { const X509V3_EXT_METHOD v3_ocsp_accresp = { NID_id_pkix_OCSP_acceptableResponses, 0, ASN1_ITEM_ref(EXTENDED_KEY_USAGE), - 0,0,0,0, - 0,0, + 0, 0, 0, 0, + 0, 0, i2v_EXTENDED_KEY_USAGE, v2i_EXTENDED_KEY_USAGE, - 0,0, + 0, 0, NULL }; -ASN1_ITEM_TEMPLATE(EXTENDED_KEY_USAGE) = - ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, EXTENDED_KEY_USAGE, ASN1_OBJECT) +ASN1_ITEM_TEMPLATE(EXTENDED_KEY_USAGE) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, EXTENDED_KEY_USAGE, + ASN1_OBJECT) ASN1_ITEM_TEMPLATE_END(EXTENDED_KEY_USAGE) IMPLEMENT_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) static STACK_OF(CONF_VALUE) * - i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, void *a, - STACK_OF(CONF_VALUE) *ext_list) +i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, void *a, + STACK_OF(CONF_VALUE) *ext_list) { EXTENDED_KEY_USAGE *eku = a; int i; ASN1_OBJECT *obj; char obj_tmp[80]; - for(i = 0; i < sk_ASN1_OBJECT_num(eku); i++) { + + for (i = 0; i < sk_ASN1_OBJECT_num(eku); i++) { obj = sk_ASN1_OBJECT_value(eku, i); i2t_ASN1_OBJECT(obj_tmp, 80, obj); X509V3_add_value(NULL, obj_tmp, &ext_list); @@ -114,8 +115,9 @@ static STACK_OF(CONF_VALUE) * return ext_list; } -static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) +static void * +v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, + STACK_OF(CONF_VALUE) *nval) { EXTENDED_KEY_USAGE *extku; char *extval; @@ -123,18 +125,22 @@ static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, CONF_VALUE *val; int i; - if(!(extku = sk_ASN1_OBJECT_new_null())) { - X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE,ERR_R_MALLOC_FAILURE); + if (!(extku = sk_ASN1_OBJECT_new_null())) { + X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, + ERR_R_MALLOC_FAILURE); return NULL; } - for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { + for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { val = sk_CONF_VALUE_value(nval, i); - if(val->value) extval = val->value; - else extval = val->name; - if(!(objtmp = OBJ_txt2obj(extval, 0))) { + if (val->value) + extval = val->value; + else + extval = val->name; + if (!(objtmp = OBJ_txt2obj(extval, 0))) { sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free); - X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE,X509V3_R_INVALID_OBJECT_IDENTIFIER); + X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, + X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(val); return NULL; } diff --git a/lib/libcrypto/x509v3/v3_genn.c b/lib/libcrypto/x509v3/v3_genn.c index b6283573013..b47098e5a7e 100644 --- a/lib/libcrypto/x509v3/v3_genn.c +++ b/lib/libcrypto/x509v3/v3_genn.c @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -94,27 +94,28 @@ ASN1_CHOICE(GENERAL_NAME) = { IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAME) -ASN1_ITEM_TEMPLATE(GENERAL_NAMES) = - ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, GENERAL_NAME) +ASN1_ITEM_TEMPLATE(GENERAL_NAMES) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, GENERAL_NAME) ASN1_ITEM_TEMPLATE_END(GENERAL_NAMES) IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAMES) -GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a) - { - return (GENERAL_NAME *) ASN1_dup((i2d_of_void *) i2d_GENERAL_NAME, - (d2i_of_void *) d2i_GENERAL_NAME, - (char *) a); - } +GENERAL_NAME * +GENERAL_NAME_dup(GENERAL_NAME *a) +{ + return (GENERAL_NAME *)ASN1_dup((i2d_of_void *)i2d_GENERAL_NAME, + (d2i_of_void *)d2i_GENERAL_NAME, (char *)a); +} /* Returns 0 if they are equal, != 0 otherwise. */ -int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) - { +int +GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) +{ int result = -1; - if (!a || !b || a->type != b->type) return -1; - switch(a->type) - { + if (!a || !b || a->type != b->type) + return -1; + switch (a->type) { case GEN_X400: case GEN_EDIPARTY: result = ASN1_TYPE_cmp(a->d.other, b->d.other); @@ -137,32 +138,34 @@ int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) case GEN_IPADD: result = ASN1_OCTET_STRING_cmp(a->d.ip, b->d.ip); break; - + case GEN_RID: result = OBJ_cmp(a->d.rid, b->d.rid); break; - } - return result; } + return result; +} /* Returns 0 if they are equal, != 0 otherwise. */ -int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b) - { +int +OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b) +{ int result = -1; - if (!a || !b) return -1; + if (!a || !b) + return -1; /* Check their type first. */ if ((result = OBJ_cmp(a->type_id, b->type_id)) != 0) return result; /* Check the value. */ result = ASN1_TYPE_cmp(a->value, b->value); return result; - } +} -void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) - { - switch(type) - { +void +GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) +{ + switch (type) { case GEN_X400: case GEN_EDIPARTY: a->d.other = value; @@ -185,20 +188,20 @@ void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) case GEN_IPADD: a->d.ip = value; break; - + case GEN_RID: a->d.rid = value; break; - } - a->type = type; } + a->type = type; +} -void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) - { +void * +GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) +{ if (ptype) *ptype = a->type; - switch(a->type) - { + switch (a->type) { case GEN_X400: case GEN_EDIPARTY: return a->d.other; @@ -216,19 +219,21 @@ void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) case GEN_IPADD: return a->d.ip; - + case GEN_RID: return a->d.rid; default: return NULL; - } } +} -int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, - ASN1_OBJECT *oid, ASN1_TYPE *value) - { +int +GENERAL_NAME_set0_othername(GENERAL_NAME *gen, ASN1_OBJECT *oid, + ASN1_TYPE *value) +{ OTHERNAME *oth; + oth = OTHERNAME_new(); if (!oth) return 0; @@ -236,11 +241,12 @@ int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, oth->value = value; GENERAL_NAME_set0_value(gen, GEN_OTHERNAME, oth); return 1; - } +} -int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, - ASN1_OBJECT **poid, ASN1_TYPE **pvalue) - { +int +GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, ASN1_OBJECT **poid, + ASN1_TYPE **pvalue) +{ if (gen->type != GEN_OTHERNAME) return 0; if (poid) @@ -248,5 +254,4 @@ int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, if (pvalue) *pvalue = gen->d.otherName->value; return 1; - } - +} diff --git a/lib/libssl/src/crypto/x509v3/tabtest.c b/lib/libssl/src/crypto/x509v3/tabtest.c index 5ed6eb68911..6b8a211e5d9 100644 --- a/lib/libssl/src/crypto/x509v3/tabtest.c +++ b/lib/libssl/src/crypto/x509v3/tabtest.c @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -70,19 +70,23 @@ main() { int i, prev = -1, bad = 0; X509V3_EXT_METHOD **tmp; + i = sizeof(standard_exts) / sizeof(X509V3_EXT_METHOD *); - if(i != STANDARD_EXTENSION_COUNT) + if (i != STANDARD_EXTENSION_COUNT) fprintf(stderr, "Extension number invalid expecting %d\n", i); tmp = standard_exts; - for(i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) { - if((*tmp)->ext_nid < prev) bad = 1; + for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) { + if ((*tmp)->ext_nid < prev) + bad = 1; prev = (*tmp)->ext_nid; - + } - if(bad) { + if (bad) { tmp = standard_exts; fprintf(stderr, "Extensions out of order!\n"); - for(i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) - printf("%d : %s\n", (*tmp)->ext_nid, OBJ_nid2sn((*tmp)->ext_nid)); - } else fprintf(stderr, "Order OK\n"); + for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) + printf("%d : %s\n", (*tmp)->ext_nid, + OBJ_nid2sn((*tmp)->ext_nid)); + } else + fprintf(stderr, "Order OK\n"); } diff --git a/lib/libssl/src/crypto/x509v3/v3_enum.c b/lib/libssl/src/crypto/x509v3/v3_enum.c index c0575e368d3..b546014b2bb 100644 --- a/lib/libssl/src/crypto/x509v3/v3_enum.c +++ b/lib/libssl/src/crypto/x509v3/v3_enum.c @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -61,37 +61,39 @@ #include static ENUMERATED_NAMES crl_reasons[] = { -{CRL_REASON_UNSPECIFIED, "Unspecified", "unspecified"}, -{CRL_REASON_KEY_COMPROMISE, "Key Compromise", "keyCompromise"}, -{CRL_REASON_CA_COMPROMISE, "CA Compromise", "CACompromise"}, -{CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", "affiliationChanged"}, -{CRL_REASON_SUPERSEDED, "Superseded", "superseded"}, -{CRL_REASON_CESSATION_OF_OPERATION, - "Cessation Of Operation", "cessationOfOperation"}, -{CRL_REASON_CERTIFICATE_HOLD, "Certificate Hold", "certificateHold"}, -{CRL_REASON_REMOVE_FROM_CRL, "Remove From CRL", "removeFromCRL"}, -{CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", "privilegeWithdrawn"}, -{CRL_REASON_AA_COMPROMISE, "AA Compromise", "AACompromise"}, -{-1, NULL, NULL} + {CRL_REASON_UNSPECIFIED, "Unspecified", "unspecified"}, + {CRL_REASON_KEY_COMPROMISE, "Key Compromise", "keyCompromise"}, + {CRL_REASON_CA_COMPROMISE, "CA Compromise", "CACompromise"}, + {CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", "affiliationChanged"}, + {CRL_REASON_SUPERSEDED, "Superseded", "superseded"}, + {CRL_REASON_CESSATION_OF_OPERATION, + "Cessation Of Operation", "cessationOfOperation"}, + {CRL_REASON_CERTIFICATE_HOLD, "Certificate Hold", "certificateHold"}, + {CRL_REASON_REMOVE_FROM_CRL, "Remove From CRL", "removeFromCRL"}, + {CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", "privilegeWithdrawn"}, + {CRL_REASON_AA_COMPROMISE, "AA Compromise", "AACompromise"}, + {-1, NULL, NULL} }; -const X509V3_EXT_METHOD v3_crl_reason = { -NID_crl_reason, 0, ASN1_ITEM_ref(ASN1_ENUMERATED), -0,0,0,0, -(X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE, -0, -0,0,0,0, -crl_reasons}; - +const X509V3_EXT_METHOD v3_crl_reason = { + NID_crl_reason, 0, ASN1_ITEM_ref(ASN1_ENUMERATED), + 0, 0, 0, 0, + (X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE, + 0, + 0, 0, 0, 0, + crl_reasons +}; -char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, - ASN1_ENUMERATED *e) +char * +i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *e) { ENUMERATED_NAMES *enam; long strval; + strval = ASN1_ENUMERATED_get(e); - for(enam = method->usr_data; enam->lname; enam++) { - if(strval == enam->bitnum) return BUF_strdup(enam->lname); + for (enam = method->usr_data; enam->lname; enam++) { + if (strval == enam->bitnum) + return BUF_strdup(enam->lname); } return i2s_ASN1_ENUMERATED(method, e); } diff --git a/lib/libssl/src/crypto/x509v3/v3_extku.c b/lib/libssl/src/crypto/x509v3/v3_extku.c index 1c665327570..30d800d3abc 100644 --- a/lib/libssl/src/crypto/x509v3/v3_extku.c +++ b/lib/libssl/src/crypto/x509v3/v3_extku.c @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -64,19 +64,18 @@ #include static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, - STACK_OF(CONF_VALUE) *nval); -static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, - void *eku, STACK_OF(CONF_VALUE) *extlist); + X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); +static STACK_OF(CONF_VALUE) *i2v_EXTENDED_KEY_USAGE( + const X509V3_EXT_METHOD *method, void *eku, STACK_OF(CONF_VALUE) *extlist); const X509V3_EXT_METHOD v3_ext_ku = { NID_ext_key_usage, 0, ASN1_ITEM_ref(EXTENDED_KEY_USAGE), - 0,0,0,0, - 0,0, + 0, 0, 0, 0, + 0, 0, i2v_EXTENDED_KEY_USAGE, v2i_EXTENDED_KEY_USAGE, - 0,0, + 0, 0, NULL }; @@ -84,29 +83,31 @@ const X509V3_EXT_METHOD v3_ext_ku = { const X509V3_EXT_METHOD v3_ocsp_accresp = { NID_id_pkix_OCSP_acceptableResponses, 0, ASN1_ITEM_ref(EXTENDED_KEY_USAGE), - 0,0,0,0, - 0,0, + 0, 0, 0, 0, + 0, 0, i2v_EXTENDED_KEY_USAGE, v2i_EXTENDED_KEY_USAGE, - 0,0, + 0, 0, NULL }; -ASN1_ITEM_TEMPLATE(EXTENDED_KEY_USAGE) = - ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, EXTENDED_KEY_USAGE, ASN1_OBJECT) +ASN1_ITEM_TEMPLATE(EXTENDED_KEY_USAGE) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, EXTENDED_KEY_USAGE, + ASN1_OBJECT) ASN1_ITEM_TEMPLATE_END(EXTENDED_KEY_USAGE) IMPLEMENT_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) static STACK_OF(CONF_VALUE) * - i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, void *a, - STACK_OF(CONF_VALUE) *ext_list) +i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, void *a, + STACK_OF(CONF_VALUE) *ext_list) { EXTENDED_KEY_USAGE *eku = a; int i; ASN1_OBJECT *obj; char obj_tmp[80]; - for(i = 0; i < sk_ASN1_OBJECT_num(eku); i++) { + + for (i = 0; i < sk_ASN1_OBJECT_num(eku); i++) { obj = sk_ASN1_OBJECT_value(eku, i); i2t_ASN1_OBJECT(obj_tmp, 80, obj); X509V3_add_value(NULL, obj_tmp, &ext_list); @@ -114,8 +115,9 @@ static STACK_OF(CONF_VALUE) * return ext_list; } -static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) +static void * +v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, + STACK_OF(CONF_VALUE) *nval) { EXTENDED_KEY_USAGE *extku; char *extval; @@ -123,18 +125,22 @@ static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, CONF_VALUE *val; int i; - if(!(extku = sk_ASN1_OBJECT_new_null())) { - X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE,ERR_R_MALLOC_FAILURE); + if (!(extku = sk_ASN1_OBJECT_new_null())) { + X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, + ERR_R_MALLOC_FAILURE); return NULL; } - for(i = 0; i < sk_CONF_VALUE_num(nval); i++) { + for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { val = sk_CONF_VALUE_value(nval, i); - if(val->value) extval = val->value; - else extval = val->name; - if(!(objtmp = OBJ_txt2obj(extval, 0))) { + if (val->value) + extval = val->value; + else + extval = val->name; + if (!(objtmp = OBJ_txt2obj(extval, 0))) { sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free); - X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE,X509V3_R_INVALID_OBJECT_IDENTIFIER); + X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, + X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(val); return NULL; } diff --git a/lib/libssl/src/crypto/x509v3/v3_genn.c b/lib/libssl/src/crypto/x509v3/v3_genn.c index b6283573013..b47098e5a7e 100644 --- a/lib/libssl/src/crypto/x509v3/v3_genn.c +++ b/lib/libssl/src/crypto/x509v3/v3_genn.c @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -94,27 +94,28 @@ ASN1_CHOICE(GENERAL_NAME) = { IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAME) -ASN1_ITEM_TEMPLATE(GENERAL_NAMES) = - ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, GENERAL_NAME) +ASN1_ITEM_TEMPLATE(GENERAL_NAMES) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, GENERAL_NAME) ASN1_ITEM_TEMPLATE_END(GENERAL_NAMES) IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAMES) -GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a) - { - return (GENERAL_NAME *) ASN1_dup((i2d_of_void *) i2d_GENERAL_NAME, - (d2i_of_void *) d2i_GENERAL_NAME, - (char *) a); - } +GENERAL_NAME * +GENERAL_NAME_dup(GENERAL_NAME *a) +{ + return (GENERAL_NAME *)ASN1_dup((i2d_of_void *)i2d_GENERAL_NAME, + (d2i_of_void *)d2i_GENERAL_NAME, (char *)a); +} /* Returns 0 if they are equal, != 0 otherwise. */ -int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) - { +int +GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) +{ int result = -1; - if (!a || !b || a->type != b->type) return -1; - switch(a->type) - { + if (!a || !b || a->type != b->type) + return -1; + switch (a->type) { case GEN_X400: case GEN_EDIPARTY: result = ASN1_TYPE_cmp(a->d.other, b->d.other); @@ -137,32 +138,34 @@ int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) case GEN_IPADD: result = ASN1_OCTET_STRING_cmp(a->d.ip, b->d.ip); break; - + case GEN_RID: result = OBJ_cmp(a->d.rid, b->d.rid); break; - } - return result; } + return result; +} /* Returns 0 if they are equal, != 0 otherwise. */ -int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b) - { +int +OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b) +{ int result = -1; - if (!a || !b) return -1; + if (!a || !b) + return -1; /* Check their type first. */ if ((result = OBJ_cmp(a->type_id, b->type_id)) != 0) return result; /* Check the value. */ result = ASN1_TYPE_cmp(a->value, b->value); return result; - } +} -void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) - { - switch(type) - { +void +GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) +{ + switch (type) { case GEN_X400: case GEN_EDIPARTY: a->d.other = value; @@ -185,20 +188,20 @@ void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) case GEN_IPADD: a->d.ip = value; break; - + case GEN_RID: a->d.rid = value; break; - } - a->type = type; } + a->type = type; +} -void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) - { +void * +GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) +{ if (ptype) *ptype = a->type; - switch(a->type) - { + switch (a->type) { case GEN_X400: case GEN_EDIPARTY: return a->d.other; @@ -216,19 +219,21 @@ void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) case GEN_IPADD: return a->d.ip; - + case GEN_RID: return a->d.rid; default: return NULL; - } } +} -int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, - ASN1_OBJECT *oid, ASN1_TYPE *value) - { +int +GENERAL_NAME_set0_othername(GENERAL_NAME *gen, ASN1_OBJECT *oid, + ASN1_TYPE *value) +{ OTHERNAME *oth; + oth = OTHERNAME_new(); if (!oth) return 0; @@ -236,11 +241,12 @@ int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, oth->value = value; GENERAL_NAME_set0_value(gen, GEN_OTHERNAME, oth); return 1; - } +} -int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, - ASN1_OBJECT **poid, ASN1_TYPE **pvalue) - { +int +GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, ASN1_OBJECT **poid, + ASN1_TYPE **pvalue) +{ if (gen->type != GEN_OTHERNAME) return 0; if (poid) @@ -248,5 +254,4 @@ int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, if (pvalue) *pvalue = gen->d.otherName->value; return 1; - } - +} -- 2.20.1