Metadata-Version: 2.2
Name: ocf-containers
Version: 1.0.0
Summary: Open Container Format - encrypted, seekable media container with passwords, machine binding, expiry, play limits and Ed25519 signed policy
Author: OCF Contributors
License: MIT License
        
        Copyright (c) 2026 OCF Contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
        ---
        
        Exception note (not legal advice): cryptography primitives are drawn from
        the `cryptography` and `argon2-cffi` distributions and remain under their
        respective licenses (Apache-2.0 with linking exceptions, MIT,
        Apache-2.0). This license governs this repository's code only. The
        no-commercial-code clean-room rule documented in CONTRIBUTING.md is an
        engineering policy of this project, not a license condition.
        
Project-URL: Homepage, https://github.com/JustHackedOn/ocf-containers
Project-URL: Documentation, https://github.com/JustHackedOn/ocf-containers/tree/main/docs
Project-URL: Changelog, https://github.com/JustHackedOn/ocf-containers/blob/main/CHANGELOG.md
Project-URL: Security, https://github.com/JustHackedOn/ocf-containers/blob/main/docs/SECURITY.md
Project-URL: Issues, https://github.com/JustHackedOn/ocf-containers/issues
Keywords: encryption,container,media,drm,aead,aes-gcm,argon2,ed25519,watermark,clean-room
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography<47,>=42
Requires-Dist: argon2-cffi<26,>=23
Provides-Extra: dev
Requires-Dist: pytest<9,>=8; extra == "dev"
Requires-Dist: hypothesis<7,>=6; extra == "dev"
Requires-Dist: build<2,>=1.2; extra == "dev"

# OCF — Open Container Format

[![CI](https://github.com/JustHackedOn/ocf-containers/actions/workflows/test.yml/badge.svg)](https://github.com/JustHackedOn/ocf-containers/actions)
[![PyPI](https://img.shields.io/pypi/v/ocf.svg)](https://pypi.org/project/ocf/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

OCF is a **clean-room, open-source encrypted media container** with password
gating, machine binding, expiry, play-count limits, watermarks, and Ed25519-signed
policy. It is built from standard primitives only — AES-256-GCM, Argon2id,
Ed25519, HMAC-SHA256 — with no proprietary dependencies and no embedded keys.

**Status:** v1.0.0 · 99 tests green · ~540 fuzz examples with 0 crashes ·
1 GB file streamed at 245 MB/s (peak memory ≈ file size).

## What it does

```
plaintext ──chunked AES-256-GCM──► SEC_DATA
password  ──Argon2id──► KEK ──wraps──► content_key (never stored in the clear)
policy    ──Ed25519──► signed SEC_POLICY (open/play pw, machine bind,
                        expiry, play count, watermark)
everything┐
header    ├─ HMAC-SHA256 footer MAC (tamper-evident, verified before decrypt)
sections  ┘
```

## Features

- **AEAD everywhere** — per-chunk AES-256-GCM tags; bit-flips are rejected,
  seek is O(1) via chunk table (256 KiB default chunks)
- **Key wrapping** — content key is wrapped under an Argon2id-derived KEK;
  the derived key never touches disk
- **Signed policy** — open/password flags, machine binding, expiry,
  play-count limit, watermark, all in one Ed25519-signed `SEC_POLICY`
  (pin the vendor pubkey for authenticity; embedded key gives integrity)
- **Streaming** — `build_streaming()` writes O(chunk) memory for any size
  (tested at 1 GB); reader is mmap-backed with zero-copy sections
- **Machine binding** — weighted fingerprint from machine GUID, BIOS UUID,
  CPU ID, disk serial, MAC (each source hashed before combining; no raw
  serials in the digest)
- **Play counting** — external state file keyed by signed `container_id`;
  rewriting the container breaks the footer MAC, so counters can't be
  reset by editing the file
- **CLI + library** — `ocfctl` for scripts, clean Python API for apps

## Honest scope (read before trusting this with anything)

OCF protects **data at rest** and gates **player behavior**. Like every
client-side DRM scheme (including commercial ones), it cannot defend an
attacker who controls the running player: the unwrapped key must exist in
process memory to play. OCF raises the cost of casual redistribution and
tampering; it does not promise impossibility. See [docs/SECURITY.md](docs/SECURITY.md)
for the full threat model.

## Install

```bash
pip install ocf-containers  # from PyPI (when published)
pip install .            # from a clone
pip install -e ".[dev]"  # dev install with pytest/hypothesis/build
```

Python 3.11+ · Windows, Linux, macOS.

## Quick start

```bash
# Encrypt a folder for this machine only, expiring 2026-12-31, 5 plays max
ocfctl create movie.ocf video.mp4 --password openpw \
    --machine-bind --expiry 2026-12-31 --play-count 5 \
    --watermark "REVIEW COPY" --sign
#    → prints the policy pubkey; PIN IT to verify signatures later

ocfctl info movie.ocf --password openpw
ocfctl authorize movie.ocf --password openpw --play-password REPLACEME
```

See [QUICKSTART.md](QUICKSTART.md) for the 5-minute walkthrough and
[docs/CLI_REFERENCE.md](docs/CLI_REFERENCE.md) for every flag.

## Library example

```python
from ocf.container import ContainerWriter, ContainerReader, FileEntry, make_policy
from ocf.primitives.signing import generate_signing_key

policy = make_policy(signing_key=generate_signing_key(), watermark="TRIAL")
blob = ContainerWriter(password=b"openpw", policy=policy).build(
    [FileEntry("video.mp4", open("video.mp4", "rb").read())]
)
r = ContainerReader(blob, password=b"openpw")
print(r.policy.watermark, r.files[0].name)
data = r.read_file(0)
```

More in [`examples/`](examples/): basic, password, machine-bound, expiry,
play-count, batch, and 1 GB streaming.

## Benchmarks

| Case | Encrypt | Decrypt |
|---|---|---|
| 100 MB (stream) | ~250 MB/s | ~290 MB/s |
| 1 GB (stream) | 245 MB/s | 250 MB/s |
| Password overhead | Argon2id ≈ 0.25 s fixed per open | |

Details and methodology: [docs/BENCHMARK.md](docs/BENCHMARK.md).
Parallel workers are off by default — measured to hurt on AES-NI.

## Documentation

| Doc | Contents |
|---|---|
| [QUICKSTART.md](QUICKSTART.md) | first container in 5 minutes |
| [docs/CLI_REFERENCE.md](docs/CLI_REFERENCE.md) | all commands and flags |
| [docs/FORMAT_SPEC.md](docs/FORMAT_SPEC.md) | public container format spec |
| [docs/SECURITY.md](docs/SECURITY.md) | threat model, disclosure |
| [docs/BENCHMARK.md](docs/BENCHMARK.md) | numbers + recommendations |
| [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md) | dev setup, PRs, clean-room policy |
| [docs/RELEASING.md](docs/RELEASING.md) | versioning, PyPI, tags |

## Development

```bash
git clone https://github.com/JustHackedOn/ocf-containers && cd ocf-containers
pip install -e ".[dev]"
pytest -q          # 99 tests, including ~540 fuzz examples
python tools/benchmark.py --quick
```

## License

MIT — see [LICENSE](LICENSE).
