3 ms·
Wow, this is super cool that they thought of / implemented this. (I think your math on bits is wrong: I'm getting that log2(1010 * 23 * 365 * 4) = 33.4, not 28
by geofft 9y ago
Wow, this is super cool that they thought of / implemented this.
(I think your math on bits is wrong: I'm getting that log2(1010 * 23 * 365 * 4) = 33.4, not 28.)
A few notes on the crypto off the top of my head:
1. 1714 iterations of SHA-256 seems really low given that you're going to be looking this up approximately once per person. My 2010-era laptop can compute about a million hashes per second according to `openssl speed sha256`. A second or two to look this up is definitely comparable with what a human would expect the UX to be for a dynamic website run by a government; honestly I wouldn't complain about up to a minute as long as there was a clear progress bar. So you could easily change it from 1,714 hashes to 1,714,000 without impacting UX, and you should probably do that given the relatively small key space, which would give you a factor of 1000x on the brute force attack.
2. AES-256-CBC with no IV smells funny to me. I guess every message is encrypted with a different key, but the keys themselves are easily derivable (they're just a single SHA-256 hash of the lookup key, and those are all in the public filesystem). I cannot think immediately of an attack against this but maybe someone else can.
3. Your brute-force estimates are what's needed to enumerate the entire lookup key space. The practical attack here is what you've outlined, that you know someone's date of birth and zip code (which are likely in public records). and want their national ID for some identity theft. You're not trying to find some arbitrary person to steal the identity of. That means that the date of birth and zip code are fixed, and you only need to brute-force the DNI portion, which has only 10^5 * 23 possibilities. That's extremely realistic: I can compute 10^5 * 23 * 1715 hashes on my 2010 laptop in a little over an hour.
I guess they do the right thing by only using a part of the DNI string, so you still have three unknown decimal digits, and zero information about what they might be.
- jsdario 9y agoHow is it any better to hash the same text 256 times? Entropy will always be the same. You'd just need to change the hashing function. https://softwareengineering.stackexchange.com/questions/115406/is-it-more-secure-to-hash-a-password-multiple-times?newreg=3a63ea8553284290bab9759378411a90 https://softwareengineering.stackexchange.com/questions/1154...
- kilburn 9y ago> (I think your math on bits is wrong: I'm getting that log2(1010 * 23 * 365 * 4) = 33.4, not 28.) 1. Totally right that I'm wrong, but I'm now getting 48 bits, not 33 ;) 2. That was a terrible mistake of my own. The lookup key is derived from the password, not the other way around. I've corrected the article to clarify that! 3. Yeah that's why I said you can do it with your laptop and not too much time ;) Only using the latest part of the DNI is not that good though. The letter is actually a control character, which can be computed from the 8 numbers. Hence, if you have 5 numbers and the letter, there are only some possible 3-digit prefixes that lead to a valid DNI! How many? I would have to investigate further hehe...
- rrobukef 9y agoI can't check, but isn't sha256_times(passkey, 1713) == passkey? (sha256_times(sha256(a), 1713) == sha256_times(a,1714)?) The encryption is then basically worthless if you have a list of all lookups. (I didn't see a dynamic in the sha256_times function.)