Root cause
Other / insufficient public mechanism detail introduced
The position-selection helper seeds Python random with the supplied value and then samples cover positions.
How AI contributed: Direct introductionPublished Mar 31, 2026 in
jahlives/openssl_encryptAll 20 findings in this repository
Provisional finding. Full causal and release verification remains incomplete.
Root cause
The position-selection helper seeds Python random with the supplied value and then samples cover positions.
Fix
The replacement shuffle derives its pseudorandom values with HMAC-SHA256 instead of Python random.
Case facts
@@ -0,0 +261,18 @@+ return psnr+ + @staticmethod+ def generate_pseudorandom_sequence(seed: int, length: int, max_value: int) -> List[int]:+ """Generate pseudorandom sequence for pixel/sample selection"""+ import random+ random.seed(seed)+ return random.sample(range(max_value), min(length, max_value))+ + @staticmethod+ def analyze_entropy(data: bytes) -> float:+ """Calculate Shannon entropy of data"""+ if not data:+ return 0.0+ + # Count byte frequencies+ byte_counts = [0] * 256+ for byte in data:@@ -92,0 +112,18 @@+ # Generate enough random bytes for all swap decisions+ # Each swap needs log2(n) bits, but we use 4 bytes per swap for simplicity+ counter = 0+ for i in range(n - 1, 0, -1):+ # Generate deterministic random index using HMAC-SHA256+ hmac_input = struct.pack(">I", counter)+ h = hmac.new(key, hmac_input, hashlib.sha256).digest()+ # Use first 4 bytes as uint32, modulo (i+1) for unbiased index+ rand_val = struct.unpack(">I", h[:4])[0]+ j = rand_val % (i + 1)+ items[i], items[j] = items[j], items[i]+ counter += 1++ @staticmethod+ def crypto_seeded_shuffle_np(items: list, key: bytes) -> None:+ """+ Deterministic cryptographic shuffle for numpy-compatible code.+ Uses HMAC-SHA256 to generate seed material for numpy Generator.AI-assisted change 8922de77db356df99cf17d7f26a5c488fd18c8ea24902a3cf70ab7ff1e1db1d5 · Fix 44250f6c84a5bd4099e907696a8528bd9638312606479f187df0a6a588b9c44f