Skip to main content

Module crypto

Module crypto 

Source
Expand description

Low-level cryptographic primitives for PDF encryption.

Split into three submodules mirroring the upstream core/fdrm/ source layout:

§RC4 manual implementation

RC4 is implemented manually rather than using the rc4 crate because that crate requires a compile-time fixed key length via a type parameter (Rc4<U5>, Rc4<U16>, etc.), which is incompatible with PDF encryption’s variable-length keys (5-16 bytes for R2-R4, determined at runtime from the encryption dictionary).

§SHA-1

SHA-1 is used for digital signature verification (PKCS#7/CMS with sha1WithRSAEncryption) and some legacy PDF encryption extensions. Delegated to the RustCrypto sha1 crate, matching the same delegation pattern as sha2 for SHA-256/384/512.

Re-exports§

pub use fx_crypt::CryptoError;
pub use fx_crypt::md5;
pub use fx_crypt::rc4_crypt;
pub use fx_crypt::sha1;
pub use fx_crypt_aes::aes128_cbc_decrypt;
pub use fx_crypt_aes::aes128_cbc_encrypt;
pub use fx_crypt_aes::aes128_cbc_encrypt_no_padding;
pub use fx_crypt_aes::aes192_cbc_decrypt;
pub use fx_crypt_aes::aes192_cbc_encrypt;
pub use fx_crypt_aes::aes256_cbc_decrypt;
pub use fx_crypt_aes::aes256_cbc_decrypt_no_padding;
pub use fx_crypt_aes::aes256_cbc_encrypt;
pub use fx_crypt_aes::aes256_cbc_encrypt_no_padding;
pub use fx_crypt_aes::aes256_ecb_decrypt_block;
pub use fx_crypt_sha::sha256;
pub use fx_crypt_sha::sha384;
pub use fx_crypt_sha::sha512;

Modules§

fx_crypt
MD5, SHA-1, and RC4 primitives.
fx_crypt_aes
AES-128/192/256-CBC and AES-256-ECB primitives.
fx_crypt_sha
SHA-256, SHA-384, and SHA-512 hash functions.