0
$\begingroup$

Is there any security risk in encrypting parts of blocks twice? I'd like to get around block sizes and make encrypted messages just as long as the unencrypted ones:

Block 1: Byte 0 - 7
Block 2: Byte 8 - 15
Block 3: Byte 16 - 23
Block 4: Byte 21 - 29

In this example blocks 3 and 4 overlap by 2 bytes. I plan on using CAST-128.

Thank you very much for helping!

Florian

$\endgroup$
11
  • 2
    $\begingroup$ ... with what mode? $\;$ $\endgroup$
    – user991
    Commented Feb 2, 2015 at 12:37
  • $\begingroup$ We want to use ECB $\endgroup$
    – Florian
    Commented Feb 2, 2015 at 14:19
  • 2
    $\begingroup$ Do you understand the risks of using ECB? Also, do you understand the risks of using a block cipher that has a 64-bit block? $\endgroup$
    – mikeazo
    Commented Feb 2, 2015 at 15:14
  • $\begingroup$ We could use CBC. We went for 64-bit blocks because of the small message in an effort to not produce overhead. would it be better to use overlapping 128-bit blocks? $\endgroup$
    – Florian
    Commented Feb 2, 2015 at 15:21
  • 6
    $\begingroup$ 1) This technique is known as Ciphertext stealing. It's secure in principle, but as @mikeazo already pointed out using ECB and using 64 bit block ciphers is generally a bad idea. 2) There are fancier length preserving encryption schemes. 3) I strongly recommend adding a nonce/IV and a MAC. While these increase the size of the message, the security implications of not having them can be severe. $\endgroup$ Commented Feb 2, 2015 at 15:22

2 Answers 2

1
$\begingroup$
  1. This technique is known as Ciphertext stealing. Ciphertext stealing avoids padding, but only works if the total message size is bigger than one block.

    Ciphertext stealing secure in principle, but as @mikeazo already pointed out using ECB and using 64 bit block ciphers is generally a bad idea.

  2. There are fancier length preserving encryption schemes. FFX mode is one example.
  3. I strongly recommend adding a nonce/IV and a MAC. While these increase the size of the message, the security implications of not having them can be severe.

    In particular the MAC prevents attacks that modify the ciphertext and watch the reaction of the decrypted and nonces/IVs ensure that encrypting the message twice doesn't leak that it's the same.

$\endgroup$
0
$\begingroup$

with CAST-128 your getting the same length output as input anyway. byte 23 and 21 don't overlap there. your just putting the input to that function with the key and it should return an array of bytes that is of the same length as the input. you should not have to worry about those bytes overlapping.

$\endgroup$
1
  • 1
    $\begingroup$ With certain modes, the plaintext must be padded, so then the output would be larger. $\endgroup$
    – mikeazo
    Commented Feb 3, 2015 at 2:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.