Processes PKCS #7 SignedData content information.
Format
#include <gskcms.h>
gsk_status gsk_read_signed_data_content_extended (
gsk_process_option option_flag
pkcs_certificates * local_certificates,
pkcs_content_info * content_info,
gsk_boolean * used_local,
pkcs_certificates * msg_certificates,
pkcs_certificates * signer_certificates,
gsk_attributes_signers * attributes_signers,
pkcs_content_info * content_data)
Parameters
- option_flag
- Specifies process options to customize process behavior.
- Enforce signing certificate has digital signing capabilities.
That is, the purpose of the certificate key as reflected by the key
usage extension must indicate digitalSignature.
- Do not allow zero-length content data.
- local_certificates
- Specifies zero or more X.509 certificates to use when verifying
the message signatures. NULL can be specified for this parameter
if no local certificates are provided.
- content_info
- Specifies the content information to be processed.
- used_local
- This parameter will be set to TRUE if the signatures were verified
using just the certificates supplied by the local_certificates parameter.
This parameter will be set to FALSE if any of the signatures were
verified using certificates contained within the message.
- msg_certificates
- Returns the X.509 certificates contained within the message.
The application should call the gsk_free_certificates() routine
to release the certificates when they are no longer needed. Specify
NULL for this parameter if the message certificates are not needed.
- signer_certificates
- Returns the certificates used to sign the message. The application
should call the gsk_free_certificates() routine to release
the certificates when they are no longer needed. Specify NULL for
this parameter if the signer certificates are not needed.
- attributes_signers
- Returns the authenticated attributes per signer contained within
the message. The application should call the gsk_free_attributes_signers() routine
to release the gsk_attributes_signers structure when it is no longer
needed. Specify NULL for this parameter if the authenticated attributes
per signer are not needed. The set of authenticated attributes returned,
omits the content-type and message-digest authenticated attributes
as these authenticated attributes must always be present, if any authenticated
attributes are present, and are automatically verified by gsk_read_signed_data_content_extended().
The digestAlgorithm field within each gsk_attributes_signer structure
returns the digest algorithm originally used for the signer.
- content_data
- Returns the SignedData content data. The application should call
the gsk_free_content_info() routine to release the data when
it is no longer needed.
Results
The function return value will be
0 if no error is detected. Otherwise, it will be one of the return
codes listed in the gskcms.h include file. These are some
possible errors:
- [CMSERR_ALG_NOT_SUPPORTED]
- The digest algorithm is not supported.
- [CMSERR_BAD_SIGNATURE]
- Signature is not correct.
- [CMSERR_CONTENT_NOT_SUPPORTED]
- The content type is not SignedData.
- [CMSERR_DIGEST_KEY_MISMATCH]
- The digest algorithm is not supported for the private key type.
- [CMSERR_ECURVE_NOT_FIPS_APPROVED]
- Elliptic Curve not supported in FIPS mode.
- [CMSERR_ECURVE_NOT_SUPPORTED]
- Elliptic Curve is not supported.
- [CMSERR_ICSF_FIPS_DISABLED]
- ICSF PKCS #11 services are disabled.
- [CMSERR_ICSF_NOT_AVAILABLE]
- ICSF services are not available.
- [CMSERR_ICSF_NOT_FIPS]
- ICSF PKCS #11 not operating in FIPS mode.
- [CMSERR_ICSF_SERVICE_FAILURE]
- ICSF callable service returned an error.
- [CMSERR_INCORRECT_KEY_USAGE ]
- A signer certificate does not allow digital signature.
- [CMSERR_NO_CONTENT_DATA]
- The content data length is zero.
- [CMSERR_NO_MEMORY]
- Insufficient storage is available.
- [CMSERR_SIGNER_NOT_FOUND]
- Signer certificate not found.
Usage
The gsk_read_signed_data_content_extended() routine
processes PKCS #7 (Cryptographic Message Syntax) SignedData message
created by the gsk_make_signed_data_content_extended() routine
and returns the content data and authenticated attributes per signed
(if present).
Processing is equivalent to
gsk_read_signed_data_content(),
with these differences:
- The signing certificate key usage need not assert digital signing
capabilities depending on option_flag.
- Zero length content is acceptable depending on option_flag.
- Authenticated attributes and the digest algorithm used to create
the signed data per signer, if present, are returned.
The local_certificates parameter can supply the
signer certificates used to verify the message signatures. If a certificate
is not found for a message signer, the gsk_read_signed_data_content_extended() routine
attempts to locate the signer certificate in the SignedData message.
An error will be returned if the signer certificate cannot be found.
An error may optionally be returned if the certificate key usage
does not allow digital signature.
No certificate validation
is performed by the gsk_read_signed_data_content_extended() routine.
It is assumed that the application has already validated the local
certificates. The certificates contained in the SignedData message
will be returned in the msg_certificates parameter and the used_local parameter
will be set to FALSE if any of these certificates were used to verify
the message signatures. It is the responsibility of the application
to validate the message certificates (for example, by calling the gsk_validate_certificate() routine
for each of the signer certificates).
These digest algorithms
are supported:
- x509_alg_md2Digest
- MD2 digest (RSA keys only) - {1.2.840.113549.2.2}
- x509_alg_md5Digest
- MD5 digest (RSA keys only) - {1.2.840.113549.2.5}
- x509_alg_sha1Digest
- SHA-1 digest (RSA, DSA, and ECDSA keys only) - {1.3.14.3.2.26}
- x509_alg_sha224Digest
- SHA-224 digest (RSA DSA, and ECDSA keys only)
- {2.16.840.1.101.3.4.2.4}
- x509_alg_sha256Digest
- SHA-256 digest (RSA, DSA, and ECDSA keys only)
- {2.16.840.1.101.3.4.2.1}
- x509_alg_sha384Digest
- SHA-384 digest (RSA and ECDSA keys only) - {2.16.840.1.101.3.4.2.2}
- x509_alg_sha512Digest
- SHA-512 digest (RSA and ECDSA keys only) - {2.16.840.1.101.3.4.2.3}
If authenticated attributes are returned from
the attributes_signers parameter, then it is recommended that
signing certificates for all signers represented within the gsk_attributes_signers
structure should be requested from the signer_certificates parameter.
When
executing in FIPS mode, digest algorithms x509_alg_md2Digest and x509_alg_md5Digest
are not supported.