Professional Documents
Culture Documents
Manu Carus
http://www.ethical-hacking.de/
mailto:manu.carus@ethical-hacking.de
Table of Content
1
CRYPTOGRAPHY
.....................................................................................................................................
3
2
SECURE
ALGORITHMS
...........................................................................................................................
4
3
LIBRARIES
AND
FRAMEWORKS
.........................................................................................................
5
3.1
3.2
3.3
3.4
OPENSSL
..................................................................................................................................................
5
JAVA
CRYPTOGRAPHY
ARCHITECTURE
...................................................................................................
6
.NET
.........................................................................................................................................................
7
CRYPTOAPI
AND
CAPICOM
...................................................................................................................
8
CRYPTOGRAPHY
.......................................................................................................................................
9
RANDOM
NUMBERS
..................................................................................................................................
9
HASHING
...................................................................................................................................................
9
MESSAGE
AUTHENTICATION
CODES
.......................................................................................................
9
SYMMETRIC
ENCRYPTION
........................................................................................................................
9
ASYMMETRIC
ENCRYPTION
...................................................................................................................
10
DIGITAL
SIGNATURE
..............................................................................................................................
10
KEY
AGREEMENT
....................................................................................................................................
10
CRYPTOGRAPHY
.....................................................................................................................................
10
HASHING
.................................................................................................................................................
10
SYMMETRIC
ENCRYPTION
......................................................................................................................
10
ASYMMETRIC
ENCRYPTION
...................................................................................................................
10
Cryptography
Definitions
Cryptography is the science of hiding information.
The term is contrasted with cryptanalysis where the objective is to analyze and break encryption
methods which have hitherto been considered secure.
Both these sciences are branches all cryptology.
Objectives of cryptography
Secrecy
"keeping information secret
Sensitive data must be concealed from others. Only explicity authorized persons must be able to read
confidential data or obtain knowledge about its content.
Integrity
knowing that information hasnt been tampered with
The recipient of a message must be able to ascertain wether the message was modified after it was
generated and before it was received.
Authentication
knowing the origin and destination of information
Both the originator and recipient of a message must be unambiguously identifiable.
Non-Repudiation
knowing that information, once sent, cannot be retracted or denied.
The originator of a message must not be able to repudiate his authorship. It must be possible to
substantiate authorship to third parties.
Requirement
A secure application must achieve these four objectives of cryptography!
Secure
Algorithms
Length1
Algorithm
RSA-2048
Asymmetric Encryption
2048 bit
256 Bytes
3DES
Cipher
112 bit2
14 Bytes
AES-128
Cipher
128 bit
16 Bytes
AES-192
Cipher
192 bit
24 Bytes
AES-256
Cipher
256 bit
32 Bytes
Blowfish
Cipher
128 bit
16 Bytes
Twofish
Cipher
DSA
Digital Signature
1024 bit
128 Bytes
ECDSA
Digital Signature
RSA-2048
Digital Signature
2048 bit
256 Bytes
RIPEMD-160
Hash
160 bit
20 Bytes
SHA-256
Hash
256 bit
32 Bytes
SHA-384
Hash
384 bit
48 Bytes
SHA-512
Hash
512 bit
64 Bytes
Diffie-Hellman
Key Agreement
1024 bit
128 Bytes
AES-CMAC
128 bit
192 bit
256 bit
16 Bytes
24 Bytes
32 Bytes
HMACSHA256
256 bit
64 Bytes
MAC-3DES-CBC
112 bit
14 Bytes
PBKDF2
arbitrary
arbitrary
Last revised: 12/2012
(bold recommendation)
1
2
3.1 OpenSSL
Application
Command
Random Numbers
openssl rand
Hashing
Message
Authentication
Codes
alg {sha256,
sha384,
sha512,
ripemd160}
Symmetric
Encryption
cipher {aes128,
aes192,
aes256,
aes-128-cbc,
aes-192-cbc,
aes-256-cbc,
bf,
bf-cbc,
blowfish,
des3}
Asymmetric
Encryption
openssl rsautl
Hybrid
Encryption
cipher {aes128,
aes192,
aes256,
des3}
Digital Signature
openssl dsaparam
cipher {aes128,
aes192,
aes256,
des3}
Key Agreement
openssl dhparam
Parameter
for DSA:
alg
{dss1}
for RSA:
alg
{sha256,
sha384,
sha512,
ripemd160}
algorithm { }
javax.crypto.Cipher
AES
AESWrap
Blowfish
DESede
DESedeWrap
DSA
ECDSA
HmacSHA256
HmacSHA384
HmacSHA512
RSA
SHA1PRNG
SHA-256
SHA256withECDSA
SHA256withRSA
SHA-384
SHA384withECDSA
SHA384withRSA
SHA-512
SHA512withECDSA
SHA512withRSA
javax.crypto.KeyGenerator
javax.crypto.Mac
javax.crypto.SecretKeyFactory
java.security.AlgorithmParameters
java.security.AlgorithmParameterGenerator
java.security.KeyFactory
java.security.KeyPairGenerator
java.security.MessageDigest
java.security.SecureRandom
java.security.Signature
3.3 .NET
Class
Version
System.Security.Cryptography.AesManaged
.NET 3.0
System.Security.Cryptography.AesCryptoServiceProvider
.NET 3.0
System.Security.Cryptography.DSACryptoServiceProvider
.NET 2.0
System.Security.Cryptography.ECDiffieHellmanCng
.NET 3.0
System.Security.Cryptography.ECDsaCng
.NET 3.0
System.Security.Cryptography.KeyedHashAlgorithm.HMACRIPEMD160
.NET 2.0
System.Security.Cryptography.KeyedHashAlgorithm.HMACSHA256
.NET 2.0
System.Security.Cryptography.KeyedHashAlgorithm.HMACSHA512
.NET 2.0
System.Security.Cryptography.KeyedHashAlgorithm.MACTripleDES
.NET 2.0
System.Security.Cryptography.ProtectedData
.NET 2.0
System.Security.Cryptography.ProtectedMemory
.NET 2.0
System.Security.Cryptography.RijndaelManaged
.NET 2.0
System.Security.Cryptography.RIPEMD160Managed
.NET 2.0
System.Security.Cryptography.RNGCryptoServiceProvider
.NET 2.0
System.Security.Cryptography.RSACryptoServiceProvider
.NET 2.0
System.Security.Cryptography.SHA256Managed
.NET 2.0
System.Security.Cryptography.SHA384Managed
.NET 2.0
System.Security.Cryptography.SHA512Managed
.NET 2.0
System.Security.Cryptography.TripleDESCryptoServiceProvider
.NET 2.0
System.Security.SecureString
.NET 2.0
ALG_ID { }
CryptCreateHash()
CALG_3DES
CALG_3DES_112
CALG_AES
CALG_AES_128
CALG_AES_192
CALG_AES_256
CALG_DSS_SIGN
CALG_ECDSA
CALG_HMAC
CALG_MAC
CALG_RSA_SIGN
CALG_SHA_256
CALG_SHA_384
CALG_SHA-512
CryptDecrypt()
CryptEncrypt()
CryptDecryptAndVerifyMessageSignature()
CryptDecryptMessage()
CryptEncryptMessage()
CryptGenKey()
CryptGenRandom()
CryptHashData()
CryptHashMessage()
CryptHashPublicKeyInfo()
CryptHashSessionKey()
CAPICOM_PROV_MS_DEF_
DSS_DH_PROV
CryptProtectData()
CryptProtectMemory()
CryptSignAndEncryptMessage()
CryptSignHash()
CryptSignMessage()
CryptSignMessageWithKey()
CryptUnprotectData()
CryptUnprotectMemory()
CryptVerifyDetachedMessageHash()
CryptVerifyDetachedMessageSignature()
CryptVerifyMessageHash()
CryptVerifyMessageSignature()
CryptVerifyMessageSignatureWithKey()
CryptVerifySignature()
Best Practices
4.1 Cryptography
Cryptographic agility: Configure and safeguard the used algorithms.
4.3 Hashing
Use SHA-256.
Use hash values that are 256 bits long or longer ( 32 Bytes).
Use hashing rather than encryption.
Use salted hashing rather than hashing when processing small input (e.g. passwords).
Compare long inputs by comparing the hash values.
Use hashing for integrity checks.
Transmit hash values only in encrypted form.
Use digital signature rather than hashing (whenever possible).
Worst Practices
5.1 Cryptography
Do not apply security by obscurity.
Do not make use of ad-hoc algorithms.
5.2 Hashing
Do not use MD5.
Do not use SHA-1.
Rules of Thumb
Computing cryptographically secure random numbers requires approximately 10 times more effort
than computing classic random numbers.
6.2 Hashing
76
The calculation of appropriate Diffie-Hellman parameters takes much time and must therefore
take place long before a communication channel between sender and receiver is established.
Severability
Clauses
If the underlying environment, the software, framework or library which is used does not support
any cryptographically secure algorithm and if, under the given circumstances, no other solution is
possible, a cryptographically weak algorithm should be used rather than dispensing with
protection entirely.
If algorithms which are classified as secure and recommended in this document are subsequently
broken, the recommendations of the Federal German Office for Information Security (BSI) and the
Commandment of caution apply until this document is next updated.
8 List
of
abbreviations
3DES
AES
BF
Blowfish
CAPICOM
CBC
CFB
CMAC
CNG
DESede
DH
Diffie-Hellman
DSA
DSS
ECB
ECDH
ECDSA
GUID
HMAC
IV
Initialization Vector
JCA
MAC
MD
Message Digest
MITM
Man-in-the-Middle
OFB
PBKDF
PGP
PKCS
PKI
PRNG
RC
RIPEMD
RSA
SHA
S/MIME
SSL
TLS
TRNG