I’ve got a bunch of 48-bit (6 byte) values that I need to encrypt symmetrically. The two requirements are:
-
The resulting encrypted value needs to also be 48-bits (6 bytes) long. They key itself can be (and would preferably be) much longer to guard again brute force attacks.
-
The resulting encrypted value needs to be deterministic, i.e. value A using key B will always produce encrypted value C (we encrypt on the fly and show the encrypted data to the user so need to always show the same value)
All block ciphers I’ve found have used a minimum block size of 64 and appear to be fixed (you can’t use an arbitrary block size). Should I be thinking about a stream cipher?
I’m doing this in Java.
Note: I’ve seen this question and associated answers but wasn’t clear on whether the suggestions would satisfy my 2nd requirement.
(Sorry, I originally misread the requirements thinking it was the INPUT data that needed to be 6 bytes.)
I don’t think you can do exactly what you want with standard cryptographic algorithms:
Now, that doesn’t mean that a 48-bit block cipher couldn’t be developed– and indeed I dare say there are some out there– just that none of the bog-standard ciphers that have undergone years of scrutiny from the cryptographic community have that block size.
So I would suggest options are:
The obvious problem with the latter option is that, whist standard block ciphers are generally based on common general principles, they adopt particular design decisions that have been subject to considerable scrutiny; yours presumably won’t be.
I would also recommend standing back a bit from the problem (or perhaps explaining a bit more what you’re trying to do), because it seems to be based on requirements that would normally go against good security practice (having the same plaintext always encrypt to the same ciphertext is something one would normally specifically avoid, for example). So you could have the best designed Feistel cipher in the world, but introduce some other vulnerability in how you’re using it.
[*] TripleDES is generally not recommended because AES gives better security more efficiently (you might like to see some comparative timings of block ciphers that I took in Java to see just how bad it is). However, this might not matter in your particular application.
No, just “pad” your data out with some bytes you don’t care about (but which are always the same if that’s your requirement) so that you reach the size of a block. (If you’re using an appropriate padding mode, then this will be done for you.)