Basics of Cryptography
Md. Alamgir Bhuyan
CSE, IUBAT
The General Goals of Cryptography
• Confidentiality; assuring that only authorized
parties are able to understand the data.
• Integrity; ensuring that when a message is sent
over a network, the message that arrives is the
same as the message that was originally sent.
• Authentication; ensuring that whoever supplies
or accesses sensitive data is an authorized party.
• Nonrepudiation; ensuring that the intended
recipient actually received the message &
ensuring that the sender actually sent the
message.
Basic Terms
• Encryption: scrambling a message or data using a
specialized cryptographic algorithm.
• Plaintext: the message or data before it gets encrypted.
• Ciphertext: the encrypted (scrambled) version of the
message.
• Cipher: the algorithm that does the encryption.
Decryption: the process of converting ciphertext back to the
original plaintext.
• Cryptanalysis: the science of breaking cryptographic
algorithms.
• Cryptanalyst: a person who breaks cryptographic codes;
also referred to as “the attacker”.
Types
Symmetric Encryption – Both Sender/Receiver use
the same algorithms/keys for encryption/decryption
Asymmetric Encryption – Sender/receiver can
employ different keys
Symmetric Cryptography
• Two main categories of symmetric algorithms:
– Block ciphers
– Stream ciphers
• Most well-known and well-studied symmetric
algorithms use block ciphers.
• Block ciphers break up the message into
constant-size blocks and encrypt the code
block by block.
Encryption Basics
Gen() algorithm for generating keys
Encryption algorithm to convert plaintext into
ciphertext – E(M, keys) = C
Decryption algorithm to convert ciphertext to plaintext
– D(C, keys) = M
Some early ciphers
Substitution (eg., Caesar cipher)
Security is hard: tfdvsjuz jt ibse
C = (M+k) mod 26
M = (C-k) mod 26
Only 26 possibilities with English Alphabet
Brute Force search can decrypt
Monoalphabetic cipher
Instead of plain rotation, use random letter
substitution
Key is 26 letters long Plain:
abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: security is hard
Ciphertext: AFVOYWUZ WA JDYQ
Example
The plaintext:
0 1 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0
The key:
1 1 0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0
The ciphertext
1 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 1 0 1 0 0 1
Example
ciphertext:
1 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 1 0 1 0 0 1
XOR’d with key
1 1 0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0
yields plaintext
0 1 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0