Skip to content

Pkcs7 add support for internal certificates #7160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/mbedtls/oid.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@
#define MBEDTLS_OID_PKCS7_SIGNED_AND_ENVELOPED_DATA MBEDTLS_OID_PKCS7 "\x04" /**< Content type is Signed and Enveloped Data OBJECT IDENTIFIER ::= {pkcs-7 4} */
#define MBEDTLS_OID_PKCS7_DIGESTED_DATA MBEDTLS_OID_PKCS7 "\x05" /**< Content type is Digested Data OBJECT IDENTIFIER ::= {pkcs-7 5} */
#define MBEDTLS_OID_PKCS7_ENCRYPTED_DATA MBEDTLS_OID_PKCS7 "\x06" /**< Content type is Encrypted Data OBJECT IDENTIFIER ::= {pkcs-7 6} */
#define MBEDTLS_OID_PKCS9_MESSAGE_DIGEST MBEDTLS_OID_PKCS9 "\x04" /**< id-messageDigest OCTET STRING ::= {pkcs-9 4} */

/*
* PKCS#8 OIDs
Expand Down
14 changes: 10 additions & 4 deletions include/mbedtls/pkcs7.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ typedef struct mbedtls_pkcs7_signer_info {
mbedtls_x509_name MBEDTLS_PRIVATE(issuer);
mbedtls_x509_buf MBEDTLS_PRIVATE(issuer_raw);
mbedtls_x509_buf MBEDTLS_PRIVATE(alg_identifier);
mbedtls_asn1_named_data MBEDTLS_PRIVATE(signed_attrs);
mbedtls_x509_buf MBEDTLS_PRIVATE(signed_attrs_raw);
mbedtls_x509_buf MBEDTLS_PRIVATE(sig_alg_identifier);
mbedtls_x509_buf MBEDTLS_PRIVATE(sig);
struct mbedtls_pkcs7_signer_info *MBEDTLS_PRIVATE(next);
Expand Down Expand Up @@ -207,7 +209,9 @@ int mbedtls_pkcs7_parse_der(mbedtls_pkcs7 *pkcs7, const unsigned char *buf,
* PKCS7 structure itself.
*
* \param pkcs7 PKCS7 structure containing signature.
* \param cert Certificate containing key to verify signature.
* \param cert Trusted certificates either containing keys to verify the
* signature or to verify an embedded certificate containing
* the key.
* \param data Plain data on which signature has to be verified.
* \param datalen Length of the data.
*
Expand All @@ -217,7 +221,7 @@ int mbedtls_pkcs7_parse_der(mbedtls_pkcs7 *pkcs7, const unsigned char *buf,
* \return 0 if the signature verifies, or a negative error code on failure.
*/
int mbedtls_pkcs7_signed_data_verify(mbedtls_pkcs7 *pkcs7,
const mbedtls_x509_crt *cert,
mbedtls_x509_crt *cert,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the prototype stricter than the original const one, let alone incompatibilities, now it requires a mutable variable and implies potential writes and changes, therefore compiler will behave more conservatively, not good.

const unsigned char *data,
size_t datalen);

Expand All @@ -236,7 +240,9 @@ int mbedtls_pkcs7_signed_data_verify(mbedtls_pkcs7 *pkcs7,
* PKCS7 structure itself.
*
* \param pkcs7 PKCS7 structure containing signature.
* \param cert Certificate containing key to verify signature.
* \param cert Trusted certificates either containing keys to verify the
* signature or to verify an embedded certificate containing
* the key.
* \param hash Hash of the plain data on which signature has to be verified.
* \param hashlen Length of the hash.
*
Expand All @@ -246,7 +252,7 @@ int mbedtls_pkcs7_signed_data_verify(mbedtls_pkcs7 *pkcs7,
* \return 0 if the signature verifies, or a negative error code on failure.
*/
int mbedtls_pkcs7_signed_hash_verify(mbedtls_pkcs7 *pkcs7,
const mbedtls_x509_crt *cert,
mbedtls_x509_crt *cert,
const unsigned char *hash, size_t hashlen);

/**
Expand Down
Loading