Concetti Base Di Sicurezza Informatica
Concetti Base Di Sicurezza Informatica
Concetti base di
sicurezza informatica
Antonio Lioy
< lioy @ polito.it >
Politecnico di Torino
Dip. Automatica e Informatica
Crittografia
mittente destinatario
messaggio messaggio
chiave-1 (in chiaro) (in chiaro) chiave-2
crittografia
g decrittografia
g
messaggio (cifrato)
Terminologia
messaggio in chiaro:
plaintext o cleartext
noi lo indicheremo con P
messaggio cifrato:
ciphertext
noi lo indicheremo con C
cifrare / decifrare:
to encrypt / decrypt
to cipher / decipher
per alcuni popoli usare “crypt” in questo senso è
offensivo (culto dei morti); preferire quindi “cipher”
Crittografia simmetrica
chiave unica
chiave comune a mittente e destinatario
C = enc ( K , P ) oppure C = { P } K
P = dec ( K , C ) = enc-1 ( K , C )
K K
Algoritmi simmetrici
⊕ 0 1
0 0 1
1 1 0
DES
Data Encryption Standard
standard FIPS 46/2
modalità di applicazione standard FIPS 81
chiave a 56 bit (+ 8 bit di parità = 64 bit)
blocco dati da 64 bit
pensato per essere efficiente in hardware perché
richiede:
XOR
shift
permutazioni (!)
Doppio DES ?
l’applicazione doppia di algoritmi di cifratura è
soggetta ad un attacco di tipo known-plaintext
chiamato meet-in-the-middle che permette di
decifrare i dati con al più 2N+1 tentativi
quindi solitamente non si usa mai la versione
doppia degli algoritmi di cifratura
nota: se l’algoritmo
g simmetrico di base fosse un
gruppo allora esisterebbe K3 tale che
enc (K2 , enc (K1 , P) ) = enc (K3 , P)
Attacco meet-in-the-middle
ipotesi:
chiavi da N bit
sono noti P e C tali che C = enc (K2, enc (K1, P) )
nota:
esiste M tale che M = enc(K1,P) e C = enc(K2,M)
azioni:
calcolo 2N valori Xi = enc (Ki, P)
calcolo 2N valori Yj = dec (Kj, C)
cerco quei valori Ki e Kj tali che Xi = Yj
“falsi positivi” eliminabili se ho più coppie P,C
IDEA
International Data Encryption Algorithm
brevettato ma con basse royalty (solo per uso
commerciale, ASCOM
SCO AG) G)
chiave a 128 bit
blocco dati da 64 bit
grande notorietà perché usato in PGP
operazioni usate:
XOR
addizione modulo 16
moltiplicazione modulo 216+1
Un’applicazione di IDEA
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.
RC2, RC4
sviluppati da Ron Rivest
RC = Ron’s Code
algoritmi proprietari di RSA ma non brevettati
3 e 10 volte più veloci di DES
RC2 è a blocchi, RC4 è stream
chiave a lunghezza variabile
RC2:
pubblicato come RFC-2268 (mar 1998)
chiave da 8 a 1024 bit (solitamente 64 bit)
blocchi da 64 bit
RC4 reverse engineered (ARCFOUR)
RC5
RFC-2040
blocco dati da B bit (0 < B < 257)
chiave (fissa/variabile) da b byte
(0 ≤ b < 256) ossia tra 0 e 2048 bit
lavora al meglio con B = 2 W
operazioni usate:
shift, rotate
addizione modulare
usato nel WAP
P1 P2 P3 P4
K K K K
C1 C2 C3 C4
ECB - decifratura
formula per il blocco i-esimo:
Pi = enc-1 ( K, Ci )
un errore in trasmissione provoca errore nella
decifratura di un solo blocco
P1 P2 P3 P4
K K K K
C1 C2 C3 C4
P1 P2 P3 P4
IV ⊕ ⊕ ⊕ ⊕
K K K K
C1 C2 C3 C4
CBC - decifratura
formula per il blocco i-esimo:
Pi = enc-1 ( K , Ci ) ⊕ Ci-1
C0 (ossia IV) noto al ricevente (in chiaro o cifrato)
un errore in trasmissione provoca errore nella
decifratura di due blocchi
P1 P2 P3 P4
IV ⊕ ⊕ ⊕ ⊕
K K K K
C1 C2 C3 C4
Padding (allineamento)
dimensione del blocco algoritmico B
quantità di dati da elaborare D < B
aggiungo bit sino a raggiungere la quantità B
dati padding
N blocchi
problemi:
trasmetto più dati (B) del minimo necessario (D)
quantità di bit di padding? (meglio D > 0.5 B)
valore dei bit di padding?
Metodi di padding
(se lunghezza è nota o ricavabile - es. stringa C)
aggiungere byte nulli
… 0x00
0 00 0
0x00
00 0 0x0000
(DES originale) un bit a 1 seguito da tanti 0
… 1000000
un byte con valore 128 seguito da byte nulli
… 0x80 0x00 0x00
ultimo byte pari alla lunghezza del padding
… 0x?? 0x?? 0x03
valore degli altri byte?
leftmost byte
Pbi ⊕ Cbi
leftmost byte
Pbi ⊕ Cbi
Pbi ⊕ Cbi
. key generator 1
. 0
0 0
1 key stream 1
plaintext 0 00011010… 0 plaintext
data stream 0 . data stream
1 .
encryption decryption
ciphertext
data stream
Crittografia simmetrica
chiave singola e segreta
una chiave per ogni coppia / gruppo di utenti
messaggio
X Y
privato X-Y
Kxy Kxy
Kxz Kxz
messaggio
privato X-Z Z
Distribuzione chiavi
per crittografia simmetrica
per una comunicazione privata completa tra N
persone occorrono N x (N-1) / 2 chiavi:
distribuzione OOB (Out-Of-Band)
distribuzione tramite algoritmi per scambio chiavi
Antonio K3 Daniele
K2 K5
K1 K6
Barbara Carla
K4
Sfide DES
256 = 72.057.594 miliardi di chiavi possibili
DES challenge I
inizio=18-feb-1997, fine=17-giu-1997
17.731.000 miliardi di chiavi provate (25%)
circa 15.000 computer in rete
DES challenge II
inizio=13-gen-98,
inizio=13 gen 98 fine=23
fine=23-feb-98
feb 98
63.686.000 miliardi di chiavi provate (87%)
circa 20.000 computer in rete
AES = RIJNDAEL
2 ottobre 2000
RIJNDAEL scelto come vincitore
pubblicato nel novembre 2001 come FIPS-197
Crittografia asimmetrica
chiavi generate a coppie:
chiave privata (Kpri) + chiave pubblica (Kpub)
chiavi con funzionalità reciproca: dati cifrati con
una chiave sono decifrabili solo con l’altra
Kpri Kpub
ciao!
c ao E q #%3& D ciao!
c ao
Kpub Kpri
Firma digitale
firma digitale ~ cifratura asimmetrica dei dati con
la chiave privata dell’autore
solitamente non si cifrano direttamente i dati ma
un loro riassunto ( digest )
fornisce autenticazione (e integrità) dei dati
X chiunque
KXpri KXpub
E D
messaggio
pubblico
firmato da X
X chiunque
KXpri KXpub
D E
messaggio
privato per X
RSA - l’algoritmo
modulo pubblico N = P × Q noto a tutti
P e Q sono primi, grandi e segreti
esponente pubblico E scelto a caso purché é
relativamente primo rispetto a P-1 e Q-1
esponente privato D = E-1 mod (P-1) × (Q-1)
Aritmetica modulare
X = A mod N
se X è il resto della divisione intera di A per N
esempi:
7 mod 5 = 2
13 mod 5 = 3
ottima per applicazioni di sicurezza perché non
invertibile in modo univoco:
dato
Y mod 5 = 2
qual è Y?
risposte: 7, 12, 17, 22, 27, ...
nell’aritmetica normale:
X = 5 implica X-1 = 1/5
perché
5 x 1/5 = 1
nell’aritmetica modulare (es
(es. modulo 4):
-1
X = 5 implica X mod 4 = { 5, 9, 13, ... }
perché
5 x 5 mod 4 = 25 mod 4 = 1
5 x 9 mod 4 = 45 mod 4 = 1
...
RSA - un esempio
scelti P=3, Q=5 si ha N = 15
E (primo rispetto a 2 e 4) = 7
D = 7-11 mod
d 8 = {7,
{7 15
15, 23
23, 31
31, …}} = 23
testo da cifrare: 1 2 3
c1 = 17 mod 15 = 1
c2 = 27 mod 15 = 128 mod 15 = 8
c3 = 37 mod 15 = 2187 mod 15 = 12
t1 = 123 mod 15 = 1
t2 = 823 mod 15 = 2
t3 = 1223 mod 15 = 3
http://www.rsasecurity.com/
rsalabs/challenges/factoring/numbers.html
Sfide RSA
sfide risolte (vecchio stile):
10-apr-1996, RSA-130, 1000 MIPS-years
2-feb-1999, RSA-140 (465 bit), 2000 MIPS-years
22-ago-1999, RSA-155 (512 bit), 8000 MIPS-years
9-mag-2005, RSA-200 (663 bit), ~75 anni Opteron
2.2 GHz
sfide risolte ((nuovo stile):
)
3-dic-2003, RSA-576 (174 cifre decimali)
2-nov-2005, RSA-640 (193 cifre decimali)
12-dic-2009, RSA-768 (232 cifre decimali)
Twinkle (!?)
An Analysis of Shamir’s Factoring Device
Robert D. Silverman
RSA Laboratories
May 3, 1999
At a Eurocrypt rump session, Professor Adi Shamir of the Weizmann
Institute announced the design for an unusual piece of hardware. This
hardware, called “TWINKLE” (which stands for The Weizmann INstitute Key
Locating Engine), is an electro-optical sieving device which will execute
sieve-based factoring algorithms approximately two to three orders of
magnitude as fast as a conventional fast PC. The announcement only
presented a rough design
design, and there are a number of practical difficulties
involved with fabricating the device. It runs at a very high clock rate (10
GHz), must trigger LEDs at precise intervals of time, and uses wafer-scale
technology. However, it is my opinion that the device is practical and could
be built after some engineering effort is applied to it. Shamir estimates that
the device can be fabricated (after the design process is complete) for about
$5,000.
X Y
KYpub KYpri
K ε Y?2gs3 δ K
Diffie-Hellman
A e B scelgono due interi grandi g e p (primo)
tali che:
1<g<p
A, scelto un numero a caso x, calcola:
X = gx mod n
B, scelto un numero a caso y, calcola:
Y = gy mod n
A e B si scambiano (pubblicano) X e Y
A calcola K = Yx mod n
B calcola K’ = Xy mod n
ma K = K’ = gxy mod n
Diffie-Hellman (DH)
p>g>1
X Y
A = gX mod p B = gY mod p
A
B
KA = BX mod p KB = AY mod p
Diffie-Hellman
primo algoritmo a chiave pubblica inventato
solitamente usato per concordare su una chiave
segreta ( key agreement )
brevettato negli USA ma il brevetto è scaduto il 29
aprile 1997
resistente allo sniffing
se l’attaccante può manipolare i dati allora è
possibile un attacco man-in-the-middle; in questo
caso richiede pre-autenticazione
certificati per chiavi DH
authenticated DH = MQV (Menezes-Qu-Vanstone)
brevettato da CertiCom
Z
X Y
A = gX mod p B = gY mod p
A M
M B
M = gZ mod p
KA = MX mod p KB = MY mod p
ci vediamo ci vediamo
alle 19:30 a?kfi3+s7#
Digest
message message
digest digest
digest OK?
V1 V2 V3
IV f f f valore di hash
SHA-1 broken
February 15, 2005
SHA-1 has been broken. Not a reduced-round version. Not a simplified
version. The real thing.
The research team of Xiaoyun WangWang, Yiqun Lisa Yin,
Yin and Hongbo Yu (mostly
from Shandong University in China) have been quietly circulating a paper
describing their results:
– collisions in the the full SHA-1 in 2**69 hash operations, much less than the
brute-force attack of 2**80 operations based on the hash length.
– collisions in SHA-0 in 2**39 operations.
– collisions in 58-round SHA-1 in 2**33 operations.
This attack builds on previous attacks on SHA-0 and SHA-1, and is a major,
major cryptanalytic result. It pretty much puts a bullet into SHA-1 as a hash
function for digital signatures (although it doesn't affect applications such
as HMAC where collisions aren’t important).
The paper isn’t generally available yet. At this point I can’t tell if the attack
is real, but the paper looks good and this is a reputable research team.
http://www.schneier.com/blog/archives/2005/02/sha1_broken.html
Autenticazione tramite
cifratura simmetrica
si invia anche una copia cifrata dei dati
solo chi conosce la chiave può confrontare la
copia con l’originale
svantaggi: raddoppio dei dati trasmessi + tempo di
calcolo
msg ???
msg msg
hash hash
chiave
segreta
md mdR
condivisa
mdF = ?
cifratura decifratura
simmetrica simmetrica
digest cifrato
Keyed-digest
Mittente Destinatario
dati inviati ??? dati ricevuti
chiave
segreta
condivisa
hash hash
kdR
kdF = ?
keyed-digest
difese:
inserire tra i dati la lunghezza di M
definire kd = H (K || M || K)
usare un keyed-digest standard
Keyed-digest: HMAC
RFC-2104
funzione di hash H: blocco B byte, output L byte
definizioni:
ipad = 0x36 ripetuto B volte
opad = 0x5C ripetuto B volte
sconsigliate chiavi t.c. | K | < L
se L < | K | < B,
B Kp = K padded 0 fino a | Kp | = B
se | K | > B, Kp = H ( K )
hmac = H( Kp ⊕ opad || H( Kp ⊕ ipad || data ) )
CBC-MAC
sfrutta un algoritmo di cifratura simmetrico a
blocchi, in modalità CBC con IV nullo, prendendo
come MAC la cifratura dell
dell'ultimo
ultimo blocco
messaggio M diviso in N blocchi M1 … MN
iterazioni:
V0 = 0
for (k=1…N) do Vk = enc (K, Mk ⊕ Vk-1 )
cbc-mac = VN
se basato su DES si chiama Data Authentication
Algorithm (standard FIPS 113, ANSI X9.17)
Authenticated encryption
unica operazione per cifratura e autenticazione (e
integrità)
una sola
l chiave
hi ed
d un solol algoritmo
l it
maggior velocità
meno probabilità di errori nel combinare le funzioni
necessità applicative (es. messaggi di posta
elettronica, pacchetti di rete):
necessita di autenticazione
header payload
necessita di confidenzialità
encK’ ⊕ ⊕ ⊕
⊕ ⊕ ⊕
C1 C2 C3
AEAD
key
encryption
nonce
ciphertext
Firma digitale
mittente destinatario
dati inviati ??? dati ricevuti
hash hash
chiave del
mittente
md mdR
PRI PUB mdF = ?
cifratura decifratura
asimmetrica asimmetrica
digital signature
Firma e verifica
firmatario verificatore
dati dati dati
fi
firma
hash hash
DR
D =?
DF
cifratura decifratura
asimmetrica asimmetrica
Meccanismi di revoca
CRL (Certificate Revocation List)
elenco di certificati revocati
firmato dalla CA o da un delegato
OCSP (On-line Certificate Status Protocol)
risposta puntuale su un singolo certificato
firmata dal server
certificato
subject: X KPUB(X)
key: KPUB(X)
Gerarchia di certificazione
CA EU
firma
ds (EU)
firma
CA IT
ds (EU)
firma firma
CA To CA Mi
ds (IT) ds (IT)
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been
corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image
EuroPKI
and then insert it again.
EuroPKI
Italy
persone server
Politecnico di Comune di
Torino CA CSP CA Modena CA
NSA suite B
per prodotti COTS che trattano informazioni SBU
(Sensitive But Unclassified) e Classified
comprende d i seguenti ti algoritmi:
l it i
(cifratura simmetrica) AES-128 e AES-256
(hash) SHA-256 e SHA-384
(key agreement) ECDH e ECMQV
((firma digitale)
g ) ECDSA
per informazioni fino a livello Secret:
AES-128 + SHA-256 + EC-256
per informazioni al livello Top Secret:
AES-256 + SHA-384 + EC-384
www.keylength.com
user bank
browser web server web
weak weak + strong
crypto crypto
strong
Verisign cert
crypto
yp
Bibliografia
( http://security.polito.it/books.html )
B.Schneier:
“Applied cryptography”
AM
A.Menezes, P van Oorschot,
P. O h t S.Vanstone:
SV t
“Handbook of Applied Cryptography”
W.Stallings:
“Cryptography and network security”
C.P.Pfleeger, S.Pfleeger:
Security in computing”
“Security computing
S.Garfinkel, G.Spafford:
“Practical Unix and Internet security”
W.R.Cheswick, S.M.Bellovin:
“Firewalls and Internet security”