Cryptographic failures
Impact of cryptographic failures
– Compromises of all data that should be protected
Commo probelms
– Not encrypting sensitive data.
– Using home grown algorithms.
– Insecure use of strong algorithms.
– Continued use of proven weak algorithms.
– Hard coding keys, and storing keys in unprotected stores.
Sensitive data exposure prevention
Cryptographic algorithm type classes
– SymmetricAlgorithm
– AsymmetrickAlogorithm
– HashAlgorithm
Symmetric Alogrithms
Types of symmetric algorithms
Symmetric algorithms classes
DES, TripleDES, RC2, Rijndael, AES
Encryption/Decryption using Symmetric Algorithm
Encrypt
* Generate Random Key
* Generate Initialization Vector (IV)
* Use CreateEncryptor() to produce ciphertext
* Store both the Key and IV into DB
Decrypt
* Retrieve Key and IV from DB
* Use CreateDecryptor() to produce plaintext
Asymmetric Algorithm
– Is also known as public key cryptography.
– Uses two keys instead of one.
– Public key systems typically work using difficult math problems known as trapdoor functions
- Generally 100-1000 times slower than symmetric algorithms
Asymmetric Algorithm classes
RSA, DSA
Encryption and decryption using RSA Algorithm
– Create instance of RSA CSP (new keys generated by default).
– Import keys (if required)
– Convert input string to byte[]
– Encrypt
– Resulting byte[] is cipher text
– Create instance of RSA CSP (new keys generated by default).
– Import keys (private)
– Decrypt
– Resulting byte[] is plain text
- Convert to string
Problems of symmetric algorithm and asymmetric algorithm
Symmetric algorithm vs asymmetric algorithm
Symmetric
◼ Uses ONE key to:
❑ Encrypt data
❑ Decrypt data
◼ Is fast & efficient
Asymmetric
◼ Uses TWO related keys:
❑ Public key to encrypt data
❑ Private key to decrypt data
❑ OR vice versa
◼ Is more secure than symmetric encryption
◼ Is slower than symmetric encryption
Hashing
A hash is a special mathematical function that performs one-way [encryption].
- Creates digest
- Irreversible
Common uses of hasing
–storing users’ passwords
* hackers can decrypt the passwords
–ensuring message integrity.
* To verify if message or file remains original and not edited
Hash Algorithm classes
SHA1, SHA256, SHA384, SHA512, MD5, KeyedHashAlgorithm
Hashing in .NET
Use salted passwords
Signing Hash
Verify Hash