Introduction to Cryptography Part 1

cryptography or cryptology is very old science it’s has been used since Ancient Greek used cryptography to secure communication in presence of third party, from Wikipedia

cryptography is about constructing and analyzing protocols that prevent third parties or the public from reading private messages;[3] various aspects in information security such as data confidentiality, data integrity, authentication, and non-repudiation[4] are central to modern cryptography.

I’ll write several parts on Cryptography explaining the modern cryptography and the modern attacks on them, you can find the programming part of Cryptography in the coding section under Cryptography as I’ll put the important library and we’ll be doing a hands on project so you can apply your knowledge as we going through.

Content:

In part 1 I’ll discuss what stream ciphers are, how secure they are and what are the most common algorithm for stream ciphers.

Let’s start our discussion by talking about simple stream cipher:

the most simple way stream cipher to use stream cipher for encryption and decryption as by using XOR function.

Before we take our example we have to declare some notations M for message, K for key, C for ciphertext, E is a Encryption function, D is a Decryption function.

Example 1.1: consider the case that you have M and K as stream of bits, M = 1101 1100 , K = 1110 0011 . So our Encryption function will be something like this, C_i = M_i XOR K_i where i corresponds to the i’th bit and for i < n-1 so we get our ciphertext C = 0011 1111. In Decryption we reverse the process we take the ciphertext and XOR with the key M_i = C_i XOR K_i where i corresponds to the i’th bit and for i < n-1 so we get our ciphertext M= 1101 1100.

Now we have a good idea about how simple stream cipher can work, If you are asking now how we get the Key you are so smart let’s start discussing Random Number Generators we have two types of Random Number Generators:

1. Truly Random Number Generators
2. Pseudo-random generators

Truly Random Number Generators

Truly Random Number Generators(TRNG) are characterized that there output can’t be reproduced, for instance if someone flips a coin 100 times and record the resulting sequence in bits it’s impossible for someone else to generate the same 100 bit sequence, TRNG are based on physical process

Pseudo-random generators

Pseudorandom number generator (PRNG) is efficient, deterministic algorithm let’s denote it by G that is given seed as input and computes an output r, the seed comes from finite seed space and the out r belongs to a finite output space R,

if s is chosen at random from S and r is chosen at random from R, then no efficient adversary can efectively tell the difference between G(s) and r: the two are computationally indistinguishable, Often (PRNG) are computed recursively here’s a good link from Wikipedia describing how it works.