2
$\begingroup$

I have to come up with a design for a cryptography system by combining a block cipher and a stream cipher. I can't seem to come up with anything on my own. Can someone point me in the right direction with helpful resources and information to tackle this problem?

$\endgroup$
  • $\begingroup$ why do you need to do this exactly? $\endgroup$ – Richie Frame Mar 29 '15 at 5:22
  • $\begingroup$ It's an assignment $\endgroup$ – fsociety Mar 29 '15 at 5:56
  • 2
    $\begingroup$ how about something like, encrypt data with stream cipher, authenticate with block cipher in some specific mode? $\endgroup$ – Richie Frame Mar 29 '15 at 9:43
  • $\begingroup$ @Richie Frame how about you say this as an answer and not as a comment. $\endgroup$ – Switch Mar 29 '15 at 18:18
6
$\begingroup$

I should begin by noting that this seems like an unusual assignment. I'm not sure why someone would explicitly have a goal of combining block ciphers and stream ciphers.

First, let's summarize the difference between block and stream ciphers, since this may be useful for future readers.

  • Block ciphers are so called because they operate over fixed lengths of plaintext. A block cipher will accept only an input of a specific block size, for example, 16 or 32 bytes, and output the ciphertext block of that size. Because of this input size limitation, block ciphers are usually employed in certain modes of operation that allow a block cipher to accept a plaintext input of arbitrary length. Some naive modes of operation, such as Electronic Codebook Mode (ECB) are considered dangerous and broken. Other modes, such as Cipher Block Chaining Mode (CBC) and Counter Mode (CTR) are considered more secure, but each comes with its dangerous drawbacks. The finickiness of block cipher modes is a big reason why many cryptographers today prefer stream ciphers over block ciphers, since stream ciphers can accept inputs of arbitrary length without any additional engineering. Examples of block ciphers: AES, DES.

  • Stream ciphers can accept an input of arbitrary length. Most of the time, they operate via a keystream design: this means that a stream cipher is usually a CSPRNG (Cryptographically Secure Pseudorandom Number Generator) in disguise, with your encryption key simply acting as the initial seed for the pseudorandom number generator! The output of the pseudorandom generator is called the keystream. The stream cipher proceeds to XOR every byte from the keystream with its corresponding plaintext byte in order, thereby producing the ciphertext. Examples of stream ciphers: Salsa20, Rabbit, NORX (and RC4, which I should warn is considered dangerous and obsolete).

Solution 1: Building a stream cipher using a block cipher

I think one way of addressing this assignment would be to use AES, a block cipher, in counter (CTR) mode. This is because counter mode effectively transforms AES into a stream cipher. Here's how AES in CTR mode works:

CTR mode encryption

Notice that:

  • The AES block input is actually composed of a nonce and a counter. Generally, the nonce is a constant that is only used once per AES encryption key. Reusing a nonce with the same key can be catastrophic. AES has a block size of 16 bytes: the nonce is usually 12 bytes long, leaving 4 bytes for the counter, which is incremented for every block.

  • After we encrypt the block, we then XOR the AES output with our actual corresponding plaintext block, thus obtaining our ciphertext. Notice how this is working like a stream cipher now! We used AES to generate a keystream, which we then XORed with our plaintext, exactly like stream ciphers would generally work.

By using AES in CTR mode, you are using a block cipher as a component of what is ultimately a stream cipher.

Solution 2: Stream cipher for encryption, block cipher for authentication

You could use a stream cipher, such as Salsa20, to encrypt your data, and then authenticate your encrypted data using a Message Authentication Code (MAC) primitive that is dependent on a block cipher, such as Poly1305-AES. That way, you'll have deployed a stream cipher for encryption and a block cipher for authentication.

$\endgroup$
  • $\begingroup$ this is brilliant! Thank you. one question, are there any specific advantages of the system in solution 1? $\endgroup$ – fsociety Mar 30 '15 at 13:55
  • $\begingroup$ for example, does this hybrid system, address vulnerabilities seen in block ciphers and stream ciphers? $\endgroup$ – fsociety Mar 30 '15 at 14:08
  • $\begingroup$ Come on, guy. You said this was for an assignment. Maybe do some part of it yourself? :-) $\endgroup$ – kaepora Apr 12 '15 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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