synta 0.1.1

ASN.1 parser, decoder, and encoder library with DER/BER support and C FFI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
"""
synta.cms — CMS (RFC 5652) and CMS-KEM (RFC 9629) types.

This module is implemented in Rust (``synta-certificate`` / ``synta-python``) and
registered as a submodule of the ``synta._synta`` extension during ``import synta``.
It is available immediately after::

    import synta

Provides:

* :class:`ContentInfo` — the top-level CMS envelope (:rfc:`5652` §3).

* :class:`SignedData` — the ``SignedData`` content type (:rfc:`5652` §5).

* :class:`SignerInfo` — per-signer information inside a ``SignedData``
  (:rfc:`5652` §5.3).

* :class:`EnvelopedData` — the ``EnvelopedData`` content type (:rfc:`5652` §6).

* :class:`EncryptedData` — the ``EncryptedData`` content type (:rfc:`5652` §8).

* :class:`DigestedData` — the ``DigestedData`` content type (:rfc:`5652` §7).

* :class:`AuthenticatedData` — the ``AuthenticatedData`` content type
  (:rfc:`5652` §9).

* :class:`IssuerAndSerialNumber` — identifies a recipient or signer by
  the issuer DN and serial number of their certificate (:rfc:`5652` §10.2.4).

* :class:`KEMRecipientInfo` — a KEM-based recipient information structure
  (``OtherRecipientInfo`` alternative identified by :data:`ID_ORI_KEM`),
  as defined in :rfc:`9629` §6.2.

* :class:`CMSORIforKEMOtherInfo` — the ``otherInfo`` input to the KDF when
  deriving a KEK from a KEM shared secret, as defined in :rfc:`9629` §6.2.

* Content-type OID constants: :data:`ID_DATA`, :data:`ID_SIGNED_DATA`,
  :data:`ID_ENVELOPED_DATA`, :data:`ID_DIGESTED_DATA`,
  :data:`ID_ENCRYPTED_DATA`, :data:`ID_CT_AUTH_DATA`.

* OtherRecipientInfo OID constants: :data:`ID_ORI`, :data:`ID_ORI_KEM`.

* Content-encryption algorithm OID constants: :data:`ID_AES128_CBC`,
  :data:`ID_AES192_CBC`, :data:`ID_AES256_CBC` — pass these to
  :meth:`EncryptedData.create` as the ``algorithm_oid`` argument.

Usage::

    import synta.cms

    # Parse a CMS ContentInfo envelope (DER or BER)
    ci = synta.cms.ContentInfo.from_der(raw_bytes)
    if ci.content_type_oid == synta.cms.ID_SIGNED_DATA:
        # content holds the raw [0] EXPLICIT TLV; strip the context tag+len
        # (typically 4 bytes for short messages) to get the SignedData SEQUENCE.
        sd = synta.cms.SignedData.from_der(ci.content[4:])
        for si in sd.signer_infos:
            print(si.digest_algorithm_oid)
            print(si.signature_algorithm_oid)

    # Decode an IssuerAndSerialNumber (e.g. from a RecipientIdentifier CHOICE)
    ias = synta.cms.IssuerAndSerialNumber.from_der(rid_der)
    print(ias.issuer)           # "CN=My CA,O=Example,C=US"
    print(ias.serial_number)    # 12345678

    # Parse a raw KEMRecipientInfo SEQUENCE (e.g. from a CMS EnvelopedData)
    kemri = synta.cms.KEMRecipientInfo.from_der(raw_bytes)

    # Inspect the encapsulated key material
    kem_oid    = kemri.kem_algorithm_oid   # ObjectIdentifier
    ciphertext = kemri.kem_ciphertext      # bytes — the KEM ct field
    enc_key    = kemri.encrypted_key       # bytes — wrapped CEK
    kek_len    = kemri.kek_length          # int   — KEK size in bytes
    kdf_oid    = kemri.kdf_algorithm_oid   # ObjectIdentifier
    wrap_oid   = kemri.key_encryption_algorithm_oid

    # Recipient identifier (issuerAndSerialNumber or subjectKeyIdentifier)
    rid_der    = kemri.recipient_id        # bytes — raw DER of the CHOICE

    # Optional user keying material
    if kemri.ukm is not None:
        ukm_bytes = kemri.ukm

    # Build the KDF otherInfo structure
    other_info = synta.cms.CMSORIforKEMOtherInfo.from_der(other_info_der)
    print(other_info.kek_length)                      # e.g. 32
    print(other_info.key_encryption_algorithm_oid)    # e.g. id-aes256-Wrap

.. class:: ContentInfo

   CMS ContentInfo (RFC 5652 §3).

   The outermost CMS envelope.  Names the content type via an OID and carries
   the content (e.g. a ``SignedData`` SEQUENCE) as raw DER bytes.

   Both DER and BER input are accepted; BER indefinite-length encodings
   (common in PKCS#7 files from older tools) are handled transparently.

   .. method:: from_der(data: bytes) -> ContentInfo
      :classmethod:

      Parse a DER- or BER-encoded ``ContentInfo`` SEQUENCE.  Raises
      :exc:`ValueError` if the outer SEQUENCE envelope is malformed.

   .. method:: to_der() -> bytes

      Return the original bytes passed to :meth:`from_der`.

   .. attribute:: content_type_oid
      :type: synta.ObjectIdentifier

      OID identifying the content type.  Compare against :data:`ID_SIGNED_DATA`,
      :data:`ID_ENVELOPED_DATA`, :data:`ID_ENCRYPTED_DATA`, or :data:`ID_DATA`.

   .. attribute:: content
      :type: bytes

      Raw DER bytes of the ``content`` field.  This is the entire
      ``[0] EXPLICIT`` TLV.  Strip the context tag and length with a
      :class:`~synta.Decoder` to obtain the inner content (e.g. the
      ``SignedData`` SEQUENCE).

.. class:: SignedData

   CMS SignedData (RFC 5652 §5).

   Obtained by parsing the inner content of a :class:`ContentInfo` whose
   ``content_type_oid`` equals :data:`ID_SIGNED_DATA`.

   .. method:: from_der(data: bytes) -> SignedData
      :classmethod:

      Parse a DER- or BER-encoded ``SignedData`` SEQUENCE.  Raises
      :exc:`ValueError` if the outer SEQUENCE envelope is malformed.

   .. method:: to_der() -> bytes

      Return the original bytes passed to :meth:`from_der`.

   .. attribute:: version
      :type: int

      CMS version integer.

   .. attribute:: encap_content_type
      :type: synta.ObjectIdentifier

      OID identifying the encapsulated content type.

   .. attribute:: encap_content
      :type: bytes | None

      Raw bytes of the encapsulated content OCTET STRING value, or ``None``
      if the field is absent.

   .. attribute:: certificates
      :type: bytes | None

      Raw **content** bytes of the ``certificates`` field (``[0] IMPLICIT``),
      or ``None`` if absent.  These are the value bytes without the context-tag
      prefix (IMPLICIT decoding strips the outer tag).

   .. attribute:: crls
      :type: bytes | None

      Raw content bytes of the ``crls`` field (``[1] IMPLICIT``), or ``None``.

   .. attribute:: signer_infos
      :type: list[SignerInfo]

      List of :class:`SignerInfo` objects, one per signer.

.. class:: SignerInfo

   CMS SignerInfo (RFC 5652 §5.3).

   Represents one signer's information within a :class:`SignedData`.
   Instances are normally retrieved via :attr:`SignedData.signer_infos`.

   .. method:: from_der(data: bytes) -> SignerInfo
      :classmethod:

      Parse a DER-encoded ``SignerInfo`` SEQUENCE.  Raises
      :exc:`ValueError` if the outer SEQUENCE envelope is malformed.

   .. method:: to_der() -> bytes

      Return the original bytes passed to :meth:`from_der`.

   .. attribute:: version
      :type: int

      CMS version integer.

   .. attribute:: sid
      :type: bytes

      Raw TLV bytes of the ``SignerIdentifier`` CHOICE field.  Peek the first
      byte to distinguish ``issuerAndSerialNumber`` (``0x30``) from
      ``subjectKeyIdentifier`` (``0x80``).

   .. attribute:: digest_algorithm_oid
      :type: synta.ObjectIdentifier

      OID of the message-digest algorithm.

   .. attribute:: digest_algorithm_params
      :type: bytes | None

      Raw DER bytes of the digest-algorithm parameters, or ``None``.

   .. attribute:: signature_algorithm_oid
      :type: synta.ObjectIdentifier

      OID of the signature algorithm.

   .. attribute:: signature_algorithm_params
      :type: bytes | None

      Raw DER bytes of the signature-algorithm parameters, or ``None``.

   .. attribute:: signature
      :type: bytes

      Raw bytes of the signature value (OCTET STRING content).

   .. attribute:: signed_attrs
      :type: bytes | None

      Raw content bytes of the ``signedAttrs`` field (``[0] IMPLICIT``), or
      ``None`` if absent.  To verify the signature, replace the leading byte
      with ``0x31`` (SET tag) before hashing.

   .. attribute:: unsigned_attrs
      :type: bytes | None

      Raw content bytes of the ``unsignedAttrs`` field (``[1] IMPLICIT``),
      or ``None`` if absent.

.. class:: EnvelopedData

   CMS EnvelopedData (RFC 5652 §6).

   Obtained by parsing the inner content of a :class:`ContentInfo` whose
   ``content_type_oid`` equals :data:`ID_ENVELOPED_DATA`.

   .. method:: from_der(data: bytes) -> EnvelopedData
      :classmethod:

      Parse a DER- or BER-encoded ``EnvelopedData`` SEQUENCE.  Raises
      :exc:`ValueError` if the outer SEQUENCE envelope is malformed.

   .. method:: to_der() -> bytes

      Return the original bytes passed to :meth:`from_der`.

   .. attribute:: version
      :type: int

      CMS version integer.

   .. attribute:: originator_info
      :type: bytes | None

      DER-encoded ``OriginatorInfo`` SEQUENCE (re-encoded from the
      ``[0] IMPLICIT`` field), or ``None`` if absent.

   .. attribute:: recipient_infos
      :type: bytes

      Raw TLV bytes of the ``RecipientInfos`` SET field.

   .. attribute:: content_type
      :type: synta.ObjectIdentifier

      OID identifying the encrypted content type.

   .. attribute:: content_encryption_algorithm_oid
      :type: synta.ObjectIdentifier

      OID of the content-encryption algorithm.

   .. attribute:: content_encryption_algorithm_params
      :type: bytes | None

      Raw DER bytes of the content-encryption algorithm parameters, or ``None``.

   .. attribute:: encrypted_content
      :type: bytes | None

      Raw bytes of the encrypted content OCTET STRING value (``[0] IMPLICIT``),
      or ``None`` if absent.

   .. attribute:: unprotected_attrs
      :type: bytes | None

      Raw content bytes of the ``unprotectedAttrs`` field (``[1] IMPLICIT``),
      or ``None`` if absent.

.. class:: EncryptedData

   CMS EncryptedData (RFC 5652 §8).

   Obtained by parsing the inner content of a :class:`ContentInfo` whose
   ``content_type_oid`` equals :data:`ID_ENCRYPTED_DATA`.

   .. method:: from_der(data: bytes) -> EncryptedData
      :classmethod:

      Parse a DER- or BER-encoded ``EncryptedData`` SEQUENCE.  Raises
      :exc:`ValueError` if the outer SEQUENCE envelope is malformed.

   .. method:: to_der() -> bytes

      Return the original bytes passed to :meth:`from_der`.

   .. attribute:: version
      :type: int

      CMS version integer.

   .. attribute:: content_type
      :type: synta.ObjectIdentifier

      OID identifying the encrypted content type.

   .. attribute:: content_encryption_algorithm_oid
      :type: synta.ObjectIdentifier

      OID of the content-encryption algorithm.

   .. attribute:: content_encryption_algorithm_params
      :type: bytes | None

      Raw DER bytes of the content-encryption algorithm parameters, or ``None``.

   .. attribute:: encrypted_content
      :type: bytes | None

      Raw bytes of the encrypted content OCTET STRING value (``[0] IMPLICIT``),
      or ``None`` if absent.

   .. attribute:: unprotected_attrs
      :type: bytes | None

      Raw content bytes of the ``unprotectedAttrs`` field (``[1] IMPLICIT``),
      or ``None`` if absent.

   .. method:: create(plaintext, key, algorithm_oid, content_type_oid=None) -> EncryptedData
      :classmethod:

      Encrypt ``plaintext`` under ``key`` and return a new
      :class:`EncryptedData` object.

      - ``algorithm_oid``: dotted-decimal string or
        :class:`~synta.ObjectIdentifier` for the content-encryption algorithm
        (e.g. ``"2.16.840.1.101.3.4.1.2"`` for AES-128-CBC).
      - ``content_type_oid``: optional content-type OID (default:
        ``id-data`` = ``"1.2.840.113549.1.7.1"``).

      A fresh random IV is generated on every call.  Raises
      :exc:`ValueError` on algorithm or key-length errors.
      Raises :exc:`NotImplementedError` when built without the ``openssl``
      Cargo feature.

   .. method:: decrypt(key: bytes) -> bytes

      Decrypt the encrypted content using a raw symmetric key.

      ``key`` must be the raw symmetric key bytes matching the
      content-encryption algorithm (e.g. 16 bytes for AES-128-CBC,
      32 bytes for AES-256-CBC).

      Raises :exc:`ValueError` if the algorithm is unsupported, the key
      length is wrong, decryption fails, or ``encryptedContent`` is absent.
      Raises :exc:`NotImplementedError` when the library was built without
      the ``openssl`` Cargo feature.

.. class:: DigestedData

   CMS DigestedData (RFC 5652 §7).

   Obtained by parsing the inner content of a :class:`ContentInfo` whose
   ``content_type_oid`` is the ``id-digestedData`` OID.

   .. method:: from_der(data: bytes) -> DigestedData
      :classmethod:

      Parse a DER- or BER-encoded ``DigestedData`` SEQUENCE.  Raises
      :exc:`ValueError` if the outer SEQUENCE envelope is malformed.

   .. method:: to_der() -> bytes

      Return the original bytes passed to :meth:`from_der`.

   .. attribute:: version
      :type: int

      CMS version integer.

   .. attribute:: digest_algorithm_oid
      :type: synta.ObjectIdentifier

      OID of the digest algorithm.

   .. attribute:: digest_algorithm_params
      :type: bytes | None

      Raw DER bytes of the digest-algorithm parameters, or ``None``.

   .. attribute:: encap_content_type
      :type: synta.ObjectIdentifier

      OID identifying the encapsulated content type.

   .. attribute:: encap_content
      :type: bytes | None

      Raw bytes of the encapsulated content OCTET STRING value, or ``None``.

   .. attribute:: digest
      :type: bytes

      Raw bytes of the message digest (OCTET STRING content).

.. class:: AuthenticatedData

   CMS AuthenticatedData (RFC 5652 §9).

   Obtained by parsing the inner content of a :class:`ContentInfo` whose
   ``content_type_oid`` is the ``id-ct-authData`` OID.

   .. method:: from_der(data: bytes) -> AuthenticatedData
      :classmethod:

      Parse a DER- or BER-encoded ``AuthenticatedData`` SEQUENCE.  Raises
      :exc:`ValueError` if the outer SEQUENCE envelope is malformed.

   .. method:: to_der() -> bytes

      Return the original bytes passed to :meth:`from_der`.

   .. attribute:: version
      :type: int

      CMS version integer.

   .. attribute:: originator_info
      :type: bytes | None

      DER-encoded ``OriginatorInfo`` SEQUENCE (re-encoded from the
      ``[0] IMPLICIT`` field), or ``None`` if absent.

   .. attribute:: recipient_infos
      :type: bytes

      Raw TLV bytes of the ``RecipientInfos`` SET field.

   .. attribute:: mac_algorithm_oid
      :type: synta.ObjectIdentifier

      OID of the MAC algorithm.

   .. attribute:: mac_algorithm_params
      :type: bytes | None

      Raw DER bytes of the MAC algorithm parameters, or ``None``.

   .. attribute:: digest_algorithm_oid
      :type: synta.ObjectIdentifier | None

      OID of the digest algorithm (``[1] IMPLICIT`` OPTIONAL), or ``None``
      if absent.

   .. attribute:: digest_algorithm_params
      :type: bytes | None

      Raw DER bytes of the digest-algorithm parameters, or ``None``.

   .. attribute:: encap_content_type
      :type: synta.ObjectIdentifier

      OID identifying the encapsulated content type.

   .. attribute:: encap_content
      :type: bytes | None

      Raw bytes of the encapsulated content OCTET STRING value, or ``None``.

   .. attribute:: mac
      :type: bytes

      Raw bytes of the MAC value (OCTET STRING content).

   .. attribute:: auth_attrs
      :type: bytes | None

      Raw content bytes of the ``authAttrs`` field (``[2] IMPLICIT``), or
      ``None`` if absent.  Replace the leading byte with ``0x31`` (SET tag)
      before feeding to the MAC function.

   .. attribute:: unauth_attrs
      :type: bytes | None

      Raw content bytes of the ``unauthAttrs`` field (``[3] IMPLICIT``),
      or ``None`` if absent.

.. class:: IssuerAndSerialNumber

   CMS IssuerAndSerialNumber (RFC 5652 §10.2.4).

   Identifies a recipient or signer by the issuer distinguished name and
   certificate serial number of their certificate.  Used as one alternative
   of the ``RecipientIdentifier`` CHOICE inside :class:`KEMRecipientInfo`.

   .. method:: from_der(data: bytes) -> IssuerAndSerialNumber
      :classmethod:

      Parse a DER-encoded ``IssuerAndSerialNumber`` SEQUENCE.  Raises
      :exc:`ValueError` if the outer SEQUENCE envelope is malformed.

   .. method:: to_der() -> bytes

      Return the original bytes passed to :meth:`from_der`.

   .. attribute:: issuer
      :type: str

      Issuer distinguished name formatted as an RFC 4514 string,
      e.g. ``"CN=My CA,O=Example,C=US"``.

   .. attribute:: issuer_raw_der
      :type: bytes

      Raw DER bytes of the issuer ``Name`` SEQUENCE.

   .. attribute:: serial_number
      :type: int

      Certificate serial number.  Returns a Python ``int`` for serials that
      fit in 128 bits; calls ``int.from_bytes(raw, "big", signed=True)`` for
      larger values.

.. class:: KEMRecipientInfo

   KEM Recipient Info (RFC 9629 §6.2).

   ``KEMRecipientInfo`` carries a quantum-safe KEM-encapsulated content-encryption
   key inside a CMS ``EnvelopedData`` structure.  It is stored as an
   ``OtherRecipientInfo`` alternative identified by :data:`ID_ORI_KEM`.

   All fields are decoded lazily on first access; only the outer SEQUENCE
   envelope is validated during :meth:`from_der`.

   .. method:: from_der(data: bytes) -> KEMRecipientInfo
      :classmethod:

      Parse a DER-encoded ``KEMRecipientInfo`` SEQUENCE.  Raises
      :exc:`ValueError` if the outer SEQUENCE envelope is malformed.

   .. method:: to_der() -> bytes

      Return the original DER bytes passed to :meth:`from_der`.

   .. attribute:: version
      :type: int

      CMS version number.  Always ``0`` for ``KEMRecipientInfo`` per RFC 9629.

   .. attribute:: recipient_id
      :type: bytes

      Raw DER bytes of the ``RecipientIdentifier`` CHOICE.  Decode with
      :class:`synta.Decoder` to distinguish ``issuerAndSerialNumber``
      (SEQUENCE tag ``0x30``) from ``subjectKeyIdentifier``
      (context-specific tag ``[0]``).

   .. attribute:: kem_algorithm_oid
      :type: synta.ObjectIdentifier

      OID of the KEM algorithm (the ``kem`` field).  For ML-KEM-768 this is
      ``2.16.840.1.101.3.4.4.2`` (id-alg-ml-kem-768).

   .. attribute:: kem_algorithm_params
      :type: bytes | None

      Raw DER bytes of the KEM algorithm parameters, or ``None`` if the
      ``AlgorithmIdentifier.parameters`` field is absent.

   .. attribute:: kem_ciphertext
      :type: bytes

      The ``kemct`` OCTET STRING — the KEM ciphertext encapsulating the shared
      secret from which the KEK is derived.

   .. attribute:: kdf_algorithm_oid
      :type: synta.ObjectIdentifier

      OID of the key-derivation algorithm (the ``kdf`` field).  For HKDF with
      SHA-256 this is ``1.2.840.113549.1.9.16.3.28`` (id-alg-hkdf-with-sha256).

   .. attribute:: kdf_algorithm_params
      :type: bytes | None

      Raw DER bytes of the KDF algorithm parameters, or ``None``.

   .. attribute:: kek_length
      :type: int

      The ``kekLength`` field: the length in bytes of the key-encryption key
      (KEK) to be derived from the KEM shared secret.  Valid range: 1–65535.

   .. attribute:: ukm
      :type: bytes | None

      User keying material (``ukm`` field, ``[0] EXPLICIT`` OPTIONAL).
      ``None`` if the optional field is absent.

   .. attribute:: key_encryption_algorithm_oid
      :type: synta.ObjectIdentifier

      OID of the key-encryption (key-wrap) algorithm (the ``wrap`` field).
      For AES-256 key-wrap this is ``2.16.840.1.101.3.4.1.45``
      (id-aes256-Wrap).

   .. attribute:: key_encryption_algorithm_params
      :type: bytes | None

      Raw DER bytes of the key-encryption algorithm parameters, or ``None``.

   .. attribute:: encrypted_key
      :type: bytes

      The ``encryptedKey`` OCTET STRING — the content-encryption key (CEK)
      encrypted under the KEK.

.. class:: CMSORIforKEMOtherInfo

   CMS ORI KEM Other Info (RFC 9629 §6.2).

   ``CMSORIforKEMOtherInfo`` is the ``otherInfo`` value passed to the KDF when
   deriving the KEK from the KEM shared secret.  It binds the key-wrap
   algorithm, the KEK length, and the optional UKM to the derivation.

   .. method:: from_der(data: bytes) -> CMSORIforKEMOtherInfo
      :classmethod:

      Parse a DER-encoded ``CMSORIforKEMOtherInfo`` SEQUENCE.  Raises
      :exc:`ValueError` if the outer SEQUENCE envelope is malformed.

   .. method:: to_der() -> bytes

      Return the original DER bytes passed to :meth:`from_der`.

   .. attribute:: key_encryption_algorithm_oid
      :type: synta.ObjectIdentifier

      OID of the key-encryption (key-wrap) algorithm.

   .. attribute:: key_encryption_algorithm_params
      :type: bytes | None

      Raw DER bytes of the key-encryption algorithm parameters, or ``None``.

   .. attribute:: kek_length
      :type: int

      The ``kekLength`` field: KEK length in bytes (range 1–65535).

   .. attribute:: ukm
      :type: bytes | None

      User keying material (``[0] EXPLICIT`` OPTIONAL), or ``None`` if absent.

.. data:: ID_DATA
   :type: synta.ObjectIdentifier

   OID for the CMS ``id-data`` content type (``1.2.840.113549.1.7.1``,
   RFC 5652 §4).  Content is an OCTET STRING carrying arbitrary data.

.. data:: ID_SIGNED_DATA
   :type: synta.ObjectIdentifier

   OID for the CMS ``id-signedData`` content type (``1.2.840.113549.1.7.2``,
   RFC 5652 §5).  Content is a ``SignedData`` SEQUENCE.

.. data:: ID_ENVELOPED_DATA
   :type: synta.ObjectIdentifier

   OID for the CMS ``id-envelopedData`` content type
   (``1.2.840.113549.1.7.3``, RFC 5652 §6).  Content is an
   ``EnvelopedData`` SEQUENCE.

.. data:: ID_DIGESTED_DATA
   :type: synta.ObjectIdentifier

   OID for the CMS ``id-digestedData`` content type
   (``1.2.840.113549.1.7.5``, RFC 5652 §7).  Content is a
   ``DigestedData`` SEQUENCE (data plus a message digest).

.. data:: ID_ENCRYPTED_DATA
   :type: synta.ObjectIdentifier

   OID for the CMS ``id-encryptedData`` content type
   (``1.2.840.113549.1.7.6``, RFC 5652 §8).  Content is an
   ``EncryptedData`` SEQUENCE (symmetric, no recipient management).

.. data:: ID_CT_AUTH_DATA
   :type: synta.ObjectIdentifier

   OID for the CMS ``id-ct-authData`` content type
   (``1.2.840.113549.1.9.16.1.2``, RFC 5652 §9).  Content is an
   ``AuthenticatedData`` SEQUENCE (MACed data).

.. data:: ID_ORI
   :type: synta.ObjectIdentifier

   Root OID for CMS ``OtherRecipientInfo`` alternatives
   (``1.2.840.113549.1.9.16.13``, id-ori, RFC 9629 §6.2).

.. data:: ID_ORI_KEM
   :type: synta.ObjectIdentifier

   OID identifying a ``KEMRecipientInfo`` value inside ``OtherRecipientInfo``
   (``1.2.840.113549.1.9.16.13.3``, id-ori-kem, RFC 9629 §6.2).
   Use this OID when matching the ``oriType`` field of an
   ``OtherRecipientInfo`` to determine whether to decode the ``oriValue``
   as a :class:`KEMRecipientInfo`.

.. rubric:: Content-encryption algorithm OIDs (NIST AES, RFC 3565)

These OIDs are passed as the ``algorithm_oid`` argument to
:meth:`EncryptedData.create` and appear in
:attr:`EncryptedData.content_encryption_algorithm_oid`.

.. data:: ID_AES128_CBC
   :type: synta.ObjectIdentifier

   OID for AES-128 in CBC mode (``2.16.840.1.101.3.4.1.2``, RFC 3565).
   Requires a 16-byte key.

.. data:: ID_AES192_CBC
   :type: synta.ObjectIdentifier

   OID for AES-192 in CBC mode (``2.16.840.1.101.3.4.1.22``, RFC 3565).
   Requires a 24-byte key.

.. data:: ID_AES256_CBC
   :type: synta.ObjectIdentifier

   OID for AES-256 in CBC mode (``2.16.840.1.101.3.4.1.42``, RFC 3565).
   Requires a 32-byte key.
"""
# This file is a documentation and IDE-stub only.  The live module object for
# ``synta.cms`` is the Rust module registered in sys.modules["synta.cms"]
# by synta-python's _synta initialiser.  Python never executes this file at
# runtime because sys.modules["synta.cms"] is already populated before any
# import machinery would look for a .py file.