11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

92 Part II: Designing Secure <strong>Web</strong> <strong>Application</strong>sDo Not Develop Your Own CryptographyCryptographic algorithms <strong>and</strong> routines are notoriously difficult to developsuccessfully. As a result, you should use the tried <strong>and</strong> tested cryptographic servicesprovided by the platform. This includes the .NET Framework <strong>and</strong> the underlyingoperating system. Do not develop custom implementations because these frequentlyresult in weak protection.Keep Unencrypted Data Close to the AlgorithmWhen passing plaintext to an algorithm, do not obtain the data until you are ready touse it, <strong>and</strong> store it in as few variables as possible.Use the Correct Algorithm <strong>and</strong> Correct Key SizeIt is important to make sure you choose the right algorithm for the right job <strong>and</strong> tomake sure you use a key size that provides a sufficient degree of security. Larger keysizes generally increase security. The following list summarizes the major algorithmstogether with the key sizes that each uses:● Data Encryption St<strong>and</strong>ard (DES) 64-bit key (8 bytes)● TripleDES 128-bit key or 192-bit key (16 or 24 bytes)● Rijndael 128–256 bit keys (16–32 bytes)● RSA 384–16,384 bit keys (48–2,048 bytes)For large data encryption, use the TripleDES symmetric encryption algorithm. Forslower <strong>and</strong> stronger encryption of large data, use Rijndael. To encrypt data that is tobe stored for short periods of time, you can consider using a faster but weakeralgorithm such as DES. For digital signatures, use Rivest, Shamir, <strong>and</strong> Adleman(RSA) or Digital Signature Algorithm (DSA). For hashing, use the Secure HashAlgorithm (SHA)1.0. For keyed hashes, use the Hash-based Message AuthenticationCode (HMAC) SHA1.0.Secure Your Encryption KeysAn encryption key is a secret number used as input to the encryption <strong>and</strong> decryptionprocesses. For encrypted data to remain secure, the key must be protected. If anattacker compromises the decryption key, your encrypted data is no longer secure.The following practices help secure your encryption keys:● Use DPAPI to avoid key management.●Cycle your keys periodically.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!