Skip to main content

sesame-esam (Python)

A native Python implementation of SESAME (Secure ESAM Authentication and Message Encryption), the proposed SCTE 130-9 security layer for the ESAM interface. A sibling of the Rust crate and C++ SDK in this repo, proven against the same golden vectors (../test-vectors/), so a Python signer and a Rust, C++, or rust-pois verifier interoperate byte-for-byte.

  • Three tiers over a Tier-0 baseline: HMAC-SHA256 auth (1), channel-scoped authorization (2), AES-256-GCM payload encryption (3), plus signed responses.
  • One dependency: cryptography for AES-256-GCM (hmac/hashlib from the stdlib cover the rest).
  • Pythonic API: verify_request / sign_response; failures raise SesameError (with .code and .http_status, Appendix A.7).

PyPI package: sesame-esam; import name: sesame. See ../SESAME.md for the byte-exact wire format (draft v0.5).

Install

pip install sesame-esam

Quick start

Verify an inbound request (the POIS side):

from sesame import (verify_request, RequestContext, SesameConfig, SesameHeaders,
                    StaticKeyProvider, ChannelScope, InMemoryReplayCache, Tier, SesameError)
import time

keys = StaticKeyProvider().with_signing_key(
    "sas-east-01", b"shared-secret", ChannelScope.list(["SportsFeed-East"]))
replay = InMemoryReplayCache(300)

headers = SesameHeaders.from_lookup(lambda name: request_headers.get(name))
ctx = RequestContext("POST", "/esam", target_channel=None)
try:
    v = verify_request(SesameConfig(), keys, replay, ctx, headers, body,
                       int(time.time()), Tier.ONE)
    # v.plaintext is the ESAM XML; v.achieved_tier / v.key_id / v.scope_channel
except SesameError as e:
    # e.code (SesameErrorCode), e.http_status
    ...

Sign an outbound response (the POIS side):

from sesame import sign_response, ResponseParams, SesameConfig, Tier
import time

params = ResponseParams(signing_key_id="pois-primary",
                        correlation="ap-1:sigid-20260224-001", tier=Tier.ONE)
resp = sign_response(SesameConfig(), keys, params, xml, int(time.time()))
# attach resp.headers (list of (name, value)), send resp.body with resp.content_type

Development

python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
pytest -q          # conformance (golden vectors) + unit (KATs + negative matrix)
python examples/sign_request.py 3

License

Dual-licensed under MIT or Apache-2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sesame_esam-0.1.1.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sesame_esam-0.1.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file sesame_esam-0.1.1.tar.gz.

File metadata

  • Download URL: sesame_esam-0.1.1.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sesame_esam-0.1.1.tar.gz
Algorithm Hash digest
SHA256 497dc97a0707de8c0f00d593fbb48bc064fd79ef01a498172d347e3eb3daf1d8
MD5 9c7a3f3ff88b1924a1ee6d338df5fd0c
BLAKE2b-256 df6272fe47708ad27e5d607dfe24ce903a7ab13991070a078a85c96b2e413461

See more details on using hashes here.

File details

Details for the file sesame_esam-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sesame_esam-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sesame_esam-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9fe9bbb13e714bffb8a670a8fa46f04a00aeeebd14b7874d66e90fe609e35110
MD5 3b936ed0cdf60a7c7760de8f7fc5fa84
BLAKE2b-256 26caa4f4350e57f045ee18c4ed33780a17d23f3ba0ada452be7f9781e087004e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page