Metadata-Version: 2.4
Name: oxcrypto
Version: 0.1.0
License-File: LICENSE-MIT
License-File: LICENSE-APACHE
License-File: THIRD_PARTY_LICENSES.md
Summary: Rust-based cryptographic infrastructure for Python
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
License-Expression: (MIT OR Apache-2.0) AND ((MIT OR Apache-2.0) AND Unicode-3.0) AND (Apache-2.0) AND (Apache-2.0 AND ISC) AND (Apache-2.0 OR GPL-2.0-only) AND (BSD-2-Clause) AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND (BSD-3-Clause) AND (CC0-1.0 OR Apache-2.0) AND (CC0-1.0 OR Apache-2.0 OR Apache-2.0 WITH LLVM-exception) AND (CC0-1.0 OR MIT-0 OR Apache-2.0) AND (ISC) AND (MIT) AND (MIT OR Apache-2.0 OR BSD-1-Clause) AND (Unicode-3.0) AND (Unlicense) AND (Unlicense OR MIT) AND (Zlib OR Apache-2.0 OR MIT)

<div align="center">

<h1>oxcrypto</h1>

<p><strong>Rust-native cryptographic infrastructure for Python</strong></p>

<p>
Established Rust implementations, led by <a href="https://github.com/RustCrypto">RustCrypto</a>,<br>
under one consistent, strongly typed Python API.
</p>

<p>
<a href="#license"><img alt="License: MIT OR Apache-2.0" src="https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue"></a>
<a href="pyproject.toml"><img alt="Python 3.11+" src="https://img.shields.io/badge/python-3.11%2B-blue"></a>
<a href="#project-status"><img alt="Status: pre-release" src="https://img.shields.io/badge/status-pre--release-lightgrey"></a>
</p>

<p>
<a href="https://oceanus403.github.io/oxcrypto/docs/"><b>Documentation</b></a>
&nbsp;&middot;&nbsp;
<a href="#capabilities"><b>Capabilities</b></a>
&nbsp;&middot;&nbsp;
<a href="#installation"><b>Installation</b></a>
&nbsp;&middot;&nbsp;
<a href="#usage"><b>Usage</b></a>
&nbsp;&middot;&nbsp;
<a href="CONTRIBUTING.md"><b>Contributing</b></a>
</p>

</div>

<br>

> [!CAUTION]
> oxcrypto has not had an independent security audit. Correctness and
> side-channel behavior depend on the upstream crates named on each docs page.
> Python `bytes` passed to or returned by oxcrypto are not wiped from memory.

## Capabilities

| Family | Algorithms |
|:--|:--|
| [Hashes](docs/content/docs/hashes/index.mdx) | SHA-2, SHA-3, Keccak, BLAKE2, BLAKE3, SM3, Streebog, BelT, Bash, Ascon-Hash256, Kupyna, Grøstl, Skein, JH, Shabal, Whirlpool, Tiger, FSB, RIPEMD; experimental Bao; legacy SHA-1, MD5, MD4, MD2, GOST R 34.11-94 |
| [XOFs](docs/content/docs/xof/index.mdx) | SHAKE, cSHAKE, TupleHash, TurboSHAKE, KangarooTwelve, Ascon-XOF128, Bash programmable hash |
| [MACs](docs/content/docs/mac/index.mdx) and [universal hashes](docs/content/docs/universal_hash/index.mdx) | HMAC, CMAC, PMAC, CBC-MAC, Retail MAC; Poly1305, GHASH, POLYVAL |
| [Block ciphers](docs/content/docs/cipher/index.mdx) and [key wrap](docs/content/docs/keywrap/index.mdx) | AES, ARIA, Camellia, Serpent, Twofish, SM4, Kuznyechik, Magma, BelT and more; CBC, CFB, CTR, OFB, IGE, PCBC; AES-KW, AES-KWP, BelT-KWP |
| [Stream ciphers](docs/content/docs/stream/index.mdx) | ChaCha, XChaCha, Salsa20, XSalsa20, HC-256, Rabbit; legacy RC4 |
| [AEADs](docs/content/docs/aead/index.mdx) | AES-GCM, AES-GCM-SIV, ChaCha20-Poly1305, XChaCha20-Poly1305, Deoxys, XAES-256-GCM, Ascon-AEAD128, Xoodyak, belt-dwp, STREAM |
| [Key derivation](docs/content/docs/kdf/index.mdx) | HKDF, KBKDF, ANSI X9.63, SP 800-56C one-step, bake-kdf |
| [Password hashing](docs/content/docs/password/index.mdx) | Argon2, scrypt, yescrypt, bcrypt, Balloon, PBKDF2, SHA-crypt, bcrypt-pbkdf |
| [Signatures](docs/content/docs/signature/index.mdx) | RSA PKCS#1 v1.5 and PSS, DSA, ECDSA on NIST, secp256k1 and Brainpool curves, BIP 340 Schnorr, Ed25519, ML-DSA, SLH-DSA, XMSS and XMSS^MT; experimental Ed448, FN-DSA, BLS, sr25519, RFC 9474 blind RSA |
| [Key exchange](docs/content/docs/exchange/index.mdx) and [encryption](docs/content/docs/encryption/index.mdx) | ECDH, BIGN-256 Diffie-Hellman, X25519, X448; RSA-OAEP |
| [KEMs](docs/content/docs/kem/index.mdx) | ML-KEM, DHKEM; experimental X-Wing, HQC, FrodoKEM, sntrup761 |
| [HPKE](docs/content/docs/hpke/index.mdx) and [NaCl](docs/content/docs/nacl/index.mdx) | RFC 9180 HPKE in all four modes; `crypto_box`, `crypto_secretbox`, sealed boxes |
| Protocols | [OPAQUE-3DH](docs/content/docs/pake/index.mdx), [OPRF, VOPRF and POPRF](docs/content/docs/oprf/index.mdx), [FROST](docs/content/docs/threshold/index.mdx), [Shamir, Feldman and Pedersen secret sharing](docs/content/docs/secret_sharing/index.mdx), [HOTP and TOTP](docs/content/docs/otp/index.mdx); experimental [ECVRF-ristretto255](docs/content/docs/vrf/index.mdx) |
| [Random](docs/content/docs/random/index.mdx), [encodings](docs/content/docs/encoding/index.mdx), [hazmat](docs/content/docs/hazmat/index.mdx) | OS CSPRNG, seeded ChaCha; Base16/32/64, PEM; Keccak, Ascon and bash-f permutations, hash-to-curve, ristretto255 and decaf448 groups |
| Certificates and signed messages | [X.509 and CMS](docs/content/docs/pki/index.mdx), [OpenSSH](docs/content/docs/ssh/index.mdx) |
| Token formats | [JOSE](docs/content/docs/jose/index.mdx), [COSE](docs/content/docs/cose/index.mdx), [PASETO](docs/content/docs/paseto/index.mdx) |
| File encryption formats | [age](docs/content/docs/age/index.mdx) |
| [Hierarchical keys](docs/content/docs/hd/index.mdx) | BIP-39 mnemonics and BIP-32 extended keys |

## Installation

oxcrypto supports Python 3.11 and newer.

Add it to a uv project:

```sh
uv add oxcrypto
```

To install it in an active Python environment:

```sh
pip install oxcrypto
```

To build from source with [uv](https://docs.astral.sh/uv/) and Rust 1.88+:

```sh
git clone https://github.com/oceanus403/oxcrypto
cd oxcrypto
uv sync --locked
```

## Usage

```python
import os

from oxcrypto.aead.aes_gcm import AES_GCM
from oxcrypto.hash.sha2 import SHA2
from oxcrypto.kem.ml_kem import ML_KEM
from oxcrypto.password.argon2 import ARGON2
from oxcrypto.signature.ecdsa import ECDSA

digest = SHA2.SHA256.digest(b"hello")

record = ARGON2.ARGON2ID.hash(b"correct horse")
assert ARGON2.ARGON2ID.verify(b"correct horse", record)

key = AES_GCM.AES256.generate()
nonce = os.urandom(12)
sealed = key.encrypt(nonce, b"message", associated_data=b"header")
assert key.decrypt(nonce, sealed, associated_data=b"header") == b"message"

signer = ECDSA.P256.generate()
signature = signer.sign(b"message", hash=SHA2.SHA256)
assert signer.public_key().verify(signature, b"message", hash=SHA2.SHA256)

decapsulator = ML_KEM.ML_KEM_768.generate()
ciphertext, shared = decapsulator.public_key().encapsulate()
assert decapsulator.decapsulate(ciphertext) == shared
```

## Project status

> [!IMPORTANT]
> oxcrypto is pre-release. Its API may change before 1.0.

## License

Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or
[MIT license](LICENSE-MIT) at your option. Wheels bundle third-party Rust
crates; their notices are in [THIRD_PARTY_LICENSES.md](THIRD_PARTY_LICENSES.md).

