That said, If I wanted to rapidly detect a wrong key, I'd concoct some
known or agreed-upon value, and use the password-derived decryption
key (or a hash thereof if it's too long to use directly) as the key
for an HMAC over the known or agreed-upon value. I'd store that with
the file and calculate it prior to attempting to decrypt the file to
see if my decryption key was valid.[1]
But let me reiterate... slow discovery of an invalid decryption key
sounds more like a feature than a bug to me, so I'd think very
carefully before implementing this kind of scheme. I suspect that this
is why you can't find the answer. Why do you want to make it faster to
attack your encryption scheme?
Geoff
[1] An authenticated mode like GCM might achieve the same goal here.
I'm not sure. My instinct is that this application would be an abuse
of such a mode and would provide neither security nor performance
advantages over what I describe, but I haven't spent much time
studying authenticated modes and could definitely be wrong about that
assertion.
> --
> You received this message because you are subscribed to the "Crypto++ Users" Google Group.
> To unsubscribe, send an email to cryptopp-user...@googlegroups.com.
> More information about Crypto++ and this group is available at http://www.cryptopp.com.
It's highly improbable, but I wouldn't be comfortable saying it's
impossible. Integrity isn't explicitly guaranteed by CBC. I'd expect a
wrong key, wrong IV or corrupt data stream to throw this exception for
CBC, and don't know of a means for distinguishing which caused it
without layering some other primitive. I'd suggest a signature and/or
an HMAC-based scheme for verifying message integrity if you need to do
that.
Geoff