Table of Contents
- 1 Generalities
- 2 Encryption
- 3 Block & Stream ciphers
- 4 A Specific algorithm: Diffie-Hellman
- 5 Hashing
- 6 Digital Signature
This page will help you having an overview of some cryptographic concepts and well-known cryptographic tools such as Digital signature and Asymmetric keys based algorithm. Cryptography is used in, among others, IT Network security to achieve, 2 out of 3 goals specified in CIA triad :
- Crypt : Is the process of transforming “clear” data into “cipher” data, using a key (shared or not) and a cryptographic algorithm.
- Decrypt : Is the process of transforming “cipher” data into “clear” data, using a key (shared or not) and a cryptographic algorithm.
- Breaking encryption ( cryptanalyze ) : Is the process of transforming “cipher” data into “clear” data, without the knowledge of encryption key.
- Authentication : Is the process of verifying the identity or other attributes claimed by or assumed of an entity (user, process, or device)
- Integrity : Within the cryptography field, is the property that data has not been changed, destroyed, or lost in an unauthorized or accidental manner.
- Confidentiality : Is the property that information is not disclosed to system entities (users, processes, devices) unless they have been authorized to access the information.
- Non-repudiation : Is the meaning to ensure that the sender of information is provided with proof of delivery and the recipient is provided with proof of the sender’s identity, so neither can later deny having processed the information.
- Reverse function is very difficult to get.
- Kerckhoffs principle : A cryptosystem should be secure even if everything about the system, except the key, is public knowledge
1.3 Desirable features
- Resistance to cryptanalyze attacks
- Variable (long) key lengths and scalability.
- Avalanche effect (small changes in plaintext cause substantial changes in cipher text)
- No export or import restrictions
- Stability of the algorithm (should not be changed often)
- Simple and fast to execute
1.4 3 differents approaches
- Splitmessages into smaller units (sentences, words etc) and substitute those units by others units (used in block mode):
- KEY = transformation table
- Hide the message into a non-significant support (picture, text etc), known as steganography:
- KEY = dispersion table
- Transformfix size units of the message into cipher text (used in stream mode):
- KEY = is part of the tranformation function
1.5 Where is Cryptography used ?
Cryptography ensure data confidentiality & integrity over untrusted networks, traffic source authentication and transaction non-repudiation. You will then find cryptographic concepts used in:
- Encryption (for confidentiality)
- Hashing (for integrity)
- HMAC (for integrity + authentication)
- Digital Signatures (for authentication + non-repudiation)
- Encrypting is the process of transforming clear data into cipher data, using a key and a cryptographic algorithm.
- Decrypting is the process of transforming cipher data into clear data, using a key and a cryptographic algorithm.
- Encryption provides confidentiality.
- Reverse function is very difficult to get.
- Desirable features :
– Resistance to cryptographic attacks
– Variable (long) key lengths and scalability.
– Avalanche effect (small changes in plain text cause substantial changes in cipher text)
– No export or import restrictions
– Stability of the algorithm (should not be changed often)
– Simple and fast to execute
2.1.3 Encryption keys
A key is a required parameter to an encryption algorithm.
There is two different kind of keys :
- The Same key is used to encrypt and decrypt data: symmetric encryption algorithms.
- A Couple of keys is used to encrypt and decrypt data: asymmetric encryption algorithms.
Also known as shared-key algorithm, it uses the same key for encryption and decryption. It mainly uses SUBSTITUTION (reverse function complex) & PERMUTATION (avalanche effect)
- Features :
– Sender and receiver must share the same key.
– Usual key length of 40-168 bits (80 bits is considered “safe enough”, 128 bits is considered “secure”).
– Used in STREAM mode.
- ↑ Key point
– Usually quite fast (hardwired, dedicated chips ) (Used intensively to encrypt data flows “on the fly” (stream mode)).
- ↓ Weak spot
– Key management may be an issue (see implementation).
– Implementation: for N potentially connected nodes you need N(N-1)/2 secret keys.
- Examples of well-known algorithms using symmetric key:
– DES (3DES); IDEA; AES ; Blowfish
– One Time Pad (OTP) : A random key used only once.used to generate a cipher text with NO relation to the clear text.
Also known as public-key algorithm, it uses 2 differents keys for encryption and decryption, a *Public key* (can usually be made public) and a Private key (MUST stay private). Based on complex computational problem, which address the “reverse-function” problem.
– Sender and receiver have differents keys.
– Usual key length of 512-2048 bits (512 bits is considered “safe enough”, 1024 bits is considered “secure”).
– Used in low volume crypto services (signatures, key exchange): Used in BLOCK mode.
- ↑ Key point
– Key management (one of the key can usually be made public) (see also Digitals Certificates and Public Key Infrastructure)
- ↓ Weak spot
– Relatively slow (compared to symmetric)
- Examples of well-known algorithms using asymmetric key:
– RSA, DSA, ECC
3 Block & Stream ciphers
Blocks and Stream ciphers describes the implementation of a given algorithm.
- Block cipher
A block cipher is a type of symmetric-key encryption algorithm that transforms a fixed-length block of plaintext data into a block of cipher text data of the same length
(ECB ; CBC ; PCBC ; OFB)
- Stream cipher
A stream cipher is a type of symmetric-key encryption algorithm. Stream ciphers can be designed to be exceptionally fast, much faster than any block cipher. While block ciphers operate on large blocks of data, stream ciphers typically operate on smaller units of plaintext, usually bits.
→The encryption of any particular plaintext with a block cipher will result in the same ciphertext when the same key is used.
→With a stream cipher, the transformation of these smaller plaintext units will vary, depending on when they are encountered during the encryption process.
Used in secured key exchange over insecure channels (e.g secure exchange of shared-key in symmetric algorithm context).
- 3 DH groups exists:
- Group 1 (768 bits) (Not good any more, broken in 1-3 years)
- Group 2 (1024 bits)
- Group 3 (1536 bits)
Hashing is the process of taking an arbitrary block of data and returning a fixed-size bit string: the (cryptographic) hash value, is such that an accidental or intentional change to the data will change the hash value.
Based on one-way mathematical functions.
The generated “fixed-size string” is often called Digest, message digest, fingerprints, checksums or simply hash.
Hashing provides an integrity control means.
5.1.2 Desirable features
- Reverse function impossible (no way to recover the clear text from a checksum).
- Avalanche effect (small changes in data cause substantial changes in digest).
- Weak / strong collision resistance (see here for an example of proved weak collision)
Note : weak collision is when you can find two strings (of your choice) that gives the same hash, when strong collision describe the capacity of finding a string that will give you the same hash of another given string.
5.1.3 Classic usage
- Data-base indexing (indexing a shorter string is faster).
5.1.4 Security usage
- Message integrity check (checksums).
- password management ( shadow file in Unix-like system).
5.1.5 Common hash algorithms
- MD5 : created in 1992, generate a 128 bits hash, in 1996 it has been proved that collisions are possible, in 2004 it took 1h on IBM cluster to find collision through analytic attack, since then MD5 is not recommended in high security context, (see Xiaoyun Wang; Hongbo Yu (2005).”How to Break MD5 and Other Hash Functions” )
- SHA-1 : created in 1993 based on the NSA SHA-0, generate a 160 bits hash, “only” 2ˆ63 trials to the first collision, improved versions:
SHA-256, SHA-384, SHA-512 : respectively generating 256, 384, 512 bits hashes.
5.2 Protocols using hash functions
5.2.1 MDC, (Message Digest Code)
Provides integrity but vulnerable to Man-in-the-middle (MIM) attack.
Process : A checksum is calculated from the message (clear text), then the message (clear text) is sent along with the checksum. When the receiver receive the message he then compute a new checksum and compare it with the one provided along with the message, if it matches this means that the message is the same as the one from which the first provided checksum was computed from.
Note : This, by no means, ensure that the received message is the same as the sended message ! (Man-In-the-Middle attack)
- MDC protocol process
Provides integrity as well as authentication by adding a shared-secret-key as the Secret key is known only to sender and receiver.
Process : A checksum is calculated from the message (clear text) and then encrypted using a secret shared-key (which prevent anyone but someone with the shared-key from alterating the message), then the message (clear text) is sent along with the checksum. When the receiver receive the message he then decrypt the checksum using the shared-key and compute a new checksum to compare it with the one provided along with the message, if it matches this means that the message is strictly the same as the one that was sent, and the sender is someone that has the shared-key.
Note : This is secure as long as you can ensure the privacy of the shared-key : Only people who are supposed to have the key should have it !
- HMAC protocol process
A digital signature is a structured data associated with a document to ensure its:
- Integrity, authentication, non-repudiation.
6.1.2 How digital signature works ?
The process is quite simple…
- Signing process
- A hash is generated from the message (= integrity)
- Then this hash is encrypted using the sender private key (= authentication & non-repudiation)
- This “encrypted digest” IS the signature, this signature is sent along with the message
- Verifying process
- A hash is generated from the message (= checking message integrity)
- Simultaneously the signature (“encrypted digest”) is decrypted using the sender public key, which reveal the digest generated by the sender
- Finally those two digest are compared :
→They are identical : the message is just as it was sent (integrity), AND the sender is the holder of the used public key ( authentication & non-repudiation ).
→They are different : either the message has been altered during its transit or the sender is not the holder of the public key, or both of it!
As you may have noticed, there is still a security issue regarding the identity of the public key holder, this problem is easily fixed using a digital certificate to deploy the public key.
Note : Using a digital signature does not encrypt the message itself. If one wants to ensure the privacy of the message, it must also encrypt it using recipient’s public key. Then only the recipient can read the message by decrypting it with his private key.
6.1.3 Desirable features
In addition to the listed security features above, digital signature may:
- Be easy to generate
- Can be checked by anybody
- Attached to a single document (no reusability)
6.1.4 Basic properties
- Signature is authentic. It convinces the document’s recipient that the signer deliberately signed the document
- Signature is unforgeable. It is proof that the signer, and no-one else, deliberately signed the document
- Signature is not reusable. It is a part of the document and cannot be moved to a different document
- Signature is unalterable. After a document is signed it cannot be altered
- Signature cannot be repudiated. Signer cannot claim later that they did not sign it.
6.1.5 What should be signed ?
- Encrypt all data with asymmetric algorithm ?
Too heavy / consuming → not used
- Generate a hash from data and encrypt this hash
Used in all cryptographic solution
6.1.6 Signature example
Use SHA-1 or MD5, recommended SHA-256, this is the most used signature. (see this page for information about RSA security breaching)
Use SHA-1 on 320 bits (2×160 bits), does not use RSA as encryption algorithm (it is good to use ≠ algorithm within the same message)