Download presentation
Presentation is loading. Please wait.
Published byTheodore Joseph Modified over 8 years ago
1
Basic Cryptography Some examples taken from “Coding Theory and Cryptography, the essentials” Second Edition Hankerson, et.al. 2000, Marcel Dekker, Inc Slides by Dannelly
2
Terms Plaintext – the readable message Plaintext – the readable message Ciphertext – the coded message Ciphertext – the coded message
3
Levels of Security Unconditionally Secure Unconditionally Secure – impossible to break, even if the adversary has unlimited ciphertext and unlimited computing power Computationally Secure Computationally Secure – only infeasible (not impossible) to break the code Provably Secure Provably Secure – intractable problem
4
Types of Attacks Ciphertext Only Ciphertext Only – adversary uses just the ciphertext to gain either the key or the plaintext (really bad) Known Plaintext Known Plaintext – adversary gets the key using some ciphertext and its plaintext Chosen Plaintext Chosen Plaintext – adversary introduces some plaintext to generate some ciphertext
5
Symmetric Key Encryption Both parties share a key The single key is used for both encryption and decryption Encryption and decryption are equal efforts
6
Shift Ciphers key = amount to shift each character Example: Rotate13 ‘A’ + 13 = 1 + 13 = 14 = ‘N’ So, the message “aardvark” becomes “nneqinex”.
7
Shift Ciphers Advantage of Rot13: Easy to implement. Rot13('A') = 'N' (1 + 13)%26 = 14 Rot13('N') = 'A' (14 + 13)%26 = 1 So, one function does both encoding and decoding. Disadvantage of Any Rotation: Very easy to break – just try all 26 possibilities.
8
Substitution Cipher Key = list of character substitutions Example: Key = “Chair” A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Y Z c h a i r B D E F G J K L M N O P Q S T U V W X Disadvantage: Susceptible to Character Frequency Analysis
9
Character Frequencies
11
Polyalphbetic Ciphers Key is repeated and used to shift characters. Example plaintextnow is the time for all + keyaar dv ark aard var kaa Ciphertextopo mo uzp ujei bpj lmm
12
Polyalphbetic Ciphers Advantage: Thwarts character frequency analysis. For example, an “e” will encrypt to several different letters. Disadvantage: Statistics can still be used to break the code.
13
Polyalphbetic Ciphers How to Break Them: 1 - Look for repeated strings. For example, if the characters “thi” appear together frequently, then it could be because the key is hitting a common word. Text = and we need to test and retest Key = ste ve stev es teve ste vestev Sum = thi sj gyjz yh njoy thi njmyxp
14
Polyalphbetic Ciphers How to Break Them: 2 – Determine Probable Key Length The start of strings “thi” are frequently separated by distances that are multiples of 5. So, key length is probably five. 3A – Try keys of that length. 3B – Use CharFreqAnal on characters separated by that length.
15
One-Time Pad Key is used to shift the plaintext. Key is used only once. Key has same length as the message. Advantage: Unbreakable! Disadvantage: Requires lots of keys.
16
Hashing Recall a hash function can be used to "randomly" spread out data and yet still determine where to find data. For example – –hash("steve") = 5, so look in file 5 for steve's data. – –hash("bob") = 42, so look in file 42 for bob's data
17
Sample Hash Function int hash (char[] name) { int sum=0; for (int I=0; I<name.length; I++) sum += name[I]; return sum%tablesize; }
18
Java's Message Digest Java provides several hash functions that turn a message into a "message digest". Java provides several hash functions that turn a message into a "message digest". H(msg) = digest The digest is always the same length, no matter the msg length. The digest is always the same length, no matter the msg length. Given a digest, you can not determine either msg or H. Given a digest, you can not determine either msg or H.
19
Common Use : verify validity To Send: To Send: 1.Use a prearranged scheme to determine the Hash function. 2.Generate message digest from msg. 3.Send both msg and message digest. To Verify Received msg: To Verify Received msg: if (Hash(msg) == digest) msg is okay msg is okay
20
Sample Code MessageDigest md; byte[] digest; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { return -1; } md.reset(); md.update(first_quarter_of_msg); md.update(forth_quarter_of_msg); md.update(second_quarter_of_msg); md.update(third_quarter_of_msg); digest = md.digest(); This should match the received digest This is the secret part Several Choices of Secure Hash Functions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.