Skip to main content

steel_crypto/
lib.rs

1//! Cryptographic utilities for `SteelMC`, focused on RSA signing and verification
2//! for secure chat message validation.
3//!
4//! This module implements the cryptographic primitives needed for Minecraft's
5//! signed chat system, including RSA key pair generation, `SHA256withRSA` signing,
6//! and signature verification.
7#![expect(
8    missing_docs,
9    reason = "crypto has a small public surface pending API documentation"
10)]
11#![expect(
12    clippy::absolute_paths,
13    clippy::manual_let_else,
14    clippy::missing_panics_doc,
15    reason = "crypto code keeps direct error-path tests and small explicit RSA type paths"
16)]
17#![cfg_attr(
18    test,
19    expect(
20        clippy::unwrap_used,
21        reason = "crypto unit tests use unwraps for direct failure diagnostics"
22    )
23)]
24
25pub mod key_store;
26pub mod rsa_utils;
27pub mod signature;
28
29pub use rsa_utils::{CryptError, generate_key_pair, public_key_from_bytes, public_key_to_bytes};
30pub use signature::{SignatureUpdater, SignatureValidator, Signer};
31
32/// Signing algorithm used for chat messages (`SHA256withRSA`)
33pub const SIGNING_ALGORITHM: &str = "SHA256withRSA";
34
35/// Size of RSA signatures in bytes (for 1024-bit RSA keys, signatures are 128 bytes)
36/// Note: Minecraft protocol specifies 256 bytes, but 1024-bit RSA produces 128-byte signatures
37pub const SIGNATURE_BYTES: usize = 128;
38
39/// Size of RSA keys in bits
40pub const RSA_KEY_BITS: usize = 1024;