Maximizing Security

Microsoft Enterprise Library 5.0

DropDown image DropDownHover image Collapse image Expand image CollapseAll image ExpandAll image Copy image CopyHover image

Two important points you should consider when you use the Cryptography Application Block are how you are going to manage symmetric encryption keys and which hashing algorithm or symmetric encryption algorithm you are going to use.

Managing and Distributing Keys

Symmetric encryption encrypts and decrypts data with the same key. Both the application that sends the data and the application that receives the data must possess this key. Any other application that can access this key can also decrypt the data that was encrypted with the key. This means that attackers can decrypt encrypted data if they can obtain the encryption key. Also, attackers can prevent you from reading your encrypted data by deleting or corrupting your key file. A key file is an encrypted text file that contains your keys. You must carefully manage your shared keys. Consider the following guidelines to help you protect your keys:

  • Protect your keys with access control lists (ACL). Only grant the necessary permissions to the identities that require access to the key file.
  • Do not configure your computer to allow remote debugging when that computer runs in a high-risk environment. An example of such a computer is a Web server that allows anonymous access.

The Cryptography Application Block stores each key in a separate file on the local computer. The <securityCryptographyConfiguration> section in the configuration source contains the absolute path to each key file. For example, when you use the default configuration source, the application configuration file contains the absolute path to the keys. To protect the key, the Cryptography Application Block uses DPAPI to encrypt it before it writes it to the file. If you also use entropy, you must protect the storage location of the entropy value. (Entropy is a random value that makes deciphering the file more difficult.) For example, you can use ACLs to set permissions on a file that contains the entropy value. If your application requires you to use an alternative form of key management, such as specialized hardware or a key container, you must modify the block source code to support your requirements. For information about modifying the block, see Modifying the Cryptography Application Block.

Selecting an Encryption Algorithm

An encryption algorithm provides no security if the encryption algorithm is cracked or is vulnerable to brute force cracking. Custom algorithms are particularly vulnerable if they have not been tested. Instead of using them, use published, well-known encryption algorithms that have withstood years of rigorous attacks and scrutiny.

Recommended key lengths change as computing power grows. Encryption key lengths that range from 128 bits to 256 bits are currently considered to be secure. Most modern algorithms use keys that are at least 128 bits long.

For hashing algorithms, the SHA256Managed algorithm is recommended. This algorithm uses a hash size of 256 bits. The hash size of SHA1Managed hashing algorithm is 160 bits. This algorithm is acceptable but not encouraged. The MD4 and MD5 algorithms are no longer recommended.

For symmetric algorithms, advanced encryption standard (AES), also known as Rijndael, is recommended. This algorithm supports key lengths of 128, 192, 256 bits. The data encryption standard (DES) algorithm is not recommended.