Summary Chapter 1: Foundation
1.1 Terminology
· The art of keeping data (plaintext messages, images, voice, stream of bits etc) secure using various logic and algorithms (cipher) is called Cryptography. Disguising a message is encryption, the encrypted message is ciphertext and the process of turning cyphertext to plain text is decryption.
· Vital requirements for social interaction on computers are Authentication- Receiver should be able to ascertain the origin of the ciphertext not any intruder. Integrity- The ciphertext should be verifiable for its integrity to confirm the original message has not been tempered with. Nonrepudiation- A sender should not be able to falsely deny sending a communication later on.
· Cryptosystem- It is an algorithm which includes possible plaintexts, ciphertexts and keys.
· Symmetric algorithms (Secret key algorithms) – Same key is used to encrypt and decrypt the message. Asymmetric algorithms (Public Key algorithms) – A message is encrypted with a public key from sender and the receiver decrypt the message using corresponding private key.
· If an algorithm cannot be broken using existing or future resources, it is termed computationally secure. Although the available resources constituents are debatable.
1.2 Steganography
· Steganography is a technique for concealing secret communications within other messages, to the point that the secret's very existence is hidden.
· Some of the techniques used are invisible inks, pin punctured on selected characters, pencils marks on typewritten characters, replacing the least significant bits of a graphic image with the message or part of the message etc
1.3 Substitution Ciphers and transposition Ciphers
· Each character in the plaintext is substituted for another character in the ciphertext in a substitution cipher. To recover the plaintext, the receiver reverses the substitution on the ciphertext.
· Caesar Cipher – A substitution cipher where a letter is replaced by the third letter in English alphabet. E.g., A is replaced by D, B is replaced by E and so on. ROT13 – A simple substitution encryption program commonly found in UNIX system, that replaces every character with the 13th character in the English alphabet. Encrypting a file twice with ROT13 restores the original file.
· In a transposition cipher the plaintext remains the same but the order or position of the characters are shuffled horizontally or vertically. E.g., if a plain text is written horizontally, in a graph paper of fixed width the ciphertext is read off vertically. Decryption is done by writing the ciphertext vertically on similar width graph paper and reading it horizontally.
1.4 Simple XOR
· XOR is exclusive -OR operation. It is a standard operation in bits and be represented as:
o 0 OR 0 = 0
o 0 OR 1 = 1
o 1 OR 0 = 1
o 1 OR 1 = 0
· XORing the same value twice restores the original.
· For a cryptanalyst decrypting a XOR encryption should not be difficult.
1.5 One-Time Pads
· It was invented in 1917 by Major Joseph Mauborgne and AT&T’s Gilbert Vernam.
· A one-time pad is just a big nonrepeating set of truly random key letters written on sheets of paper and pasted together in a pad in the traditional sense. It started out as a single-use tape for teletypewriters. Each key letter on the pad is used by the sender to encrypt one plaintext character. The plaintext character and the one-time pad key character are added modulo 26 to form encryption.
· The sender and receiver have an identical pad. The sender uses one page of the pad or a section of the tape to encrypt the message and destroy the used page or section of the pad. The receiver on the other hand uses each key on the pad pages or tape section to decrypt the message and then destroys the section of the pad or tape after decryption.
· If the adversary has no access to the one-time pad scheme can be assumed as perfectly secure.
· One time pad does not provide authenticity and it is suitable for short messages but would never work for larger communication channel.
1.6 Computer Algorithms
· Data Encryption Standard (DES) – Symmetric algorithm
· Rivest, Shamir and Adleman (RSA) – One of the most popular public key algorithms that can be used for both encryption and decryption signatures.
· Digital Signature Algorithm (DSA) – A public key algorithm that is used only for digital signatures but not encryption.
1.7 Large Numbers
· Using astronomical large numbers in combination with encryption methods.
· E.g., Odds of being killed by lightning (per day) – 1 in 9 billion (223), Time until the next ice age – 14,000 (214) years etc
A type of cryptography that uses pairs of keys is known as public key cryptography. One key in this system is public, which means that anyone can access it. The private key is the second key, and it is only known by the owner. A person uses the public key to encrypt a message in this system. The private key is then used to decrypt the communication. The production of such keys necessitates a thorough understanding of mathematical and computer techniques for decryption and authentication. The owner of the private key also should have access to the server system that can generate the corresponding public keys. Because anyone with the public key can encrypt the data, but only those with the private key can decrypt it, Public Key Cryptography is also known as a one-way function. Some of the examples of public key cryptography are PGP (Pretty Good Privacy), Digital Signature Standard, Email encryption and decryption, encryption in WhatsApp etc
Email encryption and decryption: Email encryption uses the Public Key Cryptography for securing emails. A pair of keys is connected with each email address, and these keys are required to encrypt or decrypt an email. One of the keys is a "public key," which is saved on a key server and linked to a persons’ name and email address, making it accessible to everybody. The other key is the persons’ private key, which is not to be disclosed with anyone publicly. When an email is sent, it is encrypted using the public key, and the contents of the email are transformed into a complicated, indecipherable scramble that is extremely difficult to crack. This public key can only be used to encrypt and not decrypt the message that was transmitted. Only the person who possesses the correct private key may decode the email and view its contents. Some of the email encryption protocols used are OpenPGP and S/MIME.
Encryption in WhatsApp: WhatsApp uses a combination of both symmetric and asymmetric cryptography to secure the message between the sender and receiver. The symmetric key cryptographic algorithms maintain confidentiality and integrity, whereas the asymmetric key cryptographic algorithms aid in the other security goals of authentication and non-repudiation. WhatsApp uses the Curve25519 based algorithm for public key cryptography which is based on the mathematical algorithm Elliptic Curve Diffie Hellman algorithm that allows two interacting entities to agree on a shared secret without sending each other the actual keys. Similar to email encryption, the sender sends the message encrypted with his/her public key and receiver reads the message after decrypting it with his/her own private key. However, all these processes happen in the server side, without user actually doing the encryption and decryption themselves.
· Installing the GPG in the system: sudo apt-get install gpg
· Generating a GPG key: gpg –full-generate-key
· Follow the process as instructed in the terminal.
· Checking the GPG Key:
o For private key: gpg –list-secret-keys
o For public key: gpg –list-public-keys
· Create a message.txt file with some message
· Encrypt the file with gpg and send to the recipient added while creating the GPG keys. As we are sending the message to ourselves to decrypt.
o Gpg –encrypt –output message.txt.gpg –recipient emailAddress message.txt
· A separate file named as message.txt.gpg will be created, reading the content of the file will show gibberish contents. cat message.txt.gpg
· Delete the original message.txt to confirm the decrypted message.txt.gpg file contains the same message as send.
· Decrypt the encrypted file and save it as some other file:
o gpg –decrypt –output decrypted-message.txt message.txt.gpg
· User will be prompted to type the key phrase used during key generation.
· The content of the new file will be readable and will have the same message encrypted previously.
Sending and receiving GPG keys:
· Get the list of the public keys: gpg –list-public-keys
· Copy the public key and paste in next steps’ KEYID
· Export the public key into a file: gpg –output key.gpg –export KEYID
· Import the key in another system or as a new person: gpg –import key.gpg
· In order to use the key normally in another system/ person, it needs to be verified first for GPG to properly trust it.
· Other system with gpg can run: gpg –edit-key kEYiD of newsystem
· In gpg console type: fpr
· The command will show the fingerprint of the key.
· The output of the command should be validated against the output of the system.
· After verifying the output use the command: sign
· Now the new user will be able to decrypt the message using their private key.
Bruce Schneier. (2015). Applied Cryptography: Protocols, Algorithms and Source Code in C, 20th Anniversary edition. Https://Www.Oreilly.Com/Library/View/Applied-Cryptography-Protocols/9781119096726/10_chap02.Html.
History Computer Staff. (2021, October). The complete guide to Public Key Cryptography. Https://History-Computer.Com/Public-Key-Cryptography-Complete-Guide/.