Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CMS Cryptography

The synta.cms submodule provides Python bindings for the Cryptographic Message Syntax (RFC 5652) and CMS-KEM (RFC 9629). It exposes parsers and builders for all major CMS content types.

Content types

ClassRFCDescription
ContentInfoRFC 5652 §3Outer CMS envelope; entry point for all content types
SignedDataRFC 5652 §5Encapsulates signed content plus signer information
SignerInfoRFC 5652 §5.3Per-signer structure within SignedData
EnvelopedDataRFC 5652 §6Encrypted content with key transport per recipient
EnvelopedDataBuilderRFC 5652 §6Fluent builder for EnvelopedData
EncryptedDataRFC 5652 §8Symmetric encryption (shared key, no recipient info)
DigestedDataRFC 5652 §7Hash-protected content
AuthenticatedDataRFC 5652 §9MAC-authenticated content
IssuerAndSerialNumberRFC 5652 §10.2.4Certificate identifier
KEMRecipientInfoRFC 9629 §5Quantum-safe KEM recipient structure
CMSORIforKEMOtherInfoRFC 9629 §5.3KDF input structure for KEM-based key derivation

Import

from synta.cms import (
    ContentInfo,
    SignedData, SignerInfo,
    EnvelopedData, EnvelopedDataBuilder,
    EncryptedData,
    DigestedData,
    AuthenticatedData,
    IssuerAndSerialNumber,
    KEMRecipientInfo, CMSORIforKEMOtherInfo,
    # OID constants:
    ID_DATA, ID_SIGNED_DATA, ID_ENVELOPED_DATA,
    ID_DIGESTED_DATA, ID_ENCRYPTED_DATA, ID_CT_AUTH_DATA,
    ID_AES128_CBC, ID_AES192_CBC, ID_AES256_CBC,
    ID_RSAES_OAEP, ID_RSA_ENCRYPTION,
    ID_ORI, ID_ORI_KEM,
)

OID constants

Content-type OIDs (RFC 5652 §14)

ConstantOIDName
ID_DATA1.2.840.113549.1.7.1id-data
ID_SIGNED_DATA1.2.840.113549.1.7.2id-signedData
ID_ENVELOPED_DATA1.2.840.113549.1.7.3id-envelopedData
ID_DIGESTED_DATA1.2.840.113549.1.7.5id-digestedData
ID_ENCRYPTED_DATA1.2.840.113549.1.7.6id-encryptedData
ID_CT_AUTH_DATA1.2.840.113549.1.9.16.1.2id-ct-authData

Content-encryption algorithm OIDs (RFC 3565)

ConstantOIDKey length
ID_AES128_CBC2.16.840.1.101.3.4.1.216 bytes
ID_AES192_CBC2.16.840.1.101.3.4.1.2224 bytes
ID_AES256_CBC2.16.840.1.101.3.4.1.4232 bytes

Key-transport algorithm OIDs (RFC 8017)

ConstantOIDNotes
ID_RSAES_OAEP1.2.840.113549.1.1.7RSA-OAEP with SHA-256 (recommended)
ID_RSA_ENCRYPTION1.2.840.113549.1.1.1RSA PKCS#1 v1.5 (legacy)

CMS-KEM OtherRecipientInfo OIDs (RFC 9629 §6.2)

ConstantOIDDescription
ID_ORI1.2.840.113549.1.9.16.13Root arc for OtherRecipientInfo alternatives
ID_ORI_KEM1.2.840.113549.1.9.16.13.3Identifies a KEMRecipientInfo

Sections