Skip to main content

_synta/certificate/
pkcs9.rs

1//! Python bindings for PKCS #9 attribute OID constants (RFC 2985).
2//!
3//! Exposes the 13 well-known PKCS #9 OID constants into the ``synta.pkcs9``
4//! submodule.  These OIDs are used for signed attributes in CMS/PKCS #7
5//! structures and for bag attributes in PKCS #12 archives.
6
7use pyo3::prelude::*;
8
9/// Build and register the ``synta.pkcs9`` submodule.
10pub(super) fn register_pkcs9_submodule(parent: &Bound<'_, PyModule>) -> PyResult<()> {
11    let py = parent.py();
12    let m = PyModule::new(py, "pkcs9")?;
13
14    m.add(
15        "ID_PKCS_9",
16        super::oid_const(py, synta_certificate::pkcs9_types::ID_PKCS_9),
17    )?;
18    m.add(
19        "ID_EMAIL_ADDRESS",
20        super::oid_const(py, synta_certificate::pkcs9_types::ID_EMAIL_ADDRESS),
21    )?;
22    m.add(
23        "ID_UNSTRUCTURED_NAME",
24        super::oid_const(py, synta_certificate::pkcs9_types::ID_UNSTRUCTURED_NAME),
25    )?;
26    m.add(
27        "ID_CONTENT_TYPE",
28        super::oid_const(py, synta_certificate::pkcs9_types::ID_CONTENT_TYPE),
29    )?;
30    m.add(
31        "ID_MESSAGE_DIGEST",
32        super::oid_const(py, synta_certificate::pkcs9_types::ID_MESSAGE_DIGEST),
33    )?;
34    m.add(
35        "ID_SIGNING_TIME",
36        super::oid_const(py, synta_certificate::pkcs9_types::ID_SIGNING_TIME),
37    )?;
38    m.add(
39        "ID_COUNTERSIGNATURE",
40        super::oid_const(py, synta_certificate::pkcs9_types::ID_COUNTERSIGNATURE),
41    )?;
42    m.add(
43        "ID_CHALLENGE_PASSWORD",
44        super::oid_const(py, synta_certificate::pkcs9_types::ID_CHALLENGE_PASSWORD),
45    )?;
46    m.add(
47        "ID_UNSTRUCTURED_ADDRESS",
48        super::oid_const(py, synta_certificate::pkcs9_types::ID_UNSTRUCTURED_ADDRESS),
49    )?;
50    m.add(
51        "ID_EXTENSION_REQUEST",
52        super::oid_const(py, synta_certificate::pkcs9_types::ID_EXTENSION_REQUEST),
53    )?;
54    m.add(
55        "ID_SMIME",
56        super::oid_const(py, synta_certificate::pkcs9_types::ID_SMIME),
57    )?;
58    m.add(
59        "ID_FRIENDLY_NAME",
60        super::oid_const(py, synta_certificate::pkcs9_types::ID_FRIENDLY_NAME),
61    )?;
62    m.add(
63        "ID_LOCAL_KEY_ID",
64        super::oid_const(py, synta_certificate::pkcs9_types::ID_LOCAL_KEY_ID),
65    )?;
66
67    crate::install_submodule(
68        parent,
69        &m,
70        "synta.pkcs9",
71        Some(concat!(
72            "synta.pkcs9 — PKCS #9 attribute OID constants (RFC 2985).\n\n",
73            "Covers signed-attribute OIDs used in CMS/PKCS #7 (id-contentType,\n",
74            "id-messageDigest, id-signingTime, id-countersignature), PKCS #10\n",
75            "request attributes (id-extensionRequest, id-challengePassword),\n",
76            "and PKCS #12 bag attributes (id-friendlyName, id-localKeyId).",
77        )),
78    )
79}