Download the PHP package danog/madelinecrypto without Composer
On this page you can find all versions of the php package danog/madelinecrypto. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download danog/madelinecrypto
More information about danog/madelinecrypto
Files in danog/madelinecrypto
Package madelinecrypto
Short Description Native (Rust) cryptography for MadelineProto and php-rtc: AES-IGE and MTProto transport decoding off the PHP thread, per-packet AES-GCM/CTR/CBC, hashes and HMAC
License AGPL-3.0-only
Homepage https://github.com/danog/MadelineCrypto
Informations about the package madelinecrypto
MadelineCrypto
Native (Rust) cryptography extension for MadelineProto and php-rtc: MTProto AES-256-IGE and transport decoding on a worker thread, per-packet AES-GCM/CTR/CBC, hashes and HMAC several times faster than the PHP builtins on small inputs, and the factorization of the auth key exchange. Optional: without it, MadelineProto and php-rtc use their PHP implementations.
Install
With PIE (PHP 8.2+, NTS):
Releases include prebuilt binaries for Linux (glibc 2.35+, x86_64 and arm64), macOS (arm64 and x86_64) and
Windows (x86_64), for PHP 8.2 to 8.5. Elsewhere PIE builds from source, which needs
Rust, libclang and the OpenSSL headers. The danog/madelineproto Docker image
includes the extension.
API
Namespace danog\MadelineProto\Native, see stubs/crypto.php. Crypto::version()
is the API version (0.6.0); callers check it and keep a PHP fallback.
Crypto:init()starts the worker thread (bridged to Revolt by php-tokio),ige()anddecode()run on it,decodeSync()on the PHP thread;factorize()returns the smallest prime factor of a 64-bit integer (MTProto'spq).AesGcm,AesCtr,AesCtrKey,AesCbc,AesIge,Hmac,Hash: synchronous, noinit()needed. Key objects schedule their key once, zeroize it when freed, and can't be cloned or serialized. Outputs match the PHP builtins byte for byte; invalid sizes or algorithms throw\ValueError, and a GCM tag mismatch returnsfalse(constant-time check).
Build from source
or cargo build --release --locked and copy target/release/libmadeline_crypto.{so,dylib} (or
madeline_crypto.dll) to PHP's extension directory as madeline_crypto.so (php_madeline_crypto.dll).
The vendored-openssl feature links OpenSSL statically, as the prebuilt binaries do. On Windows, build with
nightly Rust: PHP calls extension functions with __vectorcall, which needs Rust's unstable
abi_vectorcall.
Tests
CI runs them on Linux, macOS and Windows with PHP 8.2 to 8.5, and installs the extension with PIE.
Design
Internals (the executor, batching, backend choices and their measurements): DESIGN.md.
License
AGPL-3.0-only.