summaryrefslogtreecommitdiffstats
path: root/crypto/cms/cms_dd.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2015-01-22 03:40:55 +0000
committerMatt Caswell <matt@openssl.org>2015-01-22 09:20:09 +0000
commit0f113f3ee4d629ef9a4a30911b22b224772085e5 (patch)
treee014603da5aed1d0751f587a66d6e270b6bda3de /crypto/cms/cms_dd.c
parent22b52164aaed31d6e93dbd2d397ace041360e6aa (diff)
Run util/openssl-format-source -v -c .
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto/cms/cms_dd.c')
-rw-r--r--crypto/cms/cms_dd.c139
1 files changed, 68 insertions, 71 deletions
diff --git a/crypto/cms/cms_dd.c b/crypto/cms/cms_dd.c
index 93d6747ae8..d5fda1a5c3 100644
--- a/crypto/cms/cms_dd.c
+++ b/crypto/cms/cms_dd.c
@@ -1,5 +1,6 @@
/* crypto/cms/cms_dd.c */
-/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
+/*
+ * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project.
*/
/* ====================================================================
@@ -10,7 +11,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,85 +65,81 @@ DECLARE_ASN1_ITEM(CMS_DigestedData)
/* CMS DigestedData Utilities */
CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md)
- {
- CMS_ContentInfo *cms;
- CMS_DigestedData *dd;
- cms = CMS_ContentInfo_new();
- if (!cms)
- return NULL;
+{
+ CMS_ContentInfo *cms;
+ CMS_DigestedData *dd;
+ cms = CMS_ContentInfo_new();
+ if (!cms)
+ return NULL;
- dd = M_ASN1_new_of(CMS_DigestedData);
+ dd = M_ASN1_new_of(CMS_DigestedData);
- if (!dd)
- goto err;
+ if (!dd)
+ goto err;
- cms->contentType = OBJ_nid2obj(NID_pkcs7_digest);
- cms->d.digestedData = dd;
+ cms->contentType = OBJ_nid2obj(NID_pkcs7_digest);
+ cms->d.digestedData = dd;
- dd->version = 0;
- dd->encapContentInfo->eContentType = OBJ_nid2obj(NID_pkcs7_data);
+ dd->version = 0;
+ dd->encapContentInfo->eContentType = OBJ_nid2obj(NID_pkcs7_data);
- X509_ALGOR_set_md(dd->digestAlgorithm, md);
+ X509_ALGOR_set_md(dd->digestAlgorithm, md);
- return cms;
+ return cms;
- err:
+ err:
- if (cms)
- CMS_ContentInfo_free(cms);
+ if (cms)
+ CMS_ContentInfo_free(cms);
- return NULL;
- }
+ return NULL;
+}
BIO *cms_DigestedData_init_bio(CMS_ContentInfo *cms)
- {
- CMS_DigestedData *dd;
- dd = cms->d.digestedData;
- return cms_DigestAlgorithm_init_bio(dd->digestAlgorithm);
- }
+{
+ CMS_DigestedData *dd;
+ dd = cms->d.digestedData;
+ return cms_DigestAlgorithm_init_bio(dd->digestAlgorithm);
+}
int cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify)
- {
- EVP_MD_CTX mctx;
- unsigned char md[EVP_MAX_MD_SIZE];
- unsigned int mdlen;
- int r = 0;
- CMS_DigestedData *dd;
- EVP_MD_CTX_init(&mctx);
-
- dd = cms->d.digestedData;
-
- if (!cms_DigestAlgorithm_find_ctx(&mctx, chain, dd->digestAlgorithm))
- goto err;
-
- if (EVP_DigestFinal_ex(&mctx, md, &mdlen) <= 0)
- goto err;
-
- if (verify)
- {
- if (mdlen != (unsigned int)dd->digest->length)
- {
- CMSerr(CMS_F_CMS_DIGESTEDDATA_DO_FINAL,
- CMS_R_MESSAGEDIGEST_WRONG_LENGTH);
- goto err;
- }
-
- if (memcmp(md, dd->digest->data, mdlen))
- CMSerr(CMS_F_CMS_DIGESTEDDATA_DO_FINAL,
- CMS_R_VERIFICATION_FAILURE);
- else
- r = 1;
- }
- else
- {
- if (!ASN1_STRING_set(dd->digest, md, mdlen))
- goto err;
- r = 1;
- }
-
- err:
- EVP_MD_CTX_cleanup(&mctx);
-
- return r;
-
- }
+{
+ EVP_MD_CTX mctx;
+ unsigned char md[EVP_MAX_MD_SIZE];
+ unsigned int mdlen;
+ int r = 0;
+ CMS_DigestedData *dd;
+ EVP_MD_CTX_init(&mctx);
+
+ dd = cms->d.digestedData;
+
+ if (!cms_DigestAlgorithm_find_ctx(&mctx, chain, dd->digestAlgorithm))
+ goto err;
+
+ if (EVP_DigestFinal_ex(&mctx, md, &mdlen) <= 0)
+ goto err;
+
+ if (verify) {
+ if (mdlen != (unsigned int)dd->digest->length) {
+ CMSerr(CMS_F_CMS_DIGESTEDDATA_DO_FINAL,
+ CMS_R_MESSAGEDIGEST_WRONG_LENGTH);
+ goto err;
+ }
+
+ if (memcmp(md, dd->digest->data, mdlen))
+ CMSerr(CMS_F_CMS_DIGESTEDDATA_DO_FINAL,
+ CMS_R_VERIFICATION_FAILURE);
+ else
+ r = 1;
+ } else {
+ if (!ASN1_STRING_set(dd->digest, md, mdlen))
+ goto err;
+ r = 1;
+ }
+
+ err:
+ EVP_MD_CTX_cleanup(&mctx);
+
+ return r;
+
+}