synta 0.2.5

ASN.1 parser, decoder, and encoder library with DER/BER support and C FFI
Documentation
# DN Attribute OIDs


`synta.oids.attr` provides OID constants for Distinguished Name (DN) attribute types.

```python
import synta.oids.attr
```

## Constants

All constants are `ObjectIdentifier` instances.

| Constant | OID | RFC 4514 label |
|---|---|---|
| `COMMON_NAME` | 2.5.4.3 | CN |
| `ORGANIZATION` | 2.5.4.10 | O |
| `ORG_UNIT` | 2.5.4.11 | OU |
| `COUNTRY` | 2.5.4.6 | C |
| `STATE` | 2.5.4.8 | ST |
| `LOCALITY` | 2.5.4.7 | L |
| `STREET` | 2.5.4.9 | street |
| `SERIAL_NUMBER` | 2.5.4.5 | serialNumber |
| `EMAIL_ADDRESS` | 1.2.840.113549.1.9.1 | emailAddress |
| `GIVEN_NAME` | 2.5.4.42 | givenName |
| `SURNAME` | 2.5.4.4 | SN |
| `TITLE` | 2.5.4.12 | title |
| `INITIALS` | 2.5.4.43 | initials |
| `ORG_IDENTIFIER` | 2.5.4.97 | organizationIdentifier |
| `USER_ID` | 0.9.2342.19200300.100.1.1 | uid |
| `DOMAIN_COMPONENT` | 0.9.2342.19200300.100.1.25 | dc |
| `BUSINESS_CATEGORY` | 2.5.4.15 | businessCategory |
| `POSTAL_CODE` | 2.5.4.17 | postalCode |
| `GENERATION_QUALIFIER` | 2.5.4.44 | generationQualifier |
| `DN_QUALIFIER` | 2.5.4.46 | dnQualifier |
| `PSEUDONYM` | 2.5.4.65 | pseudonym |
| `JURISDICTION_LOCALITY` | 1.3.6.1.4.1.311.60.2.1.1 | jurisdictionL |
| `JURISDICTION_STATE` | 1.3.6.1.4.1.311.60.2.1.2 | jurisdictionST |
| `JURISDICTION_COUNTRY` | 1.3.6.1.4.1.311.60.2.1.3 | jurisdictionC |

## Usage

```python
import synta
import synta.oids.attr as attr

# Parse a certificate subject and look up specific attributes
cert = synta.Certificate.from_der(open("cert.der", "rb").read())
name_attrs = synta.parse_name_attrs(cert.subject_raw_der)

# name_attrs is a list of (dotted_oid_str, value_str) tuples
for oid_str, value in name_attrs:
    if oid_str == str(attr.COMMON_NAME):
        print(f"CN={value}")
    elif oid_str == str(attr.ORGANIZATION):
        print(f"O={value}")
    elif oid_str == str(attr.COUNTRY):
        print(f"C={value}")

# Use as hashable key
lookup = {attr.COMMON_NAME: "common name", attr.ORGANIZATION: "org"}
```

See also [Well-known OIDs](oids.md) for the complete OID constant catalog.