So....
.key files are encrypted with AES-256 (in CBC mode), which is a
block cipher. It operates on blocks of
exactly 16 bytes.
In order to deal with the case where a plaintext isn't a multiple of 16 bytes long, encryption tools often append additional padding bytes to the end of the plaintext to make it a multiple of 16 before encrypting it.
A very common padding standard (at least in the Bitcoin world) is standardized in
PKCS7. MultiBit and openssl both use this style of padding.
When openssl decrypts a ciphertext, its exit status is zero (as you already know) if the decryption "succeeds", and non-zero otherwise. When a (properly encrypted) ciphertext is decrypted with the
wrong key, the output should appear completely random. To check if a decryption succeeded, the only thing openssl can check is whether or not the padding at the end appears valid as per PKCS7.
After reading the description of that padding standard (linked above), you may notice if a plaintext is one byte short of being a multiple of 16 bytes long, the padding that must be appended is a single byte of value 0x01. That means that any ciphertext that happens (by random chance) to decrypt into a plaintext which ends in a 0x01, openssl has no choice but to assume that the decryption succeeded.
In short, about 1 in every 256 (actually slightly higher) decryption attempts will result in positives from openssl, even though they may be false positives.
btcrecover uses additional knowledge about what's in a decrypted .key file to throw out these false positives. Actually, btcrecover only bothers decrypting the first 16-byte block (in the interest of speed), and then it looks for a properly "
WIF" encoded private key. This also has a chance of false positives, but it's on the order of 1 in 300 billion... much more palatable
![Wink](https://bitcointalk.org/Smileys/default/wink.gif)
.
I'm going to be quite busy for the next two days with work but I'll get stuck into this at the weekend and whether or not I have any success, expect a little something coming your way.
Thanks! Tips always appreciated!