hash0() reduces each six-bit z chunk modulo a position-dependent value:
_zn = (zn % (63 - n)) + n n = 0..3
_zn4 = (zn4 % (64 - n)) + n n = 0..3, chunks 4..7
The modulus is below 0x40, so the reduction is lossy and a recovered residue
r has a second pre-image at r + modulus whenever that still fits in six bits.
invert_hash0() forked on a hardcoded table mapping {00,01,02,03} to
{3f,3e,3d,3c}, i.e. alt = 63 - r, gated on `hydra_head <= n % 4 ||
hydra_head >= 63 - (n % 4)`. Neither matches the actual arithmetic: the
alternative is r + modulus, not 63 - r, and which chunks can fork follows the
modulus rather than n % 4. The table happens to be right for a few positions
and wrong for the rest, so some valid pre-images were never generated.
Replaced with the modulus arithmetic taken directly from hash0(). Also drops
~15 lines.
Impact: the pre-image is the DES ciphertext for the master key crack. If the
true one is missing, hashcat searches the entire keyspace and finds nothing,
with no way to distinguish that from "the key isn't there".
Measured over randomly generated master/CSN pairs, where the true ciphertext
is computable and can be checked against the output:
before the true DES ciphertext was absent for 5 of 30 keys (17%)
after present for 149 of 150 keys
The one remaining failure is unrelated and predates this change:
invert_hash0() returns no pre-images at all for roughly 0.5% of keys
(measured 2 of 400), where neither p nor ~p is found in pi[] and the x search
yields nothing. Left alone here.
Example. Master key 1111111111111111 and CSN 2222222222222222 diversify to
B94318BC673F0A12, and DES_enc(CSN, master) = 950973182317F80B:
hf iclass unhash -k B94318BC673F0A12
before after
090973182314280B 090973182314280B
4F0973182314280B 090973182317F80B
950973182314280B 4F0973182314280B
DB0973182314280B 4F0973182317F80B
950973182314280B
950973182317F80B <- the true one
DB0973182314280B
DB0973182317F80B
Every printed candidate is still validated through hash0() before being
reported, so this only adds pre-images that verifiably hash back to the key.
1. Added `STL Ride On` to `transport` section.
2. Updated multiple AIDs where `Country` was listed as `N/A`.
3. Updated multiple AIDs in `transport` section where airport IATA was missing.
4. Re-sorted AIDs by AID type then ascending AID order.
*MSB/LSB endian checks were not done on recently-merged AIDs.*
-r&y.
Signed-off-by: ry4000 <154689120+ry4000@users.noreply.github.com>