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
use crate;
/// DES Feistel Function (F)
///
/// Applies the DES round function to a 32-bit block using a 48-bit subkey.
///
/// The function performs the following steps:
///
/// 1. Expansion permutation (E-box) — 32 bits → 48 bits
/// 2. XOR with round subkey
/// 3. Substitution using S-boxes — 48 bits → 32 bits
///
/// # Arguments
///
/// * `bits` - 32-bit right half of the block
/// * `k` - 48-bit round subkey (stored in `u64`)
///
/// # Returns
///
/// A 32-bit transformed block
///
/// # Examples
///
/// ```rust
/// use cryptograph::cryptography::des::f::f;
///
/// let right: u32 = 0x12345678;
/// let key: u64 = 0x3A94D63F2C1E;
///
/// let result = f(right, key);
///
/// assert!(result <= 0xFFFFFFFF);
/// ```
///
/// # Notes
///
/// - This function is used inside each DES round
/// - The output is XORed with the left half in the Feistel structure
/// - Only the lower 48 bits of `k` are used
///
/// # DES Round Structure
///
/// ```text
/// Lᵢ₊₁ = Rᵢ
/// Rᵢ₊₁ = Lᵢ XOR F(Rᵢ, Kᵢ)
/// ```
///
/// # See also
///
/// - `e_box()`
/// - `s_box()`
/// - `round()`