diff --git a/include/mbedtls/pkcs7.h b/include/mbedtls/pkcs7.h index 7699b60d53..c56926fd53 100644 --- a/include/mbedtls/pkcs7.h +++ b/include/mbedtls/pkcs7.h @@ -22,23 +22,22 @@ */ /** - * Note: For the time being, this application of the PKCS7 cryptographic + * Note: For the time being, this implementation of the PKCS7 cryptographic * message syntax is a partial implementation of RFC 2315. * Differences include: * - The RFC specifies 6 different content types. The only type currently - * supported in MbedTLS is the signed data content type. + * supported in Mbed TLS is the signed data content type. * - The only supported PKCS7 Signed Data syntax version is version 1 - * - The RFC specifies support for BER. This application is limited to + * - The RFC specifies support for BER. This implementation is limited to * DER only. * - The RFC specifies that multiple digest algorithms can be specified - * in the Signed Data type. Only one digest algorithm is supported in MbedTLS. - * - The RFC specifies the Signed Data certificate format can be - * X509 or PKCS6. The only type currently supported in MbedTLS is X509. + * in the Signed Data type. Only one digest algorithm is supported in Mbed TLS. + * - The RFC specifies the Signed Data type can contain multiple X509 or PKCS6 + * certificates. In Mbed TLS, this list can only contain 0 or 1 certificates + * and they must be in X509 format. * - The RFC specifies the Signed Data type can contain - * certificate-revocation lists (crls). This application has no support + * certificate-revocation lists (crls). This implementation has no support * for crls so it is assumed to be an empty list. - * - The RFC specifies support for multiple signers. This application only - * supports the Signed Data type with a single signer. */ #ifndef MBEDTLS_PKCS7_H diff --git a/library/pkcs7.c b/library/pkcs7.c index 9dcbab26c4..5ec10891ca 100644 --- a/library/pkcs7.c +++ b/library/pkcs7.c @@ -58,8 +58,7 @@ */ void mbedtls_pkcs7_init( mbedtls_pkcs7 *pkcs7 ) { - memset( pkcs7, 0, sizeof( mbedtls_pkcs7 ) ); - pkcs7->raw.p = NULL; + memset( pkcs7, 0, sizeof( *pkcs7 ) ); } static int pkcs7_get_next_content_len( unsigned char **p, unsigned char *end, @@ -229,7 +228,7 @@ static int pkcs7_get_certificates( unsigned char **p, unsigned char *end, * So, we support only the root certificate and the single signer. * The behaviour would be improved with addition of multiple signer support. */ - if (end_cert != end_set) + if ( end_cert != end_set ) { ret = MBEDTLS_ERR_PKCS7_FEATURE_UNAVAILABLE; goto out; @@ -702,7 +701,8 @@ out: int mbedtls_pkcs7_signed_hash_verify( mbedtls_pkcs7 *pkcs7, const mbedtls_x509_crt *cert, - const unsigned char *hash, size_t hashlen) + const unsigned char *hash, + size_t hashlen ) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; const mbedtls_md_info_t *md_info; @@ -750,7 +750,7 @@ int mbedtls_pkcs7_signed_hash_verify( mbedtls_pkcs7 *pkcs7, } out: - return ( ret ); + return( ret ); } /* diff --git a/tests/suites/test_suite_pkcs7.function b/tests/suites/test_suite_pkcs7.function index 8db3f3f53d..c5094bcca8 100644 --- a/tests/suites/test_suite_pkcs7.function +++ b/tests/suites/test_suite_pkcs7.function @@ -76,15 +76,15 @@ void pkcs7_verify( char *pkcs7_file, char *crt, char *filetobesigned, int do_has datalen = st.st_size; data = mbedtls_calloc( datalen, 1 ); - TEST_ASSERT( data != NULL); + TEST_ASSERT( data != NULL ); buflen = fread( (void *)data , sizeof( unsigned char ), datalen, file ); - TEST_ASSERT( buflen == datalen); + TEST_ASSERT( buflen == datalen ); fclose( file ); if( do_hash_alg ) { - res = mbedtls_oid_get_md_alg( &(pkcs7.signed_data.digest_alg_identifiers), &md_alg ); + res = mbedtls_oid_get_md_alg( &pkcs7.signed_data.digest_alg_identifiers, &md_alg ); TEST_ASSERT( res == 0 ); TEST_ASSERT( md_alg == (mbedtls_md_type_t) do_hash_alg ); md_info = mbedtls_md_info_from_type( md_alg ); @@ -162,7 +162,7 @@ void pkcs7_verify_multiple_signers( char *pkcs7_file, char *crt1, char *crt2, ch if( do_hash_alg ) { - res = mbedtls_oid_get_md_alg( &(pkcs7.signed_data.digest_alg_identifiers), &md_alg ); + res = mbedtls_oid_get_md_alg( &pkcs7.signed_data.digest_alg_identifiers, &md_alg ); TEST_ASSERT( res == 0 ); TEST_ASSERT( md_alg == MBEDTLS_MD_SHA256 ); @@ -171,7 +171,7 @@ void pkcs7_verify_multiple_signers( char *pkcs7_file, char *crt1, char *crt2, ch res = mbedtls_md( md_info, data, datalen, hash ); TEST_ASSERT( res == 0 ); - res = mbedtls_pkcs7_signed_hash_verify( &pkcs7, &x509_1, hash, sizeof(hash)); + res = mbedtls_pkcs7_signed_hash_verify( &pkcs7, &x509_1, hash, sizeof(hash) ); TEST_ASSERT( res == res_expect ); } else