happy-cracking 0.5.0

A fast, comprehensive CTF toolkit for cryptographic encoding/decoding, classic ciphers, hash operations, and analysis tools
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use happy_cracking::crypto::dh;
use num_bigint::BigUint;

#[test]
fn test_dh_bsgs_dos() {
    let g = BigUint::from(2u32);
    let target = BigUint::from(5u32);
    let p = BigUint::from(29u32);
    // Extremely large order, sqrt is ~2^32, which would allocate ~4 billion hashmap entries
    let order_str = "18446744073709551616"; // 2^64
    let order = order_str.parse::<BigUint>().unwrap();

    // This should return an error quickly, not hang or OOM
    let result = dh::baby_step_giant_step(&g, &target, &p, &order);
    assert!(result.is_err());
}