Sunday, January 22, 2017

Cryptography in a minute! (how to encrypt\decrypt data of Wired or Wireless)


Cryptography is the art and science of secure communication. “kryptos” is Greek word, which means ‘secret writing’.

Cryptography is not a modern invention nor because of dawn of computers, in fact its almost 3 or 4 thousand years old practice of communicating securely. Kings as part of warfare or strategy were sending messages from one king to another in secret writing so that his\her enemy shouldn’t able to read the messages by capturing the messenger. Secret writing like, write message in hidden ink, substitution cipher (with shift of 3 A will be C, C will F) etc.

Almost all modern encryption\decryption of data, whether it’s WIRED (web, file system, messages) or WIRELESS (cell, sensors) done by three ways:

  •    Symmetric key
  •    Asymmetric key
  •    Mix of Symmetric and Asymmetric keys



Symmetric key cryptography


Symmetric (reflection or mirror) uses a single secret\shared key for both encryption and decryption. In this type of crypto both sender and receiver should know the secret key up front.
Sender encrypts the message using secret key, message transferred over network, Receiver decrypts the message using same secret key used for encryption.




pic courtesy Oracle corp.


The main drawback of shared-key crypto is the difficulty of securing the secret-key, which needed by both sender and receiver, so high chances of leaking the key. It’s called key distribution problem.

Asymmetric key cryptography


Also called public-key or public private key cryptography. Due to the drawbacks of symmetric key, made the way to invention of asymmetric key.
  
Public-key cryptography, proposed by Diffie and Hellman in 1976, is the idea of having two separate keys, a public key for encryption of a message and a secret key for its decryption; a party can privately construct the two keys and then make the encryption key public without thereby revealing the decryption key. Subsequently, anyone can encrypt messages intended for the creator of the keys, but only the creator can decrypt. The first realization of this idea was due to Rivest, Shamir, and Adleman in 1978.

At the heart of RSA – public key crypto is depend upon the properties of the product of two large prime numbers. This algorithm is based on some principles from Number theory, which states that determining the prime factors of a large number is extremely difficult.






pic courtesy Wiki


Differences


Symmetric key
Asymmetric key
Encrypts 256 bits
Encrypts 1024 bits or 2048 bits
The size of ciphered text is less or equal to plain text
The size of ciphered text is heavy
Less computing power
Need lot of computing power
Used : client and server
Used for: digital signature, session key …
DES, AES algorithm
RSA algorithm
Same key for encrypt and decrypt
Public key for encrypt and private key for decrypt



Cryptanalysis is the art and science of breaking the encrypted codes that are created by applying some cryptographic algorithms.