开发者

how can I encrypt a 300-bit plaintext using a block cipher with a block size of 128 bits in ECB mode

开发者 https://www.devze.com 2022-12-23 18:24 出处:网络
how can I encrypt a 300-bit plaintext using a block cipher with a block size of 128 bits in ECB m开发者_JAVA技巧ode.First you have do some padding. The most simple padding would be to fill your plaint

how can I encrypt a 300-bit plaintext using a block cipher with a block size of 128 bits in ECB m开发者_JAVA技巧ode.


First you have do some padding. The most simple padding would be to fill your plaintext with zeros up to size 3*128 bits. Now you can encrypt it with your block cipher in three steps, first encrypting bits 0 to 127, then 128 to 255 and last 256 to 383. That's ECB.

For decryption you do the reverse. Decrypt the single blocks, then remove the padding.


First a question: Why do you want to use ECB for encrypting data larger than the block size? I would say that using ECB for len(cleartext) > block size is not recommended.

If you can live with ciphertext expansion due to padding on the last block then you can do as tangens recommends.

If you need the len(ciphertext) == len(cleartext) you need to look at cipherhext stealing versions of ECB (or CBC):

http://en.wikipedia.org/wiki/Ciphertext_stealing http://csrc.nist.gov/publications/nistpubs/800-38a/addendum-to-nist_sp800-38A.pdf

0

精彩评论

暂无评论...
验证码 换一张
取 消