adding check to the key length

In reference to #6722, I humbly submit my first PR.
DecryptException isn't the right thing to throw here. We're not trying to decrypt anything.