2
$\begingroup$

Disclaimer: I do NOT believe AES-ECB to be at all useful for encryption. That said, due to time and bureaucratic issues that I'm not in control of, I need to use AES-ECB.

I get packets of data that are Reed Solomon encoded. Each reed solomon encoded packet has length 255 bytes. On decoding, I get the message which is 223 bytes. (This is RS(255,223) with 8-bit symbols. Each codeword contains 255 code word bytes, of which 223 bytes are data and 32 bytes are parity).

I must now encrypt this data (223 bytes) and then RS encode it again to get back a packet of 255 bytes. However, when using AES ECB in block cipher mode, a byte of zeroes has to be padded in before encryption.

This padding yields a ciphertext that is 224 bytes long. This can't be RS encoded as the packet is required to be 223 bytes.

I realize that hoping this can be solved with a block cipher might be impossible, but any help or workarounds would be really appreciated!

$\endgroup$
2
  • 1
    $\begingroup$ You cannot get a ciphertext of 223 bytes using ECB. It is not a multiple of the blocksize. You either have to use a stream-cipher mode of AES, or encrypt a smaller amount of plaintext, pad the ciphertext to the appropriate size, then encode. $\endgroup$
    – mikeazo
    Apr 30, 2018 at 12:00
  • $\begingroup$ Can you use AES-ECB on a string of 14 unique 16-byte blocks to simulate an AES-CTR one-time pad and xor a 223-byte prefix of that with your data? (Warning: As a one-time pad you can't use it again! If your messages have sequence numbers, use the message sequence number as (say) the low 64-bit half of each 16-byte block and the block sequence number within a message as the high 64-bit half of each block.) $\endgroup$ May 7, 2018 at 21:10

1 Answer 1

1
$\begingroup$

You can use ciphertext stealing as the padding mode and the length won't be increased, see: ECB ciphertext stealing .

$\endgroup$
2
  • $\begingroup$ This is over UDP, so not sure how I'd deal with packet loss in this case. $\endgroup$
    – fraiser
    Apr 30, 2018 at 19:01
  • $\begingroup$ In what manor is CTS related to packet loss? Different that other packet loss? $\endgroup$
    – zaph
    Apr 30, 2018 at 19:14

Your Answer

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

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