# What is a block cipher?

I have read about block ciphers, but I do not understand the topic completely.

Is a block cipher a way to send data or a way to encrypt data?

How is the data divided into multiply blocks before it is sent? Is the data partitioned before the encryption process or afterwards?

How long are the blocks? Can I choose any block size?

-

As its name indicates, a block cipher is an algorithm to encrypt (with a secret key) plaintexts in chunks of a certain fixed block size. For practical reasons, software of a block cipher has only one or a few user-choosable block sizes, e.g. 128 bits, 256 bits, etc. The given plaintext is divided into such blocks to be processed, resulting in a sequence of blocks of the corresponding ciphertext. All this IMHO should be very clear to you from reading any textbook on cryptography.

-
thank you for your response. Can I say RSA algorithm type of block cipher – almodawan Jan 24 '13 at 17:41
Can I say DES cryptography algorithm type of block cipher. – almodawan Jan 24 '13 at 17:53
DES is clearly a block cipher(but a weak one). RSA generally isn't considered a block cipher, even if it shared some properties with one. – CodesInChaos Jan 24 '13 at 18:06

A block cipher is any cipher that works(encrypts, decrypts) on data in blocks (more than just one bit or one byte). A stream cipher is a cipher that works on the data one bit or byte at a time.

For example, DES is a block cipher because it works on the data in 64 bit chunks. This means that when you want to encrypt something with DES, you must first break it into 64 bit chunks, and encrypt each chunk with DES. Same with decryption.

An example of a stream cipher is RC4. If you want to encrypt using RC4, you need to encrypt each byte individually. There is no need to create chunks of that data, because RC4 works on the data one bit at a time.

You cannot choose a blocksize, because it's generally dictated by the algorithm you choose. How you send the data is not related to how you encrypt the data. That means a block cipher only says that you need to encrypt in a block, but says nothing about how you should transmit the data.

-
Thank you Mr Oleksi for your response. If I have data length of 512 bit and I have a 256-bit key length and encryption result rather (plain text) is 256 bit after decrypt process. I able to encrypt data has max length 256 bits. I can say that the length of block cipher is 256 bits. Because should be divide 512 bit to two chunk Each chunk has 256 bits. If that is true I am hope. please response me. – almodawan Jan 26 '13 at 17:52
Well the block size and the keysize can be different. The blocksize is always the same for a given algorithm. If you have 512 bits of data and your block size is 256, you will need to break up the data into two chunks for encryptio/decryption. – Oleksi Jan 26 '13 at 19:51
Thanks a lot MrOleksi. on this clarification is useful.Just have a simple question when the data size is less than 256-bit how to deal with it. – almodawan Jan 26 '13 at 20:17
Typically that block gets padded with '0' until it's the correct blocksize. – Oleksi Jan 26 '13 at 22:29
@Oleski Well, that only works if you are guaranteed your message never contains bytes with zeros, if that's not the case your padding will be ambiguous. See this link for more general ways to do it. – Thomas Jan 27 '13 at 9:00

Formally, a block cipher is a kind of cryptographic primitive. For a given block length $n$ and key-length $k$, each key $K \in \{0,1\}^k$ somehow chooses (deterministically) a permuation $E_K : \{0,1\}^n \to \{0,1\}^n$, such that both $E_K$ and its inverse $D_K = {E_K}^{-1}$ are efficiently computable, given $K$. (We can define this over non-binary alphabets, too.)

This means, each $k$-bit key maps $n$-bit blocks on (other) $n$-bit blocks and back, in a way that is always identical. The classical Caesar-cipher could be seen as a block cipher

A block cipher itself is not yet usable for encryption – for that, we need to wrap it in a mode of operation. This essentially builds an encryption scheme based on the block cipher.

The simplest one – split the message in blocks of the right size and then pass each of them through the block cipher (ECB mode) – is not very secure, if you have messages longer than one block or multiple messages using the same key. There are many other modes, with slightly different properties.

The block size is defined by the algorithm. While there are some algorithms (or actually algorithm families) which support multiple block sizes, you still have to chose one of them.

-