ulrik@kaizer.se/ code/
blockcipher

cbc uses a chained block cipher crypto to encrypt or decrypt its input. It can take input of any length, and the length of the output will match the input.

Internals

Internally cbc uses a Feistel cipher with a very simple round function, using one simple s-box and xor.

In each round, byte n in Plaintext P, and feistel round j, is processed using and S-Box S, and the result is xored with the key K:

C_n = S(P_n) XOR K_j

In a higher level, cipher block chaining is used where each plaintext is combined with the previous ciphertext before encryption.

If the message length is not an even multiple of the cipher block size, cbc uses ciphertext stealing so that the encrypted message is just as long as the input. When using ciphertext stealing with messages shorter than the block size, the IV will be modified and marked with a (*).

In case IV is not specified when encrypting, it will be randomly generated. The IV in general is not secret but should be used only once with each key.

The security of this crypto is probably mediocre.

Written September 2007

This program is released under the GNU GPL v2 or (at your option) any later version