About Cryptography

crypto world

Introduction


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 :

- Confidentiality (using Encryption)
- Integrity (using Hash)

 

Beside this, cryptography also provides solutions for Authentication and Non-repudiation (using Digital Signatures).

 

1 Generalities

1.1 Definitions

  • 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.

 

1.2 Principle

  1. Reverse function is very difficult to get.
  2. 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

  1. Splitmessages into smaller units (sentences, words etc) and substitute those units by others units (used in block mode):
    • KEY = transformation table
  2. Hide the message into a non-significant support (picture, text etc), known as steganography:
    • KEY = dispersion table
  3. 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:

 

2 Encryption

2.1 Generalities

2.1.1 Definition

  • 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.

 

2.1.2 Principle

  • 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 :

  1. The Same key is used to encrypt and decrypt data: symmetric encryption algorithms.
  2. A Couple of keys is used to encrypt and decrypt data: asymmetric encryption algorithms.

 

2.2 symmetric encryption algorithms

symmetric

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.

 

2.3 Asymmetric encryption algorithms

asymmetric

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.

  • Features:
    - 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.

3.1 Definition

  • 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.

 

4 A Specific algorithm: Diffie-Hellman

Used in secured key exchange over insecure channels (e.g secure exchange of shared-key in symmetric algorithm context).

  • 3 DH groups exists:
    1. Group 1 (768 bits) (Not good any more, broken in 1-3 years)
    2. Group 2 (1024 bits)
    3. Group 3 (1536 bits)

 

5 Hashing

hash

5.1 Generalities

5.1.1 Definition

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

mdc

 

5.2.2 HMAC, (Hash Message Authentication Code)

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

hmac

 

 

6 Digital Signature

dsf

6.1 Generalities

6.1.1 Definition

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 ?

Digital signature use the features of both hash function and asymmetric algorithm.

The process is quite simple…

  • Signing process
    1. A hash is generated from the message (= integrity)
    2. Then this hash is encrypted using the sender private key (= authentication & non-repudiation)
    3. This “encrypted digestIS the signature, this signature is sent along with the message

 

  • Verifying process
    1. A hash is generated from the message (= checking message integrity)
    2. Simultaneously the signature (“encrypted digest”) is decrypted using the sender public key, which reveal the digest generated by the sender
    3. 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

  1. Signature is authentic. It convinces the document’s recipient that the signer deliberately signed the document
  2. Signature is unforgeable. It is proof that the signer, and no-one else, deliberately signed the document
  3. Signature is not reusable. It is a part of the document and cannot be moved to a different document
  4. Signature is unalterable. After a document is signed it cannot be altered
  5. 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

  • RSA
    Use SHA-1 or MD5, recommended SHA-256, this is the most used signature. (see this page for information about RSA security breaching)
  • DSA
    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)

 

 

2 thoughts on “About Cryptography

    1. Pier Post author

      Really ??? Thanks for telling me, I did not have any issue but I am not the best person to judge… I’ll try to find a better font.

      What is your browser, and device ?

      Update :
      I changed the font, let me know if it looks better now, if you ever come back here!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site supports SyntaxHighlighter via WP SyntaxHighlighter. It can highlight your code.
How to highlight your code: Paste your code in the comment form, select it and then click the language link button below. This will wrap your code in a <pre> tag and format it when submitted.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">