Skip to main content

Crate layer_crypto

Crate layer_crypto 

Source
Expand description

Cryptographic primitives for Telegram MTProto.

Provides:

  • AES-256-IGE encryption/decryption
  • SHA-1 / SHA-256 hash macros
  • Pollard-rho PQ factorization
  • RSA padding (MTProto RSA-PAD scheme)
  • AuthKey — 256-byte session key
  • MTProto 2.0 message encryption / decryption
  • DH nonce→key derivation

Modules§

aes
AES-IGE (Infinite Garble Extension) — used by Telegram’s MTProto.
rsa
RSA padding used by Telegram’s auth key exchange.

Macros§

sha1
Calculate the SHA-1 hash of one or more byte slices concatenated.
sha256
Calculate the SHA-256 hash of one or more byte slices concatenated.

Structs§

AuthKey
A Telegram authorization key (256 bytes) plus pre-computed identifiers.
DequeBuffer
Growable byte buffer that supports efficient front-extension.

Enums§

DecryptError
Errors from decrypt_data_v2.

Functions§

decrypt_data_v2
Decrypt an MTProto 2.0 ciphertext.
encrypt_data_v2
Encrypt buffer (in-place, with prepended header) using MTProto 2.0.
factorize
Factorize pq into two prime factors (p, q) where p ≤ q.
generate_key_data_from_nonce
Derive (key, iv) from nonces for decrypting ServerDhParams.encrypted_answer.