![]() |
TrustCore SDK NanoCrypto API reference
version 7.0
|
__ENABLE_MOCANA_CMS__
and __ENABLE_MOCANA_PKCS7__
flags are defined in moptions.h.Using ContentInfo
objects in PKCS #7 messages, the participants in a conversation can exchange simple data objects, signed data objects, enveloped data objects, and so on. This file's API lets you create, parse, and otherwise manage these ContentInfo
objects.
OCTET
STRING objects.ContentInfo
object as: ContentInfo ::= SEQUENCE { contentType ContentType, content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
ContentType ::= OBJECT IDENTIFIER
The ContentType
OBJECT_IDENTIFIER
is defined in Section 14 of RFC 2315 as:
data OBJECT IDENTIFIER ::= { pkcs-7 1 } signedData OBJECT IDENTIFIER ::= { pkcs-7 2 } envelopedData OBJECT IDENTIFIER ::= { pkcs-7 3 } signedAndEnvelopedData OBJECT IDENTIFIER ::= { pkcs-7 4 } digestedData OBJECT IDENTIFIER ::= { pkcs-7 5 } encryptedData OBJECT IDENTIFIER ::= { pkcs-7 6 }EnvelopedData Ojbect
EnvelopedData
object as follows: EnvelopedData ::= SEQUENCE { version Version, recipientInfos RecipientInfos, encryptedContentInfo EncryptedContentInfo }
RecipientInfos ::= SET OF RecipientInfo
EncryptedContentInfo ::= SEQUENCE { contentType ContentType, contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier, encryptedContent[0] IMPLICIT EncryptedContent OPTIONAL }
EncryptedContent ::= OCTET STRING
RecipientInfo ::= SEQUENCE { version Version, issuerAndSerialNumber IssuerAndSerialNumber, keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, encryptedKey EncryptedKey }
EncryptedKey ::= OCTET STRING
To populate a ContentType
object with an EnvelopedData
object, use code similar to the following:
SignedData
object as follows: SignedData ::= SEQUENCE { version Version, digestAlgorithms DigestAlgorithmIdentifiers, contentInfo ContentInfo, certificates [0] IMPLICIT ExtendedCertificatesAndCertificates OPTIONAL, crls [1] IMPLICIT CertificateRevocationLists OPTIONAL, signerInfos SignerInfos }
DigestAlgorithmIdentifiers ::=
SET OF DigestAlgorithmIdentifier
SignerInfos ::= SET OF SignerInfo
SignerInfo ::= SEQUENCE { version Version, issuerAndSerialNumber IssuerAndSerialNumber, digestAlgorithm DigestAlgorithmIdentifier, authenticatedAttributes [0] IMPLICIT Attributes OPTIONAL, digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier, encryptedDigest EncryptedDigest, unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL }
EncryptedDigest ::= OCTET STRING
To populate a ContentType
object with a SignedData
object, use code similar to the following:
DigestedData
object as follows: DigestedData ::= SEQUENCE { version Version, digestAlgorithm DigestAlgorithmIdentifier, contentInfo ContentInfo, digest Digest }
Digest ::= OCTET STRING
ContentInfo ::= SEQUENCE { contentType ContentType, content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
To populate a ContentType
object with a DigestedData
object, use code similar to the following:
SignerInfo
object as follows: SignerInfo ::= SEQUENCE { version Version, issuerAndSerialNumber IssuerAndSerialNumber, digestAlgorithm DigestAlgorithmIdentifier, authenticatedAttributes [0] IMPLICIT Attributes OPTIONAL, digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier, encryptedDigest EncryptedDigest, unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL }
EncryptedDigest ::= OCTET STRING
Attribute
, a structure that stores attribute information for a SignedData
object.signerInfo
, a structure that stores information for a SignedData
object.signerInfoPtr
, a pointer to a signerInfo
structure.PKCS7_Callbacks
, stores the PKCS #7 callbacks required by the SoT Platform PKCS #12 convenience API.CStream
contains a memory-resident DER-encoded ASN.1 object, which is an inconvenient object from which to extract data or to which to add data. However, you can call ASN1_Parse() for a CStream to parse the CStream and create a tree of ASN1_ITEM structures that maps out the content of the CStream. ASN1_Parse() also provides a pointer to the address of the root ASN1_ITEM structure in this tree.CStream
.To set up a CStream
and parse it, use code modeled on the following:
CStream
for a SignedData
object. However, this code is not specific to any given object type. Depending on the content of the file that is read, the code could create a CStream
containing an enveloped data object (EnvelopedData
), a signed and enveloped data object (SignedObject
), a digested data object, or an encrypted data object. Therefore, you must change the code snippet's variable names to accurately indicate their content.