From 513bec93d6747369737d3a618ef58a44410059f6 Mon Sep 17 00:00:00 2001 From: tedu <> Date: Fri, 18 Apr 2014 01:59:00 +0000 Subject: blunt force knf --- src/lib/libcrypto/x509/x509_cmp.c | 109 ++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 57 deletions(-) (limited to 'src/lib/libcrypto/x509/x509_cmp.c') diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c index 2f1b8953e5..87c4596414 100644 --- a/src/lib/libcrypto/x509/x509_cmp.c +++ b/src/lib/libcrypto/x509/x509_cmp.c @@ -65,7 +65,7 @@ #include int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b) - { +{ int i; X509_CINF *ai,*bi; @@ -74,11 +74,11 @@ int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b) i=M_ASN1_INTEGER_cmp(ai->serialNumber,bi->serialNumber); if (i) return(i); return(X509_NAME_cmp(ai->issuer,bi->issuer)); - } +} #ifndef OPENSSL_NO_MD5 unsigned long X509_issuer_and_serial_hash(X509 *a) - { +{ unsigned long ret=0; EVP_MD_CTX ctx; unsigned char md[16]; @@ -102,68 +102,68 @@ unsigned long X509_issuer_and_serial_hash(X509 *a) err: EVP_MD_CTX_cleanup(&ctx); return(ret); - } +} #endif int X509_issuer_name_cmp(const X509 *a, const X509 *b) - { +{ return(X509_NAME_cmp(a->cert_info->issuer,b->cert_info->issuer)); - } +} int X509_subject_name_cmp(const X509 *a, const X509 *b) - { +{ return(X509_NAME_cmp(a->cert_info->subject,b->cert_info->subject)); - } +} int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b) - { +{ return(X509_NAME_cmp(a->crl->issuer,b->crl->issuer)); - } +} #ifndef OPENSSL_NO_SHA int X509_CRL_match(const X509_CRL *a, const X509_CRL *b) - { +{ return memcmp(a->sha1_hash, b->sha1_hash, 20); - } +} #endif X509_NAME *X509_get_issuer_name(X509 *a) - { +{ return(a->cert_info->issuer); - } +} unsigned long X509_issuer_name_hash(X509 *x) - { +{ return(X509_NAME_hash(x->cert_info->issuer)); - } +} #ifndef OPENSSL_NO_MD5 unsigned long X509_issuer_name_hash_old(X509 *x) - { +{ return(X509_NAME_hash_old(x->cert_info->issuer)); - } +} #endif X509_NAME *X509_get_subject_name(X509 *a) - { +{ return(a->cert_info->subject); - } +} ASN1_INTEGER *X509_get_serialNumber(X509 *a) - { +{ return(a->cert_info->serialNumber); - } +} unsigned long X509_subject_name_hash(X509 *x) - { +{ return(X509_NAME_hash(x->cert_info->subject)); - } +} #ifndef OPENSSL_NO_MD5 unsigned long X509_subject_name_hash_old(X509 *x) - { +{ return(X509_NAME_hash_old(x->cert_info->subject)); - } +} #endif #ifndef OPENSSL_NO_SHA @@ -188,24 +188,22 @@ int X509_cmp(const X509 *a, const X509 *b) int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b) - { +{ int ret; /* Ensure canonical encoding is present and up to date */ - if (!a->canon_enc || a->modified) - { + if (!a->canon_enc || a->modified) { ret = i2d_X509_NAME((X509_NAME *)a, NULL); if (ret < 0) return -2; - } + } - if (!b->canon_enc || b->modified) - { + if (!b->canon_enc || b->modified) { ret = i2d_X509_NAME((X509_NAME *)b, NULL); if (ret < 0) return -2; - } + } ret = a->canon_enclen - b->canon_enclen; @@ -214,10 +212,10 @@ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b) return memcmp(a->canon_enc, b->canon_enc, a->canon_enclen); - } +} unsigned long X509_NAME_hash(X509_NAME *x) - { +{ unsigned long ret=0; unsigned char md[SHA_DIGEST_LENGTH]; @@ -231,7 +229,7 @@ unsigned long X509_NAME_hash(X509_NAME *x) ((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L) )&0xffffffffL; return(ret); - } +} #ifndef OPENSSL_NO_MD5 @@ -239,7 +237,7 @@ unsigned long X509_NAME_hash(X509_NAME *x) * this is reasonably efficient. */ unsigned long X509_NAME_hash_old(X509_NAME *x) - { +{ EVP_MD_CTX md_ctx; unsigned long ret=0; unsigned char md[16]; @@ -257,13 +255,13 @@ unsigned long X509_NAME_hash_old(X509_NAME *x) EVP_MD_CTX_cleanup(&md_ctx); return(ret); - } +} #endif /* Search a stack of X509 for a match */ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name, ASN1_INTEGER *serial) - { +{ int i; X509_CINF cinf; X509 x,*x509=NULL; @@ -274,44 +272,42 @@ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name, cinf.serialNumber=serial; cinf.issuer=name; - for (i=0; icert_info == NULL)) return(NULL); return(X509_PUBKEY_get(x->cert_info->key)); - } +} ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x) - { +{ if(!x) return NULL; return x->cert_info->key->public_key; - } +} int X509_check_private_key(X509 *x, EVP_PKEY *k) - { +{ EVP_PKEY *xk; int ret; @@ -322,8 +318,7 @@ int X509_check_private_key(X509 *x, EVP_PKEY *k) else ret = -2; - switch (ret) - { + switch (ret) { case 1: break; case 0: @@ -334,10 +329,10 @@ int X509_check_private_key(X509 *x, EVP_PKEY *k) break; case -2: X509err(X509_F_X509_CHECK_PRIVATE_KEY,X509_R_UNKNOWN_KEY_TYPE); - } + } if (xk) EVP_PKEY_free(xk); if (ret > 0) return 1; return 0; - } +} -- cgit v1.2.3-55-g6feb