Encryption algorithms such as Blowfish,AES,RC4,DES and Seal are implemented in one of two categories of ciphers. What are the advantages/disadvantages to the type of ciphers?
While both are symmetric ciphers, stream ciphers are based on generating an "infinite" cryptograpic keystream, and using that to encrypt one bit or byte at a time (similar to the one-time pad), whereas block ciphers work on larger chunks of data (i.e. blocks) at a time, often combining blocks for additional security (e.g. AES in CBC mode).
- Stream ciphers are typically faster than block, but that has it's own price.
- Block ciphers typically require more memory, since they work on larger chunks of data and often have "carry over" from previous blocks, whereas since stream ciphers work on only a few bits at a time they have relatively low memory requirements (and therefore cheaper to implement in limited scenarios such as embedded devices, firmware, and esp. hardware).
- Stream ciphers are more difficult to implement correctly, and prone to weaknesses based on usage - since the principles are similar to one-time pad, the keystream has very strict requirements. On the other hand, that's usually the tricky part, and can be offloaded to e.g. an external box.
- Because block ciphers encrypt a whole block at a time (and furthermore have "feedback" modes which are most recommended), they are more susceptible to noise in transmission, that is if you mess up one part of the data, all the rest is probably unrecoverable. Whereas with stream ciphers bytes are individually encrypted with no connection to other chunks of data (in most ciphers/modes), and often have support for interruptions on the line.
- Also, stream ciphers do not provide integrity protection or authentication, whereas some block ciphers (depending on mode) can provide integrity protection, in addition to confidentiality.
- Because of all the above, stream ciphers are usually best for cases where the amount of data is either unknown, or continuous - such as network streams. Block ciphers, on the other hand, or more useful when the amount of data is pre-known - such as a file, data fields, or request/response protocols, such as HTTP where the length of the total message is known already at the beginning.
A block cipher is a versatile algorithm which implements a key-dependent permutation of values which are sequences of a fixed number of bits (called "blocks"). It can be used for various roles in many kinds of cryptographic protocols. One such role is bulk encryption of long streams of data; to achieve such a thing, the block cipher must be used with an appropriate mode of operation (aka "chaining mode"), the traditional one being CBC, and the trendy newer mode being CTR.
A stream cipher is a specialized algorithm for the purpose of bulk encryption of long streams of data. The idea is that, by forfeiting the versatility of the block cipher, it would be possible to create a more efficient algorithm (i.e. something which encrypts data faster).
Both block ciphers with a stream-oriented encryption mode, and stream ciphers, may run into security issues if the same key is used twice, for two distinct streams, without having an appropriate, unique/random enough Initialization Vector. For CBC encryption, the IV must be a new uniformly random sequence of bits, of the same size than a block, for each new message. Good stream ciphers also accept an IV. A traditional stream cipher called RC4 is IV-less (its specification does not state where or how an IV could be inserted), which led to much mayhem and gave a bad name to the concept of stream ciphers.
For newer, more secure (and faster) stream ciphers, see the eSTREAM portfolio. These algorithms have gone through a rather thorough analysis by many cryptographers and are considered "quite secure".
A stream cipher can be converted into a Pseudorandom Number Generator by encrypting a long sequence of bytes of value zero. Actually, many (but not all) stream ciphers internally work by being a PRNG, generating a long sequence of key-dependent pseudo-random bytes, which is subsequently combined (by bitwise XOR) with the data to encrypt (or decrypt), so encrypting zero bytes is then equivalent to omitting the XOR altogether. Therefore, stream ciphers are often used as custom PRNG.
One advantage of stream ciphers that haven't been mentioned previously is that they don't need padding (block ciphers operates on complete blocks, so if you don't have enough data you must generate some more somehow). And surprise (not really, cryptography is the field where Murphy's everywhere), padding can be done wrong, as exemplified for example in Practical Padding Oracle Attacks.
Also security of block ciphers pretty much depend on their mode of operation, you still see ECB used here and there at times and it's not much better than no crypto at all.
Basically you can't say one is better than the other, one got to look at a complete cryptosystem to make a security judgement.
Stream Ciphers crypts the plaintext data with a random stream of bit (usually with a XOR because it can be reversed easily). If you have a 128bit data, you will use a 128 bit psedurandom strem (your key) to encrypt.
Block Ciphers crypts the plain text data a block at a time with the same transformation (based on the key). So you have your 128bit data, the cipher breaks it in blocks (like 4 block of 32 bits) and apply the same transformation to every block obtaining 4 encrypted blocks, that combined will form the final cryptogram.
Of course because of this Block Cyphers are safer but expensive to use in terms of hardware complexity involved. Stream Ciphers are faster and "cheap" but they can be susceptible to security problems if implemented incorrectly.
Data (the stuff to be encrypted) usually comes in streams. To encrypt it, we need to employ a stream cipher, that is, an encryption algorithm suitable for use on a stream of data. A stream is a sequence of bits (or bytes) of arbitrary, varying, or unspecified length.
The best ciphers we have invented so far are usually block ciphers. A block cipher is capable of encrypting a single fixed-sized block of data; and, by the evidence around us, apparently it is easier to build good block ciphers than stream ciphers.
Good news, though. By using a given block cipher in some particular patterns (a "mode of operation"), and with the aid of particular padding strategies, we can transform any block cipher into a stream cipher! That means we can use the better ciphers, which are block ciphers, to encrypt any data, the majority of which comes in streams.