synta 0.1.12

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


`ObjectIdentifier` is a frozen (immutable, thread-safe) wrapper around an ASN.1
OBJECT IDENTIFIER value.

## Constructors

```python
ObjectIdentifier(oid_str: str)                     # from dotted-decimal, e.g. "2.5.4.3"
ObjectIdentifier.from_components(comps: list[int]) # from arc list
ObjectIdentifier.from_der_value(data: bytes)       # from implicit-tag content bytes (tag+length stripped)
```

## Methods and dunders

| Method / Dunder | Returns | Description |
|---|---|---|
| `components()` | `tuple[int, ...]` | OID arc components |
| `__str__()` | `str` | Dotted-decimal notation (cached) |
| `__repr__()` | `str` | `ObjectIdentifier('2.5.4.3')` |
| `__eq__(other)` | `bool` | Compares against another `ObjectIdentifier` or a dotted `str` |
| `__hash__()` | `int` | Consistent with `hash(str(oid))` so `oid in {"2.5.4.3"}` works |

## Full class stub

```python
class ObjectIdentifier:
    def __init__(self, oid_str: str) -> None: ...
    @staticmethod
    def from_components(components: list[int]) -> ObjectIdentifier: ...
    def components(self) -> list[int]: ...
    def __str__(self) -> str: ...
    def __eq__(self, other: ObjectIdentifier) -> bool: ...
    def __hash__(self) -> int: ...
```

## Working with Object Identifiers

```python
import synta

# Create OID from dotted string
oid = synta.ObjectIdentifier("1.2.840.10045.2.1")
print(str(oid))  # Output: 1.2.840.10045.2.1

# Get components
components = oid.components()
print(components)  # Output: [1, 2, 840, 10045, 2, 1]

# Create OID from components
oid = synta.ObjectIdentifier.from_components([1, 2, 840, 10045, 4, 3, 2])
print(str(oid))  # Output: 1.2.840.10045.4.3.2

# Equality comparison against a string
import synta.oids as oids
assert oids.EC_PUBLIC_KEY == "1.2.840.10045.2.1"

# Use as a dict key (hashable)
lookup = {oids.SHA256: "SHA-256", oids.SHA384: "SHA-384"}
name = lookup.get(cert.signature_algorithm_oid, "unknown")
```

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