1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//! Cryptographic operations for MPQ files
//!
//! This module provides all cryptographic functionality needed for MPQ archives:
//!
//! ## Features
//!
//! - **Encryption/Decryption**: Block and single-value encryption using MPQ's custom algorithm
//! - **Hashing**: Multiple hash algorithms for different table types:
//! - MPQ hash algorithm: Classic hash for hash/block tables and encryption keys
//! - Jenkins one-at-a-time: Used for BET table hashes in MPQ v3+
//! - Jenkins hashlittle2: Used for HET table lookups in MPQ v3+
//! - **Digital Signatures**: Support for both weak (512-bit RSA) and strong (2048-bit RSA) signatures
//!
//! ## Digital Signatures
//!
//! MPQ archives support two types of digital signatures:
//!
//! ### Weak Signatures (v1+)
//! - 512-bit RSA with MD5 hash
//! - Stored in `(signature)` file within the archive
//! - Can be generated using the well-known Blizzard private key
//!
//! ### Strong Signatures (v2+)
//! - 2048-bit RSA with SHA-1 hash
//! - Appended after the archive data with "NGIS" header
//! - Generation requires private key (not publicly available)
//!
//! ## Examples
//!
//! ### Hash Algorithms
//!
//! ```no_run
//! use wow_mpq::crypto::{hash_string, hash_type, jenkins_hash, het_hash};
//!
//! // MPQ hash for hash table lookups
//! let table_hash = hash_string("Units\\Human\\Footman.mdx", hash_type::TABLE_OFFSET);
//! let name_a = hash_string("Units\\Human\\Footman.mdx", hash_type::NAME_A);
//! let name_b = hash_string("Units\\Human\\Footman.mdx", hash_type::NAME_B);
//!
//! // Jenkins one-at-a-time for BET tables
//! let bet_hash = jenkins_hash("Units\\Human\\Footman.mdx");
//!
//! // Jenkins hashlittle2 for HET tables
//! let (het_file_hash, het_name_hash) = het_hash("Units\\Human\\Footman.mdx", 48);
//! ```
//!
//! ### Digital Signatures
//!
//! ```no_run
//! use wow_mpq::crypto::{generate_weak_signature, verify_weak_signature_stormlib, SignatureInfo};
//! use std::io::Cursor;
//!
//! # fn main() -> Result<(), wow_mpq::Error> {
//! let archive_data = vec![0u8; 1024];
//! let sig_info = SignatureInfo::new_weak(0, 1024, 1024, 72, vec![]);
//!
//! // Generate signature
//! let signature = generate_weak_signature(Cursor::new(&archive_data), &sig_info)?;
//!
//! // Verify signature
//! let valid = verify_weak_signature_stormlib(
//! Cursor::new(&archive_data),
//! &signature[8..72],
//! &sig_info
//! )?;
//! # Ok(())
//! # }
//! ```
// Re-export public API
pub use ;
pub use encrypt_block;
pub use hash_string;
pub use ;
pub use ;
pub use hash_type;
// Re-export constants that might be needed elsewhere
pub use ;
// Internal-only exports
/// Calculate traditional MPQ hash values for a filename.
///
/// Returns `(hash_a, hash_b, hash_offset)` after normalizing the filename
/// (converting `/` to `\` and uppercasing).
/// Calculate HET (Hash Extended Table) hash values for a filename.
///
/// Returns `(file_hash, name_hash)` used by HET tables. The filename is
/// normalized (converting `/` to `\`) but not uppercased, as HET hashes
/// are case-sensitive.