Game Development Reference
In-Depth Information
Table 16.2 Cipher Modes Available in .NET 2.0 (continued)
Cipher Mode
This cipher mode (Electronic Code Book) encrypts each block individually.
Any blocks of plain text that are in the same message or in a different
message using the same key will produce identical cipher text blocks.
If the plain text contains a large amount of repetition, it is quite possible
to break the cipher one block at a time. It is also possible to substitute and
exchange cipher blocks without detection. If a single bit in the cipher text
is corrupted, the entire corresponding plain text will also be corrupted.
This cipher mode (Output Feedback Mode) processes small amounts of
plain text instead of an entire block at a time. This cipher mode is very
similar to CipherMode.CFB except the shift register is filled differently.
If a bit in the cipher text is corrupted, the corresponding bit of plain text
will also be mangled. If there are missing bits from the cipher text, the
plain text will be corrupted from that point on.
CTS and OFB are defined but not currently implemented by any algorithms in the .NET framework.
Initialization Vectors
Symmetric algorithms will encrypt the same input block into the same output
block based on the key. This is a weakness that can be potentially exploited by
malicious attackers if they determine the structure of the data. Attackers could
locate patterns and eventually reverse-engineer the private key.
In order to protect against this, the algorithms in the .NET Class Framework per-
form data chaining, where information from the previously encrypted block is used
to encrypt the current block. This technique requires what is known as an initializa-
tion vector (IV) to perform the encryption with increased cryptographic variance.
There are a couple of ways to generate an initialization vector, but one approach is
to run a hashing algorithm on a secret phrase and use a segment of the result as
the encryption IV.
The following code shows how to do this:
using System.Security.Cryptography;
static public byte[] GenerateIV(byte[] key, int size)
Search Nedrilad ::

Custom Search