SlideShare a Scribd company logo
1 of 66
Kripto
• Kriptologi --- Seni dan sains pembuatan dan pemecahan kode rahasia
(yang dikirim melalui komunikasi digital)
• Kriptografi --- seni dan sains pembuatan kode rahasia (yang dikirim
melalui komunikasi digital)
• Kriptanalisis --- seni dan sains pemecahan kode rahasia (yang dikirim
melalui komunikasi digital)
• Kripto --- termasuk semua di atas
Kripto
• Suatu cipher atau sistem kripto digunakan untuk mengenkriptsi
the pesan asli (plaintext)
• Hasil dari enskriptsi teks cipher
• Teks chiper didekriptsi untuk mendapatkan pesan asli
• Kunci digunakan untuk menciptakan konfigurasi sistem kripto
• Kunci simetri dari sistem kripto adalah satu kunci yang
digunakan untuk mengenkriptsi dan juga untuk mendekriptsi
• Kunci publik dari sistem kripto terdiri atas satu kunci publik
untuk enkriptsi dan satu kunci pribadi untuk mendekriptsi atau
menandatangani (tanda-tangan digital)
Kripto
• Asumsi Dasar:
• Penyerang/pembobol mengetahui cara kerja sistem
• Hanya kunci dari sistem yang dirahasiakan
• (Juga dikenal sebagai Prinsip Kerckhoffs
• Algoritma kripto tidak dirahasiakan)
• Mengapa asumsi ini dibuat?
• Pengalaman menunjukkan bahwa sifat rahasia dari
algoritma sangat lemah ketika diimplementasikan
• Algoritma rahasia tidak pernah bisa dirahasiakan
selamanya
• Lebih baik orang mendapatkan kelemahan algoritma
kripto sebelum algoritma tersebut terlanjur digunakan
Kripto sebagai kotak hitam
Pesan asli
kunci
kunci
pesan asli
ciphertext
penggunaan kripto
enkript dekript
5 Classical (secret-key) cryptosystems
Kriptosistem - cipher
Kriptografi bergelut dengan masalah pengiriman pesan (teks
asli) lewat kanal tak aman yang mungkin bisa disadap oleh
adversary (misalnya oleh cryptanalyst) .
6 Classical (secret-key) cryptosystems
Komponen dari sisem kripto:
Ruang pesan (asli) P – sebuah himpunan pesan asli atas suatu alfabet 
Ruang teks kripto C – sebuah himpunan teks-teks kripto (teks cipher) atas
alfabet 
Ruang kunci K – himpunan kunci-kunci
Setiap kunci k menentukan sepasang algoritma enkriptsi algorithm ek dan
algoritma deskriptsi dk sedemikian hingga berlaku
1. untuk setiap teks asli w, ek (w) adalah teks krypto yang dihasilkan dan
2. w  dk(ek (w)) , yaitu w adalah salah satu hasil deskriptsi thd ek (w);
atau
2. w = dk(ek (w)). , yaitu w adalah saltu-satunya hasil deskriptsi thd ek (w);
Substitusi Sederhana
• Teks asli: fourscoreandsevenyearsago
• Alfabet:  = {a, b, c, ..., z},  = {A, B, C, ..., Z}
• Kunci:
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
D E F G H I J K L M N O P Q R S T U V W X Y Z A B
z
C
 Teks Cipher:
IRXUVFRUHDAGVHYHABHDUVDIR
 Contoh Chiper Caesar dengan geseran 3
Huruf asli
Huruf chiper
Part 1  Cryptography
8
Deskirptsi Chiper Ceasar
•Teks asli: spongebobsquarepants
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
D E F G H I J K L M N O P Q R S T U V W X Y Z A B
z
C
Huruf asli
Huruf Chiper
Misalkan sudah diketahui bahwa
chiper Ceasar digunakan
Teks Chiper:
VSRQJHEREVTXDUHSDQWU
Not-so-Simple Substitution
• Shift by n for some n  {0,1,2,…,25}
• Then key is n
• Example: key = 7
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
H I J K L M N O P Q R S T U V W X Y Z A B C D E F
z
G
Plaintext
Ciphertext
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
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Part 1  Cryptography
10
Cryptanalysis I: Try Them All
(Exhaustive key search)
• A simple substitution (shift by n) is used
• But the key is unknown
• Given ciphertext: CSYEVIXIVQMREXIH
• How to find the key?
• Only 26 possible keys --- try them all!
• Solution: key = 4
11 Classical (secret-key) cryptosystems
Oracle enkriptsi dan deskriptsi
(encripting and decripting oracles)
Contoh:
Saudara menggunakan kartu kredit (atau kartu ATM, kartu debit dsb) untuk
mengambil uang di mesin ATM. Secara internal (tidak kelihatan) terjadi
komunikasi antara A (= mesin ATM) dengan B (= komputer server bank).
A (mesin ATM) mengirimkan nomor/pesan asli m (= kombinasi no rahasia kartu
dengan no pin saudara) untuk mengirim nomor/pesan sandi s = E(m) kepada B (=
komputer server) . Dengan menggunakan kunci rahasia yang sama, B merubah
pesan s kembali ke m untuk mendapatkan nomor identitas kartu yang asli +
identitas saudara. Jika nomor identitas ini valid, maka B memerintahkan A (=
mesin ATM) untuk mengeluarkan dana sesuai permintaan saudara.
Baik saudara atau pegawai bank tidak ada yang mengetahui pesan asli m, hanya
komputer server yang mengetahui atau hasil penyandian s. Bilangan m tidak
sembarangan, karena m harus memenuhi syarat2 tertentu yang ketat (m  ruang
pesan).
Jika tidak demikian (tak ada syarat untuk m dan s bisa diketahui) maka saudara
bisa bikin sendiri dua pesan palsu m1 dan m2 kemudian mengetahui hasil
penyandiannya: s1 dan s2, maka saudara bisa mencoba-coba sampai
mendapatkan pesan rahasia orang lain yang valid dan mendapatkan cara untuk
menarik dana milik orang tsb.
12 Classical (secret-key) cryptosystems
Cryptanalysis II (thd affine crypto algorithm):
ea,b(x) = (ax + b) mod 26 = (xa+b) mod 26
where gcd(a, 26) = 1. (Number of keys: 12 × 26 = 312.)
Example: Assume that an English plaintext is divided into blocks of 5 letter and encrypted
by an AFINE cryptosystem (ignoring space and interpunctions) as follows:
How to find
the plaintext?
B H J U H N B U L S V U L R U S L Y X H
O N U U N B W N U A X U S N L U Y J S S
W X R L K G N B O N U U N B W S W X K X
H K X D H U Z D L K X B H J U H B N U O
N U M H U G S W H U X M B X R W X K X L
U X B H J U H C X K X A X K Z S W K X X
L K O L J K C X L C M X O N U U B V U L
R R W H S H B H J U H N B X M B X R W X
K X N O Z L J B X X H B N F U B H J U H
L U S W X G L L K Z L J P H U U L S Y X
B J K X S W H S S W X K X N B H B H J U
H Y X W N U G S W X G L L K
13 Classical (secret-key) cryptosystems
Cryptanalysis’s
Tables frequency analysis of chiphertext (for plaintext) and frequency table for English :
First guess: E = X, T = U Encodings: 4a + b = 23 (mod 26)
xa + b = y 19a + b = 20 (mod 26)
Predicted solution : a = 5, b = 3  a-1 =
Translation table
provides from the above cryptotext the plaintext that starts with KGWTG CKTMO OTMIT DMZEG, what does not make a sense.
% % %
E 12.31 L 4.03 B 1.62
T 9.59 D 3.65 G 1.61
A 8.05 C 3.20 V 0.93
O 7.94 U 3.10 K 0.52
N 7.19 P 2.29 Q 0.20
I 7.18 F 2.28 X 0.20
S 6.59 M 2.25 J 0.10
R 6.03 W 2.03 Z 0.09
H 5.14 Y 1.88 5.27
70.02 24.71
X - 32 J - 11 D - 2
U - 30 O - 6 V - 2
H - 23 R - 6 F - 1
B - 19 G - 5 P - 1
L - 19 M - 4 E - 0
N - 16 Y - 4 I - 0
K - 15 Z - 4 Q - 0
S - 15 C - 3 T - 0
W - 14 A - 2
B H J U H N B U L S V U L R U S L Y X H
O N U U N B W N U A X U S N L U Y J S S
W X R L K G N B O N U U N B W S W X K X
H K X D H U Z D L K X B H J U H B N U O
N U M H U G S W H U X M B X R W X K X L
U X B H J U H C X K X A X K Z S W K X X
L K O L J K C X L C M X O N U U B V U L
R R W H S H B H J U H N B X M B X R W X
K X N O Z L J B X X H B N F U B H J U H
L U S W X G L L K Z L J P H U U L S Y X
B J K X S W H S S W X K X N B H B H J U
H Y X W N U G S W X G L L K
crypto A B C D E F G H I J K L M N O P Q R S T U V W X
plain P K F A V Q L G B W R M H C X S N I D Y T O J E
Y Z
Z U
14 Classical (secret-key) cryptosystems
Cryptanalysis’s
Second guess: E = X, A = H
Equations 4a + b = 23 (mod 26)
b = 7 (mod 26)
Solutions: a = 4 or a = 17 and therefore a=17
This gives the translation table
and the following
plaintext from the
above cryptotext
S A U N A I S N O T K NO W N T O B E A
F I N N I S H I N V E N T I O N B U T T
H E W O R D I S F I N N I S H T H E R E
A R E M A N Y M O R E SA U N A S I N F
I N L A N D T H A N E L S E W H E R E O
N E S A U N A P E R E VE R Y T H R E E
O R F O U R P E O P L EF I N N S K N O
W W H A T A S A U N A I S E L S E W H E
R E I F Y O U S E E A S I G N S A U N A
O N T H E D O O R Y O UC A N N O T B E
S U R E T H A T T H E RE I S A S A U N
A B E H I N D T H E D OO R
crypto A B C D E F G H I J K L M N O P Q R S T U V W X
plain V S P M J G D A X U R O L I F C Z W T Q N K H E
Y Z
B Y
Part 1  Cryptography
15
Even-less-Simple Substitution
• Key is some permutation of letters
• Need not be a shift
• For example
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
J I C A X S E Y V D K W B Q T Z R H F M P N U L G
z
O
Plaintext
Ciphertext
 Then 26! > 288 possible keys!
Part 1  Cryptography
16
Cryptanalysis II
• Can’t try all 288 simple substitution keys
• Can we be more clever?
• English letter frequency counts…
0,00
0,02
0,04
0,06
0,08
0,10
0,12
0,14
A C E G I K M O Q S U W Y
17 Classical (secret-key) cryptosystems
Polyalphabetic Substitution Cryptosystems
Playfair cryptosystem
Invented around 1854 by Ch. Wheatstone.
Key - a Playfair square is defined by a word w of length at most 25. In w repeated letters are then removed,
remaining letters of alphabets (except j) are then added and resulting word is divided to form an 5 x 5 array
(a Playfair square).
Q
K
E
O
T
X
C
L
P
R
W
Y
V
M
B
G
N
F
A
H
U
I
Z
D
S
Encryption: of a pair of letters x,y
• If x and y are in the same row (column), then they are replaced by the pair of symbols to the right
(bellow) them.
• If x and y are in different rows and columns they are replaced by symbols in the opposite corners of
rectangle created by x and y.
Example: PLAYFAIR is encrypted as LCMNNFCS
Playfair was used in World War I by British army.
Playfair square:
18 Classical (secret-key) cryptosystems
Polyalphabetic Substitution Cryptosystems
VIGENERE and AUTOCLAVE cryptosystems
Several of the following polyalphabetic cryptosystems are modification of the CAESAR
cryptosystem.
A 26 ×26 table is first designed with the first row containing a permutation of all symbols of
alphabet and all columns represent CAESAR shifts starting with the symbol of the first row.
Secondly, for a plaintext w a key k is a word of the same length as w.
Encryption: the i-th letter of the plaintext - wi is replaced by the letter in the wi-row and ki-
column of the table.
VIGENERE cryptosystem: a short keyword p is chosen and
k = Key(repeated cyclicly)
VIGENERE is actually a cyclic version of the CAESAR cryptosystem.
AUTOCLAVE cryptosystem: k = Key + (part of original message).
19 Classical (secret-key) cryptosystems
Polyalphabetic Substitution Cryptosystems
VIGENERE and AUTOCLAVE cryptosystems
Example:
Keyword: H A M B U R G
Plaintext: I N J E D E M M E N S C H E N G E S I C H T E S T E H T S E I N E G
Vigenere-key: H A M B U R G H A M B U R G H A M B U R G H A M B U R G H A M B U R
Autoclave-key: H A M B U R G I N J E D E M M E N S C H E N G E S I C H T E S T E H
Vigerere-cryp.: P N V F X V S T E Z T W Y K U G Q T C T N A E E V Y Y Z Z E U O Y X
Autoclave-cryp.: P N V F X V S U R W W F L Q Z K R K K J L G K W L M J A L I A G I N
20 Classical (secret-key) cryptosystems
BREAKING VIGENERE CRYPTO SYSTEM
CRYPTOANALYSIS of cryptotexts produced by VINEGAR cryptosystem
1.Task 1 -- to find the length of the key
Kasiski method (1852) - invented also by Charles Babbage (1853).
Basic observation If a subword of a plaintext is repeated at a distance that is a multiple of the
length of the key, then the corresponding subwords of the cryptotext are the same.
Example, cryptotext:
Substring ''CHR'' occurs in positions 1, 21, 41, 66, 71: expected keyword length is therefore GCD(20,
20, 20, 15) = 5.
CHRGQPWOEIRULYANDOSHCHRIZKEBUSNOFKYWROPDCHRKGAXBNRHROAKERBKSCHRSIWADFTHNNDG
Method. Determine the greatest common divisor of the distances between identical subwords
(of length 3 or more) of the cryptotext.
21 Classical (secret-key) cryptosystems
CRYPTOANALYSIS of cryptotexts produced by VINEGAR
cryptosystem
Friedman method
Let ni be the number of occurrences of the i-th letter in the cryptotext.
Let l be the length of the keyword.
Let n be the of the cryptotext. Then it holds
Once the length of the klength eyword is found it is easy to determine the key using
the statistical (frequency analysis)method of analyzing monoalphabetic
cryptosystems.
 
 
 






 

26
1
1
1
065
.
0
038
.
0
1
027
.
0
,
i
n
n
n
n
n
I
n
n i
i
I
l
22 Classical (secret-key) cryptosystems
Derivation of the Friedman method
Assume that a cryptotext is organized into l columns headed by the letters of the keyword
First observation Each column is obtained using the CAESAR cryptosystem.
Probability that two randomly chosen letters are the same in
- the same column is 0.065. - different columns is 0.038.
The number of pairs of letters in the same column:
The number of pairs of letters in different columns:
The expect number A of pairs of equals letters is
Since
one gets the formula for l from the previous slide.
   
l
l
n
n
l
n
l
n
l
2
2 1 



   
l
l
n
n
l
n
l
l
2
2
1 2
2
2 



   
038
.
0
065
.
0 2
1
2
2



 

l
l
n
l
l
n
n
A
     
 
065
.
0
038
.
0
027
.
0
1
1
2
1 


 
 n
l
I n
l
A
n
n
letters Sl S1 S2 S3 . . . Sl
x1 x2 x3 . . . Xl
xl+1 xl+2 xl+3 X
xl+1 xl+2 xl+3 . . . x3l
. . . .
23 Classical (secret-key) cryptosystems
ONE-TIME PAD cryptosystem – Vernam’s cipher
Binary case:
plaintext w
key k are binary words of the same length
cryptotext c
Encryption: c = w k (is the Nim sum or modulo 2 addition)
Decryption: w = c k
Example:
w = 101101011
k = 011011010
c = 110110001
What happens if the same key is used twice or 3 times for encryption?
c1 = w1 k, c2 = w2 k, c3 = w3 k
c1 c2 = w1 w2
c1 c3 = w1 w3
c2 c3 = w2 w3
Part 1  Cryptography
24
One-time Pad
e=000 h=001 i=010 k=011 l=100 r=101 s=110 t=111
h e i l h i t l e r
001 000 010 100 001 010 111 100 000 101
111 101 110 101 111 100 000 101 110 000
110 101 100 001 110 110 111 001 110 101
s r l h s s t h s r
Encryption: Plaintext  Key = Ciphertext
Plaintext:
Key:
Ciphertext:
Part 1  Cryptography
25
One-time Pad
e=000 h=001 i=010 k=011 l=100 r=101 s=110 t=111
s r l h s s t h s r
110 101 100 001 110 110 111 001 110 101
101 111 000 101 111 100 000 101 110 000
011 010 100 100 001 010 111 100 000 101
k i l l h i t l e r
Ciphertext:
“key”:
“Plaintext”:
Double agent claims sender used “key”:
Part 1  Cryptography
26
One-time Pad
e=000 h=001 i=010 k=011 l=100 r=101 s=110 t=111
s r l h s s t h s r
110 101 100 001 110 110 111 001 110 101
111 101 000 011 101 110 001 011 101 101
001 000 100 010 011 000 110 010 011 000
h e l i k e s i k e
Ciphertext:
“Key”:
“Plaintext”:
Sender is captured and claims the key is:
Part 1  Cryptography
27
Stream Ciphers
• Not as popular today as block ciphers
• We’ll discuss two examples
• A5/1
• Based on shift registers
• Used in GSM mobile phone system
• RC4
• Based on a changing lookup table
• Used many places
Part 1  Cryptography
28
A5/1
• A5/1 consists of 3 shift registers
• X: 19 bits (x0,x1,x2,…,x18)
• Y: 22 bits (y0,y1,y2,…,y21)
• Z: 23 bits (z0,z1,z2, …,z22)
Part 1  Cryptography
29
A5/1
• At each step: m = maj(x8, y10, z10)
• Examples: maj(0,1,0) = 0 and maj(1,1,0) = 1
• If x8 = m then X steps
• t = x18  x17  x16  x13
• xi = xi1 for i = 18,17,…,1 and x0 = t
• If y10 = m then Y steps
• t = y21  y20
• yi = yi1 for i = 21,20,…,1 and y0 = t
• If z10 = m then Z steps
• t = z22  z21  z20  z7
• zi = zi1 for i = 22,21,…,1 and z0 = t
• Keystream bit is x18  y21  z22
Part 1  Cryptography
30
A5/1
• Each value is a single bit
• Key is used as initial fill of registers
• Each register steps or not, based on (x8, y10, z10)
• Keystream bit is XOR of right bits of registers
y0 y1 y2 y3 y4 y5 y6 y7 y8 y9 y10 y11 y12 y13 y14 y15 y16 y17 y18 y19 y20 y21
z0 z1 z2 z3 z4 z5 z6 z7 z8 z9 z10 z11 z12 z13 z14 z15 z16 z17 z18 z19 z20 z21 z22
X
Y
Z




x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18
Part 1  Cryptography
31
A5/1
• In this example, m = maj(x8, y10, z10) = maj(1,0,1) = 1
• Register X steps, Y does not step, and Z steps
• Keystream bit is XOR of right bits of registers
• Here, keystream bit will be 0  1  0 = 1
1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
X
Y
Z




1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
Part 1  Cryptography
32
Shift Register Crypto
• Shift register-based crypto is efficient in hardware
• Harder to implement in software
• In the past, very popular
• Today, more is done in software due to faster processors
• Shift register crypto still used some
Part 1  Cryptography
33
RC4
• A self-modifying lookup table
• Table always contains some permutation of
0,1,…,255
• Initialize the permutation using key
• At each step, RC4
• Swaps elements in current lookup table
• Selects a keystream byte from table
• Each step of RC4 produces a byte
• Efficient in software
• Each step of A5/1 produces only a bit
• Efficient in hardware
Part 1  Cryptography
34
RC4 Initialization
• S[] is permutation of 0,1,…,255
• key[] contains N bytes of key
for i = 0 to 255
S[i] = i
K[i] = key[i (mod N)]
next i
j = 0
for i = 0 to 255
j = (j + S[i] + K[i]) mod 256
swap(S[i], S[j])
next j
i = j = 0
Part 1  Cryptography
35
RC4 Keystream
• For each keystream byte, swap table elements and select byte
i = (i + 1) mod 256
j = (j + S[i]) mod 256
swap(S[i], S[j])
t = (S[i] + S[j]) mod 256
keystreamByte = S[t]
• Use keystream bytes like a one-time pad
• Note: first 256 bytes must be discarded
• Otherwise attacker can recover key
Part 1  Cryptography
36
Stream Ciphers
• Stream ciphers were big in the past
• Efficient in hardware
• Speed needed to keep up with voice, etc.
• Today, processors are fast, so software-based crypto is
fast enough
• Future of stream ciphers?
• Shamir: “the death of stream ciphers”
• May be exaggerated…
2. Pengenalan Kunci Publik
Bagian A. Sistem Kripto Berbasis Kesukaran
Faktorisasi N = pq, p dan q prima
38
Landasan Teori:
Lemma. Jika a = bq + r, maka FPB(a,b) = FPB(b,r).
Algoritma Euklid. Misalkan r0 = a dan r1 = b bulat dg a  b.
r0 = r1q1 + r2, 0  r2 < r1,
r1 = r2q2 + r3, 0  r3 < r2,
… …
rn2 = rn1qn1 + rn, 0  rn < rn1,
rn1 = rnqn.
Lemma  FPB(a,b) = FPB(r0, r1) = FPB(r1, r2) = … =
FPB(rn2, rn1) = FPB(rn1, rn) = FPB(rn, 0) = rn.
Contoh 2.1:
662 = 4141 + 248, 414 = 2481 + 166, 248 = 1661 + 82,
166 = 822 + 2, 82 = 241 Lemma 
FPB(662,414)=FPB(414,248)= .... =FPB(82, 2)=FPB(2, 0)=2.
39
Teorema 2.1
Jika a dan b adalah dua bilangan bulat positif, maka
terdapat dua bilangan s dan t sedemikian rupa sehingga
FPB(a,b) = sa + tb. (2.1)
Nilai s dan t dlm teorem di atas bisa diperoleh melalui perluasan
algoritma Euclid via barisan {sk,tk} yg didef sbb.
s0 = 1, s1 = 0, t0 = 0, t1 = 1,
sk+1 = sk1  qksk , tk+1 = tk1  qktk .
Teorema berikut mengadopsi notasi sisa terakhir rn+1 = 0.
Teorema 2.2
Jika 0  k  n + 1, maka rk = ska + tkb.
Sebagai akibatnya, nilai s dan t dalam (2.1) adl
s = sn dan t = tn.
40
Contoh 2.2:
Misalkan a = 100 dan b = 35. Diagram berikut
memudahkan penggunaan algoritma Euklid yang
diperluas.
Dari tabel di atasan, teorema 2.2 memberikan
5 = FPB(100, 35) = r3 = (1)100 + (3)35
 s = 1 dan t = 3.
k 0 1 2 3 4
rk 100 35 30 5 0
qk 2 1 6
sk 1 0 1 1 7
tk 0 1 2 3 20
41
Contoh 2.3:
Sekarang misalkan a = 469 dan b = 203. Seperti
Contoh 2.2, diagram berikut memudahkan implemen-
tasi algoritma Euclid yang diperluas.
Dari tabel di atasan, Teorema 2.2 memberikan
7 = FPB(469, 203) = r4 = 13469 + 30203
 s = 13 dan t = 30.
k 0 1 2 3 4 5
rk 469 203 63 14 7 0
qk 2 3 4 2
sk 1 0 1 3 13 29
tk 0 1 2 7 30 67
Landasan Teori:
Grup dari Bilangan-Bilangan Bulat
Grup yang akan dibahas hanyalah grup dengan operasi tambah
(atau kali) kongruen modulo n, yaitu grup
Zn = {k  N | 1  k < n }
Teorema 2.3
Jika (G, +) adalah grup (dalam notasi tambah) dengan banyak
unsur n (yaitu |G| = n), maka untuk setiap g  G berlaku ng = 0.
Contoh 2.4:
Dalam Z9 = {0, 1, 2, 3, 4, 5, 6, 7 , 8} berlaku
(9)(4) = 4 + 4 + 4 + 4 + 4 + 4 +4 + 4 + 4 = 0.
Grup dari Bilangan-Bilangan Bulat
Teorema 2.4
Z
n = {k  N | 1  k < n, k saling prima dengan n }
terhadap operasi kali kongruen modulo n merupakan grup.
Contoh 2.5:
Z
9 = {1, 2, 4, 5, 7, 8},
Z
10 = {1, 3, 7, 9},
Z
11 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
adalah grup (kali).
Grup dari Bilangan-Bilangan Bulat
Teorema 2.4 dalam bahasa teori bilangan
Untuk setiap g  Z berlaku ng mod n = 0 atau ng  0 mod n
Contoh 2.5 dalam bahasa teori bilangan
(9)(4) mod 9 = (4 + 4 + 4 + 4 + 4 + 4 +4 + 4 + 4) mod 9 = 0
atau (4 + 4 + 4 + 4 + 4 + 4 +4 + 4 + 4)  0 mod 9
Fungsi Euler (Totient)
Definisi :
Fungsi Euler : N  N didefinisikan melalui aturan pengawanan
(n) = banyaknya bilangan asli k dengan 1  k < n yang saling prima
dengan n.
Contoh :
Z
7 = {1, 2, 3, 4, 5, 6} sehingga (7) = 6.
Z
10 = {1, 3, 7, 9} sehingga (10) = 4.
Dari definisi di atas, jelas
(n) = |Zn
|,
(n) adalah ukuran (kardinalitas) dari grup kali Zn
.
Fungsi Euler (Totient)
Teorema
Jika p adalah prima maka (p) = p  1.
Bukti :
Karena p prima, semua bilangan-bilangan 1, 2, ..., p  1 saling
prima dengan p. Jadi
Z
p = {1, 2, ..., p  1}
dan
|Z
p| = p  1.
Fungsi Euler (Totient)
Teorema
Jika p dan q adalah dua bilangan prima yang berbeda (p  q),
maka (pq) = (p  1)(q  1).
Bukti :
Di antara pq  1 bilangan-bilangan asli
1, 2, … , pq – 1
bilangan-bilangan yang tidak relatif prima terhadap p adalah
p, 2p, 3p, … , (q – 1)p
dan yang tidak relatif prima terhadap q adalah
q, 2q, 3q, … , (p – 1)q
Total banyaknya bilangan yang tidak saling prima dengan pq adalah
(q – 1) + (p – 1). Jadi banyak bilangan asli k dengan 1  k < pq yang
saling prima dengan pq adalah
(pq  1)  [(q  1) + (p  1)] = pq  p  q + 1 = (p  1)(q  1).
Fungsi Euler (Totient)
Teorema
Jika p prima dan a adalah bil bulat yang bukan kelipatan p, maka
ap-1 ≡ 1 mod p
Bukti :
Sebab ukuran grup kali Z
p = {1, 2, ..., p  1} adalah p  1
sehingga untuk setiap z  Z
p berlaku zp1 = 1. Dalam bahasa
teori bilangan, kesamaan ini menyatakan kongruensi
zp1  1 mod p..
Karena setiap bilangan bulat positif kongruen dengan suatu z 
Z
p, yaitu a  z mod p, maka dari Teorema 2.3
ap1  zp1 mod p  1 mod p.
Fungsi Euler (Totient)
Akibat (Teorema Fermat)
Teorema fermat diatas dapat dinyatakan secara lebih luas
dengan menghilangkan syarat FPB(a,p)=1 sebagai berikut.
Jika p suatu bilangan prima, maka ap ≡ a (mod p) untuk setiap
bilangan bulat a.
Fungsi Euler (Totient)
Definisi :
Fungsi Euler : N  N didefinisikan melalui aturan pengawanan
(n) = banyaknya bilangan asli k dengan 1  k < n yang saling prima
dengan n.
Contoh :
Z
7 = {1, 2, 3, 4, 5, 6} sehingga (7) = 6.
Z
10 = {1, 3, 7, 9} sehingga (10) = 4.
Dari definisi di atas, jelas
(n) = |Zn
|,
(n) adalah ukuran (kardinalitas) dari grup kali Zn
.
Teorema
Jika p adalah prima maka (p) = p  1.
Fungsi Euler (Totient)
Teorema
Jika p dan q adalah dua bilangan prima yang berbeda (p  q),
maka (pq) = (p  1)(q  1).
Teorema
Misalkan p prima dan 0 < a < p. maka
ap-1 ≡ 1 mod p
Kesepakatan Kunci Diffie-Hellman
p
g
Y A
X
A mod

p
g
Y B
X
B mod

Kunci Diffie dan Hellman merupakan sistem kriptografi kunci publik pertama
yang melindungi informasi tanpa harus menggunakan saluran khusus untuk
mengirimkan kunci rahasia.
Pengguna sistem secara bersama menggunakan satu bilangan prima p dan
satu generator g dari grup Zp
 yang bisa diakses publik.
p
g
Y C
X
C mod

Kesepakatan Kunci Diffie-Hellman
Supaya lebih aman, pilih bilangan prima Sophie-Germain, yaitup bilangan
prima p yang memenuhi p = 2q + 1, untuk suatu bilangan prima q
( ) mod
A
X
AB B
Z Y p
 ( ) mod .
B
X
BA A
Z Y p

A B
Proposisi: ZAB = ZBA.
Bukti :
p
g
p
Y
Z A
B
A X
X
X
B
AB mod
)
(
mod
)
( 

mod ( ) mod .
A B B
X X X
A BA
g p Y p Z
  
Kesepakatan Kunci Diffie-Hellman
Contoh :
Misalkan : p = 23 = 2(11) + 1, g = 5.
Pilih : XA = 7, XB = 13. Kedua kunci berikut adalah kunci publik (dikirim melalui
kanal publik, jadi bisa diakses publik)
YA = 57 mod 23 = 17, YB = 513 mod 23 = 21.
A dan B masing-masing menghitung dan sepakat dengan kunci rahasia
bersama berikut:
ZAB = 217 mod 23 = 10 , ZBA = 1713 mod 23 = 10.
A dan B mempunyai kunci rahasia bersama, yaitu 10.
Tugas
Kunci umum (publik) p = 373 dan
semua mhs menggunakan satu
generator g dari Z73
x.
Setiap mhs memilih kunci rahasia XA
berupa 5 angka terakhir (urutan
dibalik) dari No. Stb mhs. Kunci public.
Cari 5 teman.
11. Tulis semua kunci public 5 teman saudara
CIPHER SHAMIR
Sistem kunci publik yang memungkinkan dua pihak untuk bertukar pesan
melalui saluran terbuka. Semua user bersama-sama menggunakan satu
bilangan prima p sebagai satu-satunya parameter publik
A B
Langkah - langkah
1. A akan mengirim m ke B
2. - A memilih dua kunci rahasia cA dan dA = cA
-1 yang relatif prima terhadap p  1
- B memilih dua kunci rahasia cB dan dB = cB
-1 yang relatif prima
terhadap p  1
m
3. Jika m < p
maka m dikirimkan sekaligus
3. Jika m ≥ p
maka pesan diwakili oleh barisan blok-blok m1, m2, … , mt
di mana masing-masing mi < p, dan blok-blok ini dikirimkan secara bergilir
sesuai urutannya dalam pesan m.
CIPHER SHAMIR
Berikut adalah protokol pengiriman setiap blok m < p.
Langkah 1 : A menghitung p
m
x A
c
mod
1 
dan mengirimkan x1 ke B melalui kanal publik.
Langkah 2 : Setelah merima x1, B menghitung
Langkah 3 : Setelah merima x2, A menghitung
Langkah 4 : Setelah merima x3, B menghitung
dan mengirimkan x2 ke A melalui kanal publik.
dan mengirimkan x3 ke B melalui kanal publik.
p
x
x B
c
mod
1
2 
p
x
x A
d
mod
2
3 
p
x
x B
d
mod
3
4 
CIPHER SHAMIR
Contoh :
A ingin mengirim pesan m = 10 kepada B,
p = 23
A memilih cA = 7 yang relatif prima terhadap 22 = p  1
(yaitu FPB(7,22) = 1) kemudian memperoleh dA = 19.
B memilih cB = 5 dengan FPB(5, 22) = 1 dan memperoleh dB = 9.
langkah-langkah protokol Shamir adalah sebagai berikut
(Langkah 1) A  B: x1 = 107 mod 23 = 14.
(Langkah 2) B  A: x2 = 145 mod 23 = 15.
(Langkah 3) A  B : x3 = 1519 mod 23 = 19.
(Langkah 4) B menghitung x4 = 199 mod 23 = 10.
B menerima pesan m = 10.
ENKRIPSI ELGAMAL
p
g
d i
c
i mod

Pilih p prima. Setiap pengguna kemudian memilih sendiri kunci pribadi ci,
1 < ci < p – 1,
Kemudian setiap pengguna memiliki kunci publik
Enkripsi ElGamal merupakan sistem kriptografi kunci publik yang memecahkan
masalah komunikasi pesan rahasia satu sama lain dengan hanya satu kali
menyampaikan pesan tanpa harus melalui saluran komunikasi khusus yang aman
.
ENKRIPSI ELGAMAL
Langkah 1. A membangkitkan bilangan acak k dengan 1 < k ≤ p – 2,
menghitung kunci publik
A B
mod
k
B
e m d p
 
r = gk mod p
mengirimkan kunci publik (r, e) ke pengguna B melalui kanal publik
Langkah 2. B setelah menerima (r, e) menghitung
1
' mod
B
p c
m e r p
 
 
m
ENKRIPSI ELGAMAL
Contoh :
Pesan m = 15 dikirimkan dari A ke B
p = 23, g =5 dan pengguna B memilih bilangan rahasia cB = 13.
B dengan (3.11) menghitung kunci publik
dB = 513 mod 23 = 21.
Pengguna A membangkitkan bilangan acak k,
misalnya didapat k = 7 dan dengan (2.25) dan (2.26) menghitung
r = 57 mod 23 = 17,
e = 15217 mod 23 = 1510 mod 23 = 12.
A mengirim B pesan terenkripsi sebagai pasangan angka (17,12) dan dengan (2.27) B
menghitung
.
15
23
mod
7
12
23
mod
17
12
23
mod
17
12
' 9
13
1
23






 

m
ENKRIPSI RSA DAN FUNGSI TRAPDOOR
Fakta 2 : Masalah memfaktorkan bilangan-bilangan bulat n = pq dengan p
dan q adalah bilangan prima yang berukuran kurang lebih sama,
yaitu menemukan bilangan prima p dan q jika diberikan n = pq,
adalah sangat sulit (atau secara komputasi infeasible) apabila p dan
q cukup besar
NB: Pengertian ‘cukup besar’ relatif, selalu berubah dan bertambah besar seiring
perkembangan teknologi
Fungsi Trapdoor yang dipakai pada sistem RSA didasarkan pada dua
fakta teori bilangan berikut:
Fakta 1 : Pengujian untuk menentukan bilangan prima adalah relatif
mudah
ENKRIPSI RSA DAN FUNGSI TRAPDOOR
Setiap pengguna memilih secara acak dua bilangan prima p dan q yang
berukuran besar dan kemudian menghitung
N = pq
Selanjutnya pengguna tersebut menghitung
( 1)( 1)
p q
   
1
mod 

cd
dan memilih bilangan d <  yang relatif prima terhadap  . Kemudian dengan
menggunakan Algoritma Euklid yang diperluas, dicari bilangan c = d-1 dengan
KRIPTOGRAFI RSA
Langkah 1: Alice mengenkripsi pesan sebagai berikut
mod
B
d
B
e m N

' mod .
B
c
B
m e N

Alisa Bob
m
Langkah 2: Bob, setelah menerima pesan terenkripsi, menghitung
menggunakan kunci publik Bob (dB) dan mengirimkan
e melalui saluran terbuka/publik.
KRIPTOGRAFI RSA
Contoh :
Misalkan Alisa ingin mengirim pesan m = 15 ke Bob.
Misalkan parameter untuk Bob adalah
pB = 3, qB = 11, NB = 33, dB = 3
(3 adalah saling prima terhdp (33) = 20). Dengan menggunakan algoritma
Euklid yang diperluas, diperoleh cB = 7 (Periksa dBcB mod 20 = 37 mod 20 =
1). Enkripsi terhadap m dengan menggunakan (3.18​​) :
e = 153 mod 33 = 15215 mod 33 = 2715 mod 33 = 9.
Alisa mengirim bilangan 9 untuk Bob melalui saluran terbuka. Hanya Bob tahu
cB = 7 sehingga Bob mendekripsi dengan (3.19):
.
15
33
mod
9
15
15
33
mod
9
9
)
9
(
33
mod
9
' 2
2
2
2
7








m
KRIPTOGRAFI RSA
MODIFIKASI RSA DENGAN KONSEP ‘DIGITAL SIGNATURE’
A B
m
A akan mengirimkankan m = (m1, m2, ..., mn) dengan tandatangan digital
dengan menggunakan fungsi hash h(m) (Konsep fungsi hash akan dibahas
kemudian). Setelah A menghitung nilai fungsi hash h = h(m) dan s = hc mod N,
A mengirimkan pasangan (m, s) ke B. Penerima pesan tinggal menghitung
w = sd mod N
dan mencocokkan nilai ini dengan nilai h. Jika sama, pesan dipercaya berasal
dari Alice dan dikirim tanpa perubahan. Pesan asli m bisa diperoleh dengan
cara yang sudah dibahas lebih dulu.

More Related Content

Similar to BahanAjar Kripto gscfsdfgerffsdfdsa.pptx

Sistem Kriptografi Klasik Berbasis Substitusi
Sistem Kriptografi Klasik Berbasis SubstitusiSistem Kriptografi Klasik Berbasis Substitusi
Sistem Kriptografi Klasik Berbasis SubstitusiFanny Oktaviarti
 
Kriptografi Klasik belajar kriptografi mudah
Kriptografi Klasik belajar kriptografi mudahKriptografi Klasik belajar kriptografi mudah
Kriptografi Klasik belajar kriptografi mudahmrdonnie
 
asktingkatan3-kriptografi-sifer-190308061345.pdf
asktingkatan3-kriptografi-sifer-190308061345.pdfasktingkatan3-kriptografi-sifer-190308061345.pdf
asktingkatan3-kriptografi-sifer-190308061345.pdfssuser09b4cf
 
Ask tingkatan3 kriptografi-sifer
Ask tingkatan3 kriptografi-siferAsk tingkatan3 kriptografi-sifer
Ask tingkatan3 kriptografi-siferRoslina Abdullah
 
Metode enkripsi caesar cipher
Metode enkripsi caesar cipherMetode enkripsi caesar cipher
Metode enkripsi caesar cipherBobby Chandra
 
Kriptografi - Algoritma Kriptografi Klasik (bagian 2)
Kriptografi - Algoritma Kriptografi Klasik (bagian 2)Kriptografi - Algoritma Kriptografi Klasik (bagian 2)
Kriptografi - Algoritma Kriptografi Klasik (bagian 2)KuliahKita
 
IF5110 - Mesin Turing (Bagian 1).pdf
IF5110 - Mesin Turing (Bagian 1).pdfIF5110 - Mesin Turing (Bagian 1).pdf
IF5110 - Mesin Turing (Bagian 1).pdfMunawirMunawir15
 
Tugas rekayasa komputasional Enkripsi
Tugas rekayasa komputasional EnkripsiTugas rekayasa komputasional Enkripsi
Tugas rekayasa komputasional EnkripsiAlfiandi Hakim
 
Kriptografi klasik
Kriptografi klasikKriptografi klasik
Kriptografi klasiklikut101010
 

Similar to BahanAjar Kripto gscfsdfgerffsdfdsa.pptx (20)

Sistem Kriptografi Klasik Berbasis Substitusi
Sistem Kriptografi Klasik Berbasis SubstitusiSistem Kriptografi Klasik Berbasis Substitusi
Sistem Kriptografi Klasik Berbasis Substitusi
 
7.algoritma kriptografi klasik (bag 3)xx
7.algoritma kriptografi klasik (bag 3)xx7.algoritma kriptografi klasik (bag 3)xx
7.algoritma kriptografi klasik (bag 3)xx
 
Uas k eamanan komputer
Uas   k eamanan komputerUas   k eamanan komputer
Uas k eamanan komputer
 
ikh323-03
ikh323-03ikh323-03
ikh323-03
 
Kriptografi Klasik belajar kriptografi mudah
Kriptografi Klasik belajar kriptografi mudahKriptografi Klasik belajar kriptografi mudah
Kriptografi Klasik belajar kriptografi mudah
 
Kripto Klasik
Kripto KlasikKripto Klasik
Kripto Klasik
 
5. algoritma kriptografi klasik (bag 1)xx
5. algoritma kriptografi klasik (bag 1)xx5. algoritma kriptografi klasik (bag 1)xx
5. algoritma kriptografi klasik (bag 1)xx
 
asktingkatan3-kriptografi-sifer-190308061345.pdf
asktingkatan3-kriptografi-sifer-190308061345.pdfasktingkatan3-kriptografi-sifer-190308061345.pdf
asktingkatan3-kriptografi-sifer-190308061345.pdf
 
Ask tingkatan3 kriptografi-sifer
Ask tingkatan3 kriptografi-siferAsk tingkatan3 kriptografi-sifer
Ask tingkatan3 kriptografi-sifer
 
Metode enkripsi caesar cipher
Metode enkripsi caesar cipherMetode enkripsi caesar cipher
Metode enkripsi caesar cipher
 
9.algoritma kriptografi klasik (bag 5)xx
9.algoritma kriptografi klasik (bag 5)xx9.algoritma kriptografi klasik (bag 5)xx
9.algoritma kriptografi klasik (bag 5)xx
 
Kriptografi - Algoritma Kriptografi Klasik (bagian 2)
Kriptografi - Algoritma Kriptografi Klasik (bagian 2)Kriptografi - Algoritma Kriptografi Klasik (bagian 2)
Kriptografi - Algoritma Kriptografi Klasik (bagian 2)
 
Kriptografi reg 05
Kriptografi reg 05Kriptografi reg 05
Kriptografi reg 05
 
8.algoritma kriptografi klasik (bag 4)xx
8.algoritma kriptografi klasik (bag 4)xx8.algoritma kriptografi klasik (bag 4)xx
8.algoritma kriptografi klasik (bag 4)xx
 
Des
DesDes
Des
 
Kriptografi
KriptografiKriptografi
Kriptografi
 
Kriptografi
KriptografiKriptografi
Kriptografi
 
IF5110 - Mesin Turing (Bagian 1).pdf
IF5110 - Mesin Turing (Bagian 1).pdfIF5110 - Mesin Turing (Bagian 1).pdf
IF5110 - Mesin Turing (Bagian 1).pdf
 
Tugas rekayasa komputasional Enkripsi
Tugas rekayasa komputasional EnkripsiTugas rekayasa komputasional Enkripsi
Tugas rekayasa komputasional Enkripsi
 
Kriptografi klasik
Kriptografi klasikKriptografi klasik
Kriptografi klasik
 

Recently uploaded

UKURAN PENTYEBARAN DATA PPT KELOMPOK 2.pptx
UKURAN PENTYEBARAN DATA PPT KELOMPOK 2.pptxUKURAN PENTYEBARAN DATA PPT KELOMPOK 2.pptx
UKURAN PENTYEBARAN DATA PPT KELOMPOK 2.pptxzidanlbs25
 
pertemuan-3-distribusi pada-frekuensi.ppt
pertemuan-3-distribusi pada-frekuensi.pptpertemuan-3-distribusi pada-frekuensi.ppt
pertemuan-3-distribusi pada-frekuensi.pptAhmadSyajili
 
Manajemen Lalu Lintas Baru Di Jalan Selamet Riyadi
Manajemen Lalu Lintas Baru Di Jalan Selamet RiyadiManajemen Lalu Lintas Baru Di Jalan Selamet Riyadi
Manajemen Lalu Lintas Baru Di Jalan Selamet RiyadiCristianoRonaldo185977
 
Geologi Jawa Timur-Madura Kelompok 6.pdf
Geologi Jawa Timur-Madura Kelompok 6.pdfGeologi Jawa Timur-Madura Kelompok 6.pdf
Geologi Jawa Timur-Madura Kelompok 6.pdfAuliaAulia63
 
MATERI SESI 2 KONSEP ETIKA KOMUNIKASI.pptx
MATERI SESI 2 KONSEP ETIKA KOMUNIKASI.pptxMATERI SESI 2 KONSEP ETIKA KOMUNIKASI.pptx
MATERI SESI 2 KONSEP ETIKA KOMUNIKASI.pptxrikosyahputra0173
 
MARIA NOVILIA BOISALA FASILITATOR PMM.pptx
MARIA NOVILIA BOISALA FASILITATOR PMM.pptxMARIA NOVILIA BOISALA FASILITATOR PMM.pptx
MARIA NOVILIA BOISALA FASILITATOR PMM.pptxmariaboisala21
 
Menggunakan Data matematika kelas 7.pptx
Menggunakan Data matematika kelas 7.pptxMenggunakan Data matematika kelas 7.pptx
Menggunakan Data matematika kelas 7.pptxImahMagwa
 

Recently uploaded (7)

UKURAN PENTYEBARAN DATA PPT KELOMPOK 2.pptx
UKURAN PENTYEBARAN DATA PPT KELOMPOK 2.pptxUKURAN PENTYEBARAN DATA PPT KELOMPOK 2.pptx
UKURAN PENTYEBARAN DATA PPT KELOMPOK 2.pptx
 
pertemuan-3-distribusi pada-frekuensi.ppt
pertemuan-3-distribusi pada-frekuensi.pptpertemuan-3-distribusi pada-frekuensi.ppt
pertemuan-3-distribusi pada-frekuensi.ppt
 
Manajemen Lalu Lintas Baru Di Jalan Selamet Riyadi
Manajemen Lalu Lintas Baru Di Jalan Selamet RiyadiManajemen Lalu Lintas Baru Di Jalan Selamet Riyadi
Manajemen Lalu Lintas Baru Di Jalan Selamet Riyadi
 
Geologi Jawa Timur-Madura Kelompok 6.pdf
Geologi Jawa Timur-Madura Kelompok 6.pdfGeologi Jawa Timur-Madura Kelompok 6.pdf
Geologi Jawa Timur-Madura Kelompok 6.pdf
 
MATERI SESI 2 KONSEP ETIKA KOMUNIKASI.pptx
MATERI SESI 2 KONSEP ETIKA KOMUNIKASI.pptxMATERI SESI 2 KONSEP ETIKA KOMUNIKASI.pptx
MATERI SESI 2 KONSEP ETIKA KOMUNIKASI.pptx
 
MARIA NOVILIA BOISALA FASILITATOR PMM.pptx
MARIA NOVILIA BOISALA FASILITATOR PMM.pptxMARIA NOVILIA BOISALA FASILITATOR PMM.pptx
MARIA NOVILIA BOISALA FASILITATOR PMM.pptx
 
Menggunakan Data matematika kelas 7.pptx
Menggunakan Data matematika kelas 7.pptxMenggunakan Data matematika kelas 7.pptx
Menggunakan Data matematika kelas 7.pptx
 

BahanAjar Kripto gscfsdfgerffsdfdsa.pptx

  • 1. Kripto • Kriptologi --- Seni dan sains pembuatan dan pemecahan kode rahasia (yang dikirim melalui komunikasi digital) • Kriptografi --- seni dan sains pembuatan kode rahasia (yang dikirim melalui komunikasi digital) • Kriptanalisis --- seni dan sains pemecahan kode rahasia (yang dikirim melalui komunikasi digital) • Kripto --- termasuk semua di atas
  • 2. Kripto • Suatu cipher atau sistem kripto digunakan untuk mengenkriptsi the pesan asli (plaintext) • Hasil dari enskriptsi teks cipher • Teks chiper didekriptsi untuk mendapatkan pesan asli • Kunci digunakan untuk menciptakan konfigurasi sistem kripto • Kunci simetri dari sistem kripto adalah satu kunci yang digunakan untuk mengenkriptsi dan juga untuk mendekriptsi • Kunci publik dari sistem kripto terdiri atas satu kunci publik untuk enkriptsi dan satu kunci pribadi untuk mendekriptsi atau menandatangani (tanda-tangan digital)
  • 3. Kripto • Asumsi Dasar: • Penyerang/pembobol mengetahui cara kerja sistem • Hanya kunci dari sistem yang dirahasiakan • (Juga dikenal sebagai Prinsip Kerckhoffs • Algoritma kripto tidak dirahasiakan) • Mengapa asumsi ini dibuat? • Pengalaman menunjukkan bahwa sifat rahasia dari algoritma sangat lemah ketika diimplementasikan • Algoritma rahasia tidak pernah bisa dirahasiakan selamanya • Lebih baik orang mendapatkan kelemahan algoritma kripto sebelum algoritma tersebut terlanjur digunakan
  • 4. Kripto sebagai kotak hitam Pesan asli kunci kunci pesan asli ciphertext penggunaan kripto enkript dekript
  • 5. 5 Classical (secret-key) cryptosystems Kriptosistem - cipher Kriptografi bergelut dengan masalah pengiriman pesan (teks asli) lewat kanal tak aman yang mungkin bisa disadap oleh adversary (misalnya oleh cryptanalyst) .
  • 6. 6 Classical (secret-key) cryptosystems Komponen dari sisem kripto: Ruang pesan (asli) P – sebuah himpunan pesan asli atas suatu alfabet  Ruang teks kripto C – sebuah himpunan teks-teks kripto (teks cipher) atas alfabet  Ruang kunci K – himpunan kunci-kunci Setiap kunci k menentukan sepasang algoritma enkriptsi algorithm ek dan algoritma deskriptsi dk sedemikian hingga berlaku 1. untuk setiap teks asli w, ek (w) adalah teks krypto yang dihasilkan dan 2. w  dk(ek (w)) , yaitu w adalah salah satu hasil deskriptsi thd ek (w); atau 2. w = dk(ek (w)). , yaitu w adalah saltu-satunya hasil deskriptsi thd ek (w);
  • 7. Substitusi Sederhana • Teks asli: fourscoreandsevenyearsago • Alfabet:  = {a, b, c, ..., z},  = {A, B, C, ..., Z} • Kunci: 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 D E F G H I J K L M N O P Q R S T U V W X Y Z A B z C  Teks Cipher: IRXUVFRUHDAGVHYHABHDUVDIR  Contoh Chiper Caesar dengan geseran 3 Huruf asli Huruf chiper
  • 8. Part 1  Cryptography 8 Deskirptsi Chiper Ceasar •Teks asli: spongebobsquarepants 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 D E F G H I J K L M N O P Q R S T U V W X Y Z A B z C Huruf asli Huruf Chiper Misalkan sudah diketahui bahwa chiper Ceasar digunakan Teks Chiper: VSRQJHEREVTXDUHSDQWU
  • 9. Not-so-Simple Substitution • Shift by n for some n  {0,1,2,…,25} • Then key is n • Example: key = 7 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 H I J K L M N O P Q R S T U V W X Y Z A B C D E F z G Plaintext Ciphertext 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 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
  • 10. Part 1  Cryptography 10 Cryptanalysis I: Try Them All (Exhaustive key search) • A simple substitution (shift by n) is used • But the key is unknown • Given ciphertext: CSYEVIXIVQMREXIH • How to find the key? • Only 26 possible keys --- try them all! • Solution: key = 4
  • 11. 11 Classical (secret-key) cryptosystems Oracle enkriptsi dan deskriptsi (encripting and decripting oracles) Contoh: Saudara menggunakan kartu kredit (atau kartu ATM, kartu debit dsb) untuk mengambil uang di mesin ATM. Secara internal (tidak kelihatan) terjadi komunikasi antara A (= mesin ATM) dengan B (= komputer server bank). A (mesin ATM) mengirimkan nomor/pesan asli m (= kombinasi no rahasia kartu dengan no pin saudara) untuk mengirim nomor/pesan sandi s = E(m) kepada B (= komputer server) . Dengan menggunakan kunci rahasia yang sama, B merubah pesan s kembali ke m untuk mendapatkan nomor identitas kartu yang asli + identitas saudara. Jika nomor identitas ini valid, maka B memerintahkan A (= mesin ATM) untuk mengeluarkan dana sesuai permintaan saudara. Baik saudara atau pegawai bank tidak ada yang mengetahui pesan asli m, hanya komputer server yang mengetahui atau hasil penyandian s. Bilangan m tidak sembarangan, karena m harus memenuhi syarat2 tertentu yang ketat (m  ruang pesan). Jika tidak demikian (tak ada syarat untuk m dan s bisa diketahui) maka saudara bisa bikin sendiri dua pesan palsu m1 dan m2 kemudian mengetahui hasil penyandiannya: s1 dan s2, maka saudara bisa mencoba-coba sampai mendapatkan pesan rahasia orang lain yang valid dan mendapatkan cara untuk menarik dana milik orang tsb.
  • 12. 12 Classical (secret-key) cryptosystems Cryptanalysis II (thd affine crypto algorithm): ea,b(x) = (ax + b) mod 26 = (xa+b) mod 26 where gcd(a, 26) = 1. (Number of keys: 12 × 26 = 312.) Example: Assume that an English plaintext is divided into blocks of 5 letter and encrypted by an AFINE cryptosystem (ignoring space and interpunctions) as follows: How to find the plaintext? B H J U H N B U L S V U L R U S L Y X H O N U U N B W N U A X U S N L U Y J S S W X R L K G N B O N U U N B W S W X K X H K X D H U Z D L K X B H J U H B N U O N U M H U G S W H U X M B X R W X K X L U X B H J U H C X K X A X K Z S W K X X L K O L J K C X L C M X O N U U B V U L R R W H S H B H J U H N B X M B X R W X K X N O Z L J B X X H B N F U B H J U H L U S W X G L L K Z L J P H U U L S Y X B J K X S W H S S W X K X N B H B H J U H Y X W N U G S W X G L L K
  • 13. 13 Classical (secret-key) cryptosystems Cryptanalysis’s Tables frequency analysis of chiphertext (for plaintext) and frequency table for English : First guess: E = X, T = U Encodings: 4a + b = 23 (mod 26) xa + b = y 19a + b = 20 (mod 26) Predicted solution : a = 5, b = 3  a-1 = Translation table provides from the above cryptotext the plaintext that starts with KGWTG CKTMO OTMIT DMZEG, what does not make a sense. % % % E 12.31 L 4.03 B 1.62 T 9.59 D 3.65 G 1.61 A 8.05 C 3.20 V 0.93 O 7.94 U 3.10 K 0.52 N 7.19 P 2.29 Q 0.20 I 7.18 F 2.28 X 0.20 S 6.59 M 2.25 J 0.10 R 6.03 W 2.03 Z 0.09 H 5.14 Y 1.88 5.27 70.02 24.71 X - 32 J - 11 D - 2 U - 30 O - 6 V - 2 H - 23 R - 6 F - 1 B - 19 G - 5 P - 1 L - 19 M - 4 E - 0 N - 16 Y - 4 I - 0 K - 15 Z - 4 Q - 0 S - 15 C - 3 T - 0 W - 14 A - 2 B H J U H N B U L S V U L R U S L Y X H O N U U N B W N U A X U S N L U Y J S S W X R L K G N B O N U U N B W S W X K X H K X D H U Z D L K X B H J U H B N U O N U M H U G S W H U X M B X R W X K X L U X B H J U H C X K X A X K Z S W K X X L K O L J K C X L C M X O N U U B V U L R R W H S H B H J U H N B X M B X R W X K X N O Z L J B X X H B N F U B H J U H L U S W X G L L K Z L J P H U U L S Y X B J K X S W H S S W X K X N B H B H J U H Y X W N U G S W X G L L K crypto A B C D E F G H I J K L M N O P Q R S T U V W X plain P K F A V Q L G B W R M H C X S N I D Y T O J E Y Z Z U
  • 14. 14 Classical (secret-key) cryptosystems Cryptanalysis’s Second guess: E = X, A = H Equations 4a + b = 23 (mod 26) b = 7 (mod 26) Solutions: a = 4 or a = 17 and therefore a=17 This gives the translation table and the following plaintext from the above cryptotext S A U N A I S N O T K NO W N T O B E A F I N N I S H I N V E N T I O N B U T T H E W O R D I S F I N N I S H T H E R E A R E M A N Y M O R E SA U N A S I N F I N L A N D T H A N E L S E W H E R E O N E S A U N A P E R E VE R Y T H R E E O R F O U R P E O P L EF I N N S K N O W W H A T A S A U N A I S E L S E W H E R E I F Y O U S E E A S I G N S A U N A O N T H E D O O R Y O UC A N N O T B E S U R E T H A T T H E RE I S A S A U N A B E H I N D T H E D OO R crypto A B C D E F G H I J K L M N O P Q R S T U V W X plain V S P M J G D A X U R O L I F C Z W T Q N K H E Y Z B Y
  • 15. Part 1  Cryptography 15 Even-less-Simple Substitution • Key is some permutation of letters • Need not be a shift • For example 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 J I C A X S E Y V D K W B Q T Z R H F M P N U L G z O Plaintext Ciphertext  Then 26! > 288 possible keys!
  • 16. Part 1  Cryptography 16 Cryptanalysis II • Can’t try all 288 simple substitution keys • Can we be more clever? • English letter frequency counts… 0,00 0,02 0,04 0,06 0,08 0,10 0,12 0,14 A C E G I K M O Q S U W Y
  • 17. 17 Classical (secret-key) cryptosystems Polyalphabetic Substitution Cryptosystems Playfair cryptosystem Invented around 1854 by Ch. Wheatstone. Key - a Playfair square is defined by a word w of length at most 25. In w repeated letters are then removed, remaining letters of alphabets (except j) are then added and resulting word is divided to form an 5 x 5 array (a Playfair square). Q K E O T X C L P R W Y V M B G N F A H U I Z D S Encryption: of a pair of letters x,y • If x and y are in the same row (column), then they are replaced by the pair of symbols to the right (bellow) them. • If x and y are in different rows and columns they are replaced by symbols in the opposite corners of rectangle created by x and y. Example: PLAYFAIR is encrypted as LCMNNFCS Playfair was used in World War I by British army. Playfair square:
  • 18. 18 Classical (secret-key) cryptosystems Polyalphabetic Substitution Cryptosystems VIGENERE and AUTOCLAVE cryptosystems Several of the following polyalphabetic cryptosystems are modification of the CAESAR cryptosystem. A 26 ×26 table is first designed with the first row containing a permutation of all symbols of alphabet and all columns represent CAESAR shifts starting with the symbol of the first row. Secondly, for a plaintext w a key k is a word of the same length as w. Encryption: the i-th letter of the plaintext - wi is replaced by the letter in the wi-row and ki- column of the table. VIGENERE cryptosystem: a short keyword p is chosen and k = Key(repeated cyclicly) VIGENERE is actually a cyclic version of the CAESAR cryptosystem. AUTOCLAVE cryptosystem: k = Key + (part of original message).
  • 19. 19 Classical (secret-key) cryptosystems Polyalphabetic Substitution Cryptosystems VIGENERE and AUTOCLAVE cryptosystems Example: Keyword: H A M B U R G Plaintext: I N J E D E M M E N S C H E N G E S I C H T E S T E H T S E I N E G Vigenere-key: H A M B U R G H A M B U R G H A M B U R G H A M B U R G H A M B U R Autoclave-key: H A M B U R G I N J E D E M M E N S C H E N G E S I C H T E S T E H Vigerere-cryp.: P N V F X V S T E Z T W Y K U G Q T C T N A E E V Y Y Z Z E U O Y X Autoclave-cryp.: P N V F X V S U R W W F L Q Z K R K K J L G K W L M J A L I A G I N
  • 20. 20 Classical (secret-key) cryptosystems BREAKING VIGENERE CRYPTO SYSTEM CRYPTOANALYSIS of cryptotexts produced by VINEGAR cryptosystem 1.Task 1 -- to find the length of the key Kasiski method (1852) - invented also by Charles Babbage (1853). Basic observation If a subword of a plaintext is repeated at a distance that is a multiple of the length of the key, then the corresponding subwords of the cryptotext are the same. Example, cryptotext: Substring ''CHR'' occurs in positions 1, 21, 41, 66, 71: expected keyword length is therefore GCD(20, 20, 20, 15) = 5. CHRGQPWOEIRULYANDOSHCHRIZKEBUSNOFKYWROPDCHRKGAXBNRHROAKERBKSCHRSIWADFTHNNDG Method. Determine the greatest common divisor of the distances between identical subwords (of length 3 or more) of the cryptotext.
  • 21. 21 Classical (secret-key) cryptosystems CRYPTOANALYSIS of cryptotexts produced by VINEGAR cryptosystem Friedman method Let ni be the number of occurrences of the i-th letter in the cryptotext. Let l be the length of the keyword. Let n be the of the cryptotext. Then it holds Once the length of the klength eyword is found it is easy to determine the key using the statistical (frequency analysis)method of analyzing monoalphabetic cryptosystems.                26 1 1 1 065 . 0 038 . 0 1 027 . 0 , i n n n n n I n n i i I l
  • 22. 22 Classical (secret-key) cryptosystems Derivation of the Friedman method Assume that a cryptotext is organized into l columns headed by the letters of the keyword First observation Each column is obtained using the CAESAR cryptosystem. Probability that two randomly chosen letters are the same in - the same column is 0.065. - different columns is 0.038. The number of pairs of letters in the same column: The number of pairs of letters in different columns: The expect number A of pairs of equals letters is Since one gets the formula for l from the previous slide.     l l n n l n l n l 2 2 1         l l n n l n l l 2 2 1 2 2 2         038 . 0 065 . 0 2 1 2 2       l l n l l n n A         065 . 0 038 . 0 027 . 0 1 1 2 1       n l I n l A n n letters Sl S1 S2 S3 . . . Sl x1 x2 x3 . . . Xl xl+1 xl+2 xl+3 X xl+1 xl+2 xl+3 . . . x3l . . . .
  • 23. 23 Classical (secret-key) cryptosystems ONE-TIME PAD cryptosystem – Vernam’s cipher Binary case: plaintext w key k are binary words of the same length cryptotext c Encryption: c = w k (is the Nim sum or modulo 2 addition) Decryption: w = c k Example: w = 101101011 k = 011011010 c = 110110001 What happens if the same key is used twice or 3 times for encryption? c1 = w1 k, c2 = w2 k, c3 = w3 k c1 c2 = w1 w2 c1 c3 = w1 w3 c2 c3 = w2 w3
  • 24. Part 1  Cryptography 24 One-time Pad e=000 h=001 i=010 k=011 l=100 r=101 s=110 t=111 h e i l h i t l e r 001 000 010 100 001 010 111 100 000 101 111 101 110 101 111 100 000 101 110 000 110 101 100 001 110 110 111 001 110 101 s r l h s s t h s r Encryption: Plaintext  Key = Ciphertext Plaintext: Key: Ciphertext:
  • 25. Part 1  Cryptography 25 One-time Pad e=000 h=001 i=010 k=011 l=100 r=101 s=110 t=111 s r l h s s t h s r 110 101 100 001 110 110 111 001 110 101 101 111 000 101 111 100 000 101 110 000 011 010 100 100 001 010 111 100 000 101 k i l l h i t l e r Ciphertext: “key”: “Plaintext”: Double agent claims sender used “key”:
  • 26. Part 1  Cryptography 26 One-time Pad e=000 h=001 i=010 k=011 l=100 r=101 s=110 t=111 s r l h s s t h s r 110 101 100 001 110 110 111 001 110 101 111 101 000 011 101 110 001 011 101 101 001 000 100 010 011 000 110 010 011 000 h e l i k e s i k e Ciphertext: “Key”: “Plaintext”: Sender is captured and claims the key is:
  • 27. Part 1  Cryptography 27 Stream Ciphers • Not as popular today as block ciphers • We’ll discuss two examples • A5/1 • Based on shift registers • Used in GSM mobile phone system • RC4 • Based on a changing lookup table • Used many places
  • 28. Part 1  Cryptography 28 A5/1 • A5/1 consists of 3 shift registers • X: 19 bits (x0,x1,x2,…,x18) • Y: 22 bits (y0,y1,y2,…,y21) • Z: 23 bits (z0,z1,z2, …,z22)
  • 29. Part 1  Cryptography 29 A5/1 • At each step: m = maj(x8, y10, z10) • Examples: maj(0,1,0) = 0 and maj(1,1,0) = 1 • If x8 = m then X steps • t = x18  x17  x16  x13 • xi = xi1 for i = 18,17,…,1 and x0 = t • If y10 = m then Y steps • t = y21  y20 • yi = yi1 for i = 21,20,…,1 and y0 = t • If z10 = m then Z steps • t = z22  z21  z20  z7 • zi = zi1 for i = 22,21,…,1 and z0 = t • Keystream bit is x18  y21  z22
  • 30. Part 1  Cryptography 30 A5/1 • Each value is a single bit • Key is used as initial fill of registers • Each register steps or not, based on (x8, y10, z10) • Keystream bit is XOR of right bits of registers y0 y1 y2 y3 y4 y5 y6 y7 y8 y9 y10 y11 y12 y13 y14 y15 y16 y17 y18 y19 y20 y21 z0 z1 z2 z3 z4 z5 z6 z7 z8 z9 z10 z11 z12 z13 z14 z15 z16 z17 z18 z19 z20 z21 z22 X Y Z     x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18
  • 31. Part 1  Cryptography 31 A5/1 • In this example, m = maj(x8, y10, z10) = maj(1,0,1) = 1 • Register X steps, Y does not step, and Z steps • Keystream bit is XOR of right bits of registers • Here, keystream bit will be 0  1  0 = 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 X Y Z     1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
  • 32. Part 1  Cryptography 32 Shift Register Crypto • Shift register-based crypto is efficient in hardware • Harder to implement in software • In the past, very popular • Today, more is done in software due to faster processors • Shift register crypto still used some
  • 33. Part 1  Cryptography 33 RC4 • A self-modifying lookup table • Table always contains some permutation of 0,1,…,255 • Initialize the permutation using key • At each step, RC4 • Swaps elements in current lookup table • Selects a keystream byte from table • Each step of RC4 produces a byte • Efficient in software • Each step of A5/1 produces only a bit • Efficient in hardware
  • 34. Part 1  Cryptography 34 RC4 Initialization • S[] is permutation of 0,1,…,255 • key[] contains N bytes of key for i = 0 to 255 S[i] = i K[i] = key[i (mod N)] next i j = 0 for i = 0 to 255 j = (j + S[i] + K[i]) mod 256 swap(S[i], S[j]) next j i = j = 0
  • 35. Part 1  Cryptography 35 RC4 Keystream • For each keystream byte, swap table elements and select byte i = (i + 1) mod 256 j = (j + S[i]) mod 256 swap(S[i], S[j]) t = (S[i] + S[j]) mod 256 keystreamByte = S[t] • Use keystream bytes like a one-time pad • Note: first 256 bytes must be discarded • Otherwise attacker can recover key
  • 36. Part 1  Cryptography 36 Stream Ciphers • Stream ciphers were big in the past • Efficient in hardware • Speed needed to keep up with voice, etc. • Today, processors are fast, so software-based crypto is fast enough • Future of stream ciphers? • Shamir: “the death of stream ciphers” • May be exaggerated…
  • 37. 2. Pengenalan Kunci Publik Bagian A. Sistem Kripto Berbasis Kesukaran Faktorisasi N = pq, p dan q prima
  • 38. 38 Landasan Teori: Lemma. Jika a = bq + r, maka FPB(a,b) = FPB(b,r). Algoritma Euklid. Misalkan r0 = a dan r1 = b bulat dg a  b. r0 = r1q1 + r2, 0  r2 < r1, r1 = r2q2 + r3, 0  r3 < r2, … … rn2 = rn1qn1 + rn, 0  rn < rn1, rn1 = rnqn. Lemma  FPB(a,b) = FPB(r0, r1) = FPB(r1, r2) = … = FPB(rn2, rn1) = FPB(rn1, rn) = FPB(rn, 0) = rn. Contoh 2.1: 662 = 4141 + 248, 414 = 2481 + 166, 248 = 1661 + 82, 166 = 822 + 2, 82 = 241 Lemma  FPB(662,414)=FPB(414,248)= .... =FPB(82, 2)=FPB(2, 0)=2.
  • 39. 39 Teorema 2.1 Jika a dan b adalah dua bilangan bulat positif, maka terdapat dua bilangan s dan t sedemikian rupa sehingga FPB(a,b) = sa + tb. (2.1) Nilai s dan t dlm teorem di atas bisa diperoleh melalui perluasan algoritma Euclid via barisan {sk,tk} yg didef sbb. s0 = 1, s1 = 0, t0 = 0, t1 = 1, sk+1 = sk1  qksk , tk+1 = tk1  qktk . Teorema berikut mengadopsi notasi sisa terakhir rn+1 = 0. Teorema 2.2 Jika 0  k  n + 1, maka rk = ska + tkb. Sebagai akibatnya, nilai s dan t dalam (2.1) adl s = sn dan t = tn.
  • 40. 40 Contoh 2.2: Misalkan a = 100 dan b = 35. Diagram berikut memudahkan penggunaan algoritma Euklid yang diperluas. Dari tabel di atasan, teorema 2.2 memberikan 5 = FPB(100, 35) = r3 = (1)100 + (3)35  s = 1 dan t = 3. k 0 1 2 3 4 rk 100 35 30 5 0 qk 2 1 6 sk 1 0 1 1 7 tk 0 1 2 3 20
  • 41. 41 Contoh 2.3: Sekarang misalkan a = 469 dan b = 203. Seperti Contoh 2.2, diagram berikut memudahkan implemen- tasi algoritma Euclid yang diperluas. Dari tabel di atasan, Teorema 2.2 memberikan 7 = FPB(469, 203) = r4 = 13469 + 30203  s = 13 dan t = 30. k 0 1 2 3 4 5 rk 469 203 63 14 7 0 qk 2 3 4 2 sk 1 0 1 3 13 29 tk 0 1 2 7 30 67
  • 42. Landasan Teori: Grup dari Bilangan-Bilangan Bulat Grup yang akan dibahas hanyalah grup dengan operasi tambah (atau kali) kongruen modulo n, yaitu grup Zn = {k  N | 1  k < n } Teorema 2.3 Jika (G, +) adalah grup (dalam notasi tambah) dengan banyak unsur n (yaitu |G| = n), maka untuk setiap g  G berlaku ng = 0. Contoh 2.4: Dalam Z9 = {0, 1, 2, 3, 4, 5, 6, 7 , 8} berlaku (9)(4) = 4 + 4 + 4 + 4 + 4 + 4 +4 + 4 + 4 = 0.
  • 43. Grup dari Bilangan-Bilangan Bulat Teorema 2.4 Z n = {k  N | 1  k < n, k saling prima dengan n } terhadap operasi kali kongruen modulo n merupakan grup. Contoh 2.5: Z 9 = {1, 2, 4, 5, 7, 8}, Z 10 = {1, 3, 7, 9}, Z 11 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} adalah grup (kali).
  • 44. Grup dari Bilangan-Bilangan Bulat Teorema 2.4 dalam bahasa teori bilangan Untuk setiap g  Z berlaku ng mod n = 0 atau ng  0 mod n Contoh 2.5 dalam bahasa teori bilangan (9)(4) mod 9 = (4 + 4 + 4 + 4 + 4 + 4 +4 + 4 + 4) mod 9 = 0 atau (4 + 4 + 4 + 4 + 4 + 4 +4 + 4 + 4)  0 mod 9
  • 45. Fungsi Euler (Totient) Definisi : Fungsi Euler : N  N didefinisikan melalui aturan pengawanan (n) = banyaknya bilangan asli k dengan 1  k < n yang saling prima dengan n. Contoh : Z 7 = {1, 2, 3, 4, 5, 6} sehingga (7) = 6. Z 10 = {1, 3, 7, 9} sehingga (10) = 4. Dari definisi di atas, jelas (n) = |Zn |, (n) adalah ukuran (kardinalitas) dari grup kali Zn .
  • 46. Fungsi Euler (Totient) Teorema Jika p adalah prima maka (p) = p  1. Bukti : Karena p prima, semua bilangan-bilangan 1, 2, ..., p  1 saling prima dengan p. Jadi Z p = {1, 2, ..., p  1} dan |Z p| = p  1.
  • 47. Fungsi Euler (Totient) Teorema Jika p dan q adalah dua bilangan prima yang berbeda (p  q), maka (pq) = (p  1)(q  1). Bukti : Di antara pq  1 bilangan-bilangan asli 1, 2, … , pq – 1 bilangan-bilangan yang tidak relatif prima terhadap p adalah p, 2p, 3p, … , (q – 1)p dan yang tidak relatif prima terhadap q adalah q, 2q, 3q, … , (p – 1)q Total banyaknya bilangan yang tidak saling prima dengan pq adalah (q – 1) + (p – 1). Jadi banyak bilangan asli k dengan 1  k < pq yang saling prima dengan pq adalah (pq  1)  [(q  1) + (p  1)] = pq  p  q + 1 = (p  1)(q  1).
  • 48. Fungsi Euler (Totient) Teorema Jika p prima dan a adalah bil bulat yang bukan kelipatan p, maka ap-1 ≡ 1 mod p Bukti : Sebab ukuran grup kali Z p = {1, 2, ..., p  1} adalah p  1 sehingga untuk setiap z  Z p berlaku zp1 = 1. Dalam bahasa teori bilangan, kesamaan ini menyatakan kongruensi zp1  1 mod p.. Karena setiap bilangan bulat positif kongruen dengan suatu z  Z p, yaitu a  z mod p, maka dari Teorema 2.3 ap1  zp1 mod p  1 mod p.
  • 49. Fungsi Euler (Totient) Akibat (Teorema Fermat) Teorema fermat diatas dapat dinyatakan secara lebih luas dengan menghilangkan syarat FPB(a,p)=1 sebagai berikut. Jika p suatu bilangan prima, maka ap ≡ a (mod p) untuk setiap bilangan bulat a.
  • 50. Fungsi Euler (Totient) Definisi : Fungsi Euler : N  N didefinisikan melalui aturan pengawanan (n) = banyaknya bilangan asli k dengan 1  k < n yang saling prima dengan n. Contoh : Z 7 = {1, 2, 3, 4, 5, 6} sehingga (7) = 6. Z 10 = {1, 3, 7, 9} sehingga (10) = 4. Dari definisi di atas, jelas (n) = |Zn |, (n) adalah ukuran (kardinalitas) dari grup kali Zn .
  • 51. Teorema Jika p adalah prima maka (p) = p  1. Fungsi Euler (Totient) Teorema Jika p dan q adalah dua bilangan prima yang berbeda (p  q), maka (pq) = (p  1)(q  1). Teorema Misalkan p prima dan 0 < a < p. maka ap-1 ≡ 1 mod p
  • 52. Kesepakatan Kunci Diffie-Hellman p g Y A X A mod  p g Y B X B mod  Kunci Diffie dan Hellman merupakan sistem kriptografi kunci publik pertama yang melindungi informasi tanpa harus menggunakan saluran khusus untuk mengirimkan kunci rahasia. Pengguna sistem secara bersama menggunakan satu bilangan prima p dan satu generator g dari grup Zp  yang bisa diakses publik. p g Y C X C mod 
  • 53. Kesepakatan Kunci Diffie-Hellman Supaya lebih aman, pilih bilangan prima Sophie-Germain, yaitup bilangan prima p yang memenuhi p = 2q + 1, untuk suatu bilangan prima q ( ) mod A X AB B Z Y p  ( ) mod . B X BA A Z Y p  A B Proposisi: ZAB = ZBA. Bukti : p g p Y Z A B A X X X B AB mod ) ( mod ) (   mod ( ) mod . A B B X X X A BA g p Y p Z   
  • 54. Kesepakatan Kunci Diffie-Hellman Contoh : Misalkan : p = 23 = 2(11) + 1, g = 5. Pilih : XA = 7, XB = 13. Kedua kunci berikut adalah kunci publik (dikirim melalui kanal publik, jadi bisa diakses publik) YA = 57 mod 23 = 17, YB = 513 mod 23 = 21. A dan B masing-masing menghitung dan sepakat dengan kunci rahasia bersama berikut: ZAB = 217 mod 23 = 10 , ZBA = 1713 mod 23 = 10. A dan B mempunyai kunci rahasia bersama, yaitu 10.
  • 55. Tugas Kunci umum (publik) p = 373 dan semua mhs menggunakan satu generator g dari Z73 x. Setiap mhs memilih kunci rahasia XA berupa 5 angka terakhir (urutan dibalik) dari No. Stb mhs. Kunci public. Cari 5 teman. 11. Tulis semua kunci public 5 teman saudara
  • 56. CIPHER SHAMIR Sistem kunci publik yang memungkinkan dua pihak untuk bertukar pesan melalui saluran terbuka. Semua user bersama-sama menggunakan satu bilangan prima p sebagai satu-satunya parameter publik A B Langkah - langkah 1. A akan mengirim m ke B 2. - A memilih dua kunci rahasia cA dan dA = cA -1 yang relatif prima terhadap p  1 - B memilih dua kunci rahasia cB dan dB = cB -1 yang relatif prima terhadap p  1 m 3. Jika m < p maka m dikirimkan sekaligus 3. Jika m ≥ p maka pesan diwakili oleh barisan blok-blok m1, m2, … , mt di mana masing-masing mi < p, dan blok-blok ini dikirimkan secara bergilir sesuai urutannya dalam pesan m.
  • 57. CIPHER SHAMIR Berikut adalah protokol pengiriman setiap blok m < p. Langkah 1 : A menghitung p m x A c mod 1  dan mengirimkan x1 ke B melalui kanal publik. Langkah 2 : Setelah merima x1, B menghitung Langkah 3 : Setelah merima x2, A menghitung Langkah 4 : Setelah merima x3, B menghitung dan mengirimkan x2 ke A melalui kanal publik. dan mengirimkan x3 ke B melalui kanal publik. p x x B c mod 1 2  p x x A d mod 2 3  p x x B d mod 3 4 
  • 58. CIPHER SHAMIR Contoh : A ingin mengirim pesan m = 10 kepada B, p = 23 A memilih cA = 7 yang relatif prima terhadap 22 = p  1 (yaitu FPB(7,22) = 1) kemudian memperoleh dA = 19. B memilih cB = 5 dengan FPB(5, 22) = 1 dan memperoleh dB = 9. langkah-langkah protokol Shamir adalah sebagai berikut (Langkah 1) A  B: x1 = 107 mod 23 = 14. (Langkah 2) B  A: x2 = 145 mod 23 = 15. (Langkah 3) A  B : x3 = 1519 mod 23 = 19. (Langkah 4) B menghitung x4 = 199 mod 23 = 10. B menerima pesan m = 10.
  • 59. ENKRIPSI ELGAMAL p g d i c i mod  Pilih p prima. Setiap pengguna kemudian memilih sendiri kunci pribadi ci, 1 < ci < p – 1, Kemudian setiap pengguna memiliki kunci publik Enkripsi ElGamal merupakan sistem kriptografi kunci publik yang memecahkan masalah komunikasi pesan rahasia satu sama lain dengan hanya satu kali menyampaikan pesan tanpa harus melalui saluran komunikasi khusus yang aman .
  • 60. ENKRIPSI ELGAMAL Langkah 1. A membangkitkan bilangan acak k dengan 1 < k ≤ p – 2, menghitung kunci publik A B mod k B e m d p   r = gk mod p mengirimkan kunci publik (r, e) ke pengguna B melalui kanal publik Langkah 2. B setelah menerima (r, e) menghitung 1 ' mod B p c m e r p     m
  • 61. ENKRIPSI ELGAMAL Contoh : Pesan m = 15 dikirimkan dari A ke B p = 23, g =5 dan pengguna B memilih bilangan rahasia cB = 13. B dengan (3.11) menghitung kunci publik dB = 513 mod 23 = 21. Pengguna A membangkitkan bilangan acak k, misalnya didapat k = 7 dan dengan (2.25) dan (2.26) menghitung r = 57 mod 23 = 17, e = 15217 mod 23 = 1510 mod 23 = 12. A mengirim B pesan terenkripsi sebagai pasangan angka (17,12) dan dengan (2.27) B menghitung . 15 23 mod 7 12 23 mod 17 12 23 mod 17 12 ' 9 13 1 23          m
  • 62. ENKRIPSI RSA DAN FUNGSI TRAPDOOR Fakta 2 : Masalah memfaktorkan bilangan-bilangan bulat n = pq dengan p dan q adalah bilangan prima yang berukuran kurang lebih sama, yaitu menemukan bilangan prima p dan q jika diberikan n = pq, adalah sangat sulit (atau secara komputasi infeasible) apabila p dan q cukup besar NB: Pengertian ‘cukup besar’ relatif, selalu berubah dan bertambah besar seiring perkembangan teknologi Fungsi Trapdoor yang dipakai pada sistem RSA didasarkan pada dua fakta teori bilangan berikut: Fakta 1 : Pengujian untuk menentukan bilangan prima adalah relatif mudah
  • 63. ENKRIPSI RSA DAN FUNGSI TRAPDOOR Setiap pengguna memilih secara acak dua bilangan prima p dan q yang berukuran besar dan kemudian menghitung N = pq Selanjutnya pengguna tersebut menghitung ( 1)( 1) p q     1 mod   cd dan memilih bilangan d <  yang relatif prima terhadap  . Kemudian dengan menggunakan Algoritma Euklid yang diperluas, dicari bilangan c = d-1 dengan
  • 64. KRIPTOGRAFI RSA Langkah 1: Alice mengenkripsi pesan sebagai berikut mod B d B e m N  ' mod . B c B m e N  Alisa Bob m Langkah 2: Bob, setelah menerima pesan terenkripsi, menghitung menggunakan kunci publik Bob (dB) dan mengirimkan e melalui saluran terbuka/publik.
  • 65. KRIPTOGRAFI RSA Contoh : Misalkan Alisa ingin mengirim pesan m = 15 ke Bob. Misalkan parameter untuk Bob adalah pB = 3, qB = 11, NB = 33, dB = 3 (3 adalah saling prima terhdp (33) = 20). Dengan menggunakan algoritma Euklid yang diperluas, diperoleh cB = 7 (Periksa dBcB mod 20 = 37 mod 20 = 1). Enkripsi terhadap m dengan menggunakan (3.18​​) : e = 153 mod 33 = 15215 mod 33 = 2715 mod 33 = 9. Alisa mengirim bilangan 9 untuk Bob melalui saluran terbuka. Hanya Bob tahu cB = 7 sehingga Bob mendekripsi dengan (3.19): . 15 33 mod 9 15 15 33 mod 9 9 ) 9 ( 33 mod 9 ' 2 2 2 2 7         m
  • 66. KRIPTOGRAFI RSA MODIFIKASI RSA DENGAN KONSEP ‘DIGITAL SIGNATURE’ A B m A akan mengirimkankan m = (m1, m2, ..., mn) dengan tandatangan digital dengan menggunakan fungsi hash h(m) (Konsep fungsi hash akan dibahas kemudian). Setelah A menghitung nilai fungsi hash h = h(m) dan s = hc mod N, A mengirimkan pasangan (m, s) ke B. Penerima pesan tinggal menghitung w = sd mod N dan mencocokkan nilai ini dengan nilai h. Jika sama, pesan dipercaya berasal dari Alice dan dikirim tanpa perubahan. Pesan asli m bisa diperoleh dengan cara yang sudah dibahas lebih dulu.