A deep dive into Computer Cryptography



Branches of Cryptography

Symmetric Algorithms

Problem with symmetric key cryptography is that both parties need to share the key with each other before they begin the communication which ultimately poses the threat of leakage of key to some other party.
  • Encryption equation y = eK(x)
  • Decryption equation x = dK(y)

Asymmetric (or Public key) Algorithms

Cryptanalysis : Attacking Cryptosystems

title:Kerckhoff's Principle
A Cryptosystem should be secure even if the attacker knows all the details of the system with the exception of key.

Classical Attacks

Mathematical Attacks

Brute-Force Attacks

  • Requires at least 1 plaintext-ciphertext pair.
  • Checks all possible combinations until the key is found.Substitution Attack
  • Historical Cipher
  • Encrypts letters rather than numbers
  • Plain text is replaced by cipher letters.
  • Exhaustive key search : Try every possible substitution until a intelligent text appears.
  • Frequency Analysis Attack : Checking frequency of different letters in the cipher and deducing the key.

Modular Arithmetic

  • Discrete (sets with integers are particularly useful)
  • finite

Properties of congruence

  1. a≡b(mod m) iff m/a-b
  1. a=q.m+r
  2. a≡b(mod m) implies b≡a(mod m)
  3. if a≡b(mod m) and b≡c(mod m) then a≡c(mod m)

Stream Ciphers

  • AES is an example of Block Cipher which is being used to encrypt internet communication.
  • Stream Cipher is being used in mobile GSM voice communication encryption.
  • AES and DES are highly optimized to work efficiently with modern apps.

Stream cipher


Random Number Generators

True Random Number generator(TRNG)

  • The our of TRNGs cannot be reproduced.For example if we flip a coin hundred times and then try to again output the same result.Other example include rolling of dice,radio active decay etc.
  • TRNGs are used for generating session keys.

(General) Pseudorandom Number Generator (PRNG)

  • PRNG has a starting state called seed state
  • Many numbers are generated which can be reproduced if the starting point is known
  • The numbers are predictable but efficient
  • They make the use of already developed algorithm to produce random numbers.
s0 = 12345  # this is the initial seed state
si+1 = 012023492si+12345 mod 2E31
s0 = seed
si+1 = ASi+B mod m

Cryptographically Secure Pseudorandom Number Generator (CSPRNG)

  • They are a special type of PRNGs
  • They posses unpredictability unlike PRNGs.

The One Time Pad

title: Unconditional Security
A cryptosystem is unconditionally or information-theoretically se-
cure if it cannot be broken even with infinite computational re-
  • The key must be random (uniformly distributed and independent of the plaintext).
  • The key must be at least as long as the plaintext.
  • The key must never be reused in whole or in part.
  • The key must be kept completely secret by the communicating parties.
  • This implies that we need one key bit for every bit of plaintext.

Linear Feedback Shift Registers

  • LFSR contain clock storage element called flip flops and a feedback path.
  • The number of flip flops gives us the degree of LFSR which means that m flip flops mean the degree of LFSR is m.

Data Encryption Standard

  • Confusion : is an encryption operation where the relationship between the key and the cipher text is obscured.
  • Diffusion : means an operation where influence of one plain text symbol is spread over many cipher text symbols with the goal of hiding statistical properties of of a plain text.

Overview of DES algorithm

Working of Feistel Network

  • After the initial permutation the 64 bit input is divided in 32 bit L0 and R0 separate input.
  • The R0 or right hand side goes to the L1 as it is without any change.
  • R0 is also used in the function (f) whose output is XOR with the input of L0.
  • The result becomes R1.
  • So only one 32 bit gets encrypted i.e. the L0.
  • Note that values are being swapped for the next round.

Function involved in DES

  • first a 32 bit plain text p1 is taken as input.
  • Then an expansion is performed and it is turned into 48 bit.
  • Now those 48 bits get XOR with a 48 bit key.
  • The result is converted into 8 groups of 6 bits.
  • These groups go into s-boxes which map these 6 bits to 4 bits using a lookup table giving us a total result of 32 bits.
  • At last permutation is performed and final 32 bit output is given



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

I am a Cyber Security Engineer(currently studying) and a technology enthusiast.Looking forward to engage with the Medium community and share knowledge!