ContentInfo
ContentInfo is the outer CMS envelope — every CMS structure is wrapped in a ContentInfo
SEQUENCE. It is the standard entry point for parsing any CMS payload.
Class
class ContentInfo:
@staticmethod
def from_der(data: bytes) -> ContentInfo: ...
# Parse a DER- or BER-encoded ContentInfo SEQUENCE.
def to_der(self) -> bytes: ...
content_type_oid: ObjectIdentifier
# e.g. ID_SIGNED_DATA, ID_ENVELOPED_DATA, ID_ENCRYPTED_DATA, …
content: bytes
# Raw bytes of the content field (including the [0] EXPLICIT tag for most types).
Usage
from synta.cms import ContentInfo, ID_SIGNED_DATA, ID_ENVELOPED_DATA, ID_ENCRYPTED_DATA
data = open("message.p7m", "rb").read()
ci = ContentInfo.from_der(data)
print(ci.content_type_oid) # e.g. ObjectIdentifier("1.2.840.113549.1.7.2")
if ci.content_type_oid == ID_SIGNED_DATA:
from synta.cms import SignedData
sd = SignedData.from_der(ci.content)
print(f"Signers: {len(sd.signer_infos)}")
elif ci.content_type_oid == ID_ENVELOPED_DATA:
from synta.cms import EnvelopedData
ed = EnvelopedData.from_der(ci.content)
# decrypt with ed.decrypt(private_key)
elif ci.content_type_oid == ID_ENCRYPTED_DATA:
from synta.cms import EncryptedData
enc = EncryptedData.from_der(ci.content)
# decrypt with enc.decrypt(key)
See also the CMS Overview for a summary of all content types.