Crypto Signature 2021
Crypto Signature 2021
Rachid Elazouzi
2021
L3 INFO
CERI, Avignon Université
www java www mail www ucl ulg www www ezp www www.example.com
192.0.2.1
www.example.com
192.0.2.50
Internet
The resolver learns the hierarchy
responses can be cached to avoid querying twice the same server
3
DNS cache poisoning
example.org. @{192.0.2.1}
4
Hash func&on
• Validate that a message has not been altered on its way between Alice and Bob
• Hash functions map arbitrary large numbers of variable length to fixed-length numbers
• h = H(m), h is called hash or digest
• e.g., MD5, SHA-1, SHA-256
• Good hash functions for cryptography must be such that
• H(m) is not complex to compute
• but finding a m2 such that H(m2) = H(m) is complex,
• H(m) is deterministic,
• H output must be evenly distributed over the output set
• Example
• SHA-1 maps messages its input space on a 160-bits output
• SHA-1(Message to validate) = 5e06ee754bda0d33cf65ec305ffc779404e66029
• SHA-1(Message tO validate) = b1c306f8cb792fa14d4d1fdcf6f37d86c2fe6bb9
5
Is that enough?
msg
d = H(msg)
msg, d
valid as d = H(msg)
msg2
msg2, d2
d2 = H(msg2)
msg3
d3 = H(msg3) msg3, d3
valid as d3 = H(msg3)
6
Hash func*on with salt
7
Hash func*on with salt
(contd.)
Alice Trudy Bob
K K
msg
d = H(msg, K)
msg, d
valid as d = H(msg, K)
msg2
msg2, d2
d2 = H(msg2, K)
msg3
msg3, d3
d3 = H(msg3) invalid as d3 ≠ H(msg3, K)
8
Problem solved?
•fill me
•fill me
•fill me
9
Diffie-Hellman key exchange
• How can Alice and Bob agree on a secret
number and be sure that Eve will not discover
it?
• Principle
• do not exchange the secret number but other
numbers that are use to build up the secret
10
Diffie-Hellman key exchange (contd.)
•Working on finite group and positive
integers
Alice Eve Bob
a, g, m
A, g, m
A ga mod m b
B gb mod m
B
K Ba mod m K Ab mod m
K Ab mod m (ga mod m)b mod m gba mod m (gb mod m)a mod m Ba mod m K
11
Diffie-Hellman key exchange
(contd.)
•Trudy can break Diffie-Hellman
Alice Trudy Bob
a, g, m
A, g, m
A ga mod m
at, gt, mt
At gat mod mt
At, gt, mt
bt b
Bt gbt mod m
K Abt mod m
K Bta mod m Bt B gtb mod mt
B K‘ Atb mod mt
K‘ Bat mod mt
12
Diffie-Hellman key exchange (contd.)
13
Asymmetric cryptography (contd.)
m2
c2 = crypt(m2, PublicB) c2
m3
c3=crypt(m3, PublicB) c3
decrypt(c3, PrivateB)=m3
14
Asymmetric cryptography (contd.)
m
s = sign(m, PrivateA) m, s
check(m, s, PublicA)
15
How to build sign and
check?
s = sign(H(m), k) = crypt(H(m), k)
check(m, s, K) = (H(m)==decrypt(s, K))
where k is the private key of the signer
and K is the public key
Asymmetric cryptography is slow and m
can be large
encrypting m would be too costly
solution: consider the digest of m
while signing
16
Public key infrastructure
PublicB
PublicB
17
Public key infrastructure (contd.)
PublicT
PublicT
18
Public key infrastructure (contd.)
S(Yes, PrivB),
S(PubB, PrivT)
PublicB
19
Public key infrastructure (contd.)
• Practically, Bob sends a certificate (e.g., X.509), not only its
public key and signature
• A certificate provides many information to be able to correctly
identify and authenticate its subject (e.g., Bob)
• the subject name and organization
• the subject public key (and type)
• the issuer name and organization
• the certificate validity time (valid not before and not after)
• the certificate signature and type, signature made by the
issuer of the certificate
• ...
20
Certificate Life Cycle
Certificate issued
AA
u Extensions § Extensions can be used to tailor
C
Digital Signature certificates to meet the needs of
end applications.
Public key infrastructure (contd.)
• Certificates are issued once and valid during a given time
period, whatever the number of time it is used
• What if the subjects leaves its organization? The private key of
the subject is stolen? The private key of the issuer is stolen?
• Keys are selected big enough to not be broken during validity
time
• When a certified key is compromised, the certificate is revoked
• the issuer maintains the list of revoked certificates
• when a certificate is checked for validity, the verifying client
should verify that the certificate is not in the revoked
certificates list
24
Diffie-Hellman key exchange (the
return)
•Trudy cannot perform her aEack
anymore
Alice Trudy Bob
PublicA, PrivateA, PublicB PublicA PublicB PublicA, PublicB, PrivateB
a, g, m
A ga mod m
sA=sign((A,g,m), PrivateA) A, g, m, sA
check((A,g,m),sA,PublicA)
b
B gb mod m
K Ab mod m
B, sB
check(B, sB, PublicB) sB=sign(B, PrivateB)
K Ba mod m
26
Problem solved?
fill me
fill me
fill me
27
Nonce
• Trudy can replay a message
m = “open door”
s = sign(m, PrivateA) m, s
check(m, s, PublicA)
remember (m, s)
door is open
m2 = “close door”
s2 = sign(m2, PrivateA) m2, s2
check(m2, s2, PublicA)
door is closed
m, s
check(m, s, PublicA)
door is open !!
28
Nonce (contd.)
A nonce is a number used only once
Three general methods to create nonces
sequen6al number
increment a7er each use
keep it in non-vola6le storage in case of reboot
6mestamp
current 6me of the nonce genera6on
be sure clock is not going backward (e.g., winter 6me)
random number
low collision probability if the pseudo random number generator is good and random number is
big enough (e.g., more than 128 bits)
Nonce alone is rarely enough to have a good protec6on
not robust to eavesdropping or man-in-the-middle aFack
29
Nonce (contd.)
•Each message is make unique thanks to
the nonce
Alice Trudy Bob
PublicA, PrivateA PublicA PublicA
m
n = nonce m, n, s
s = sign((m, n), PrivateA)
check((m, n), s, PublicA)
remember (m, n, s)
nonces = {n}
m2
n2 = nonce
s2 = sign((m2,n2),PrivateA) m2, n2, s2
check((m2,n2),s2,PublicA)
nonces = {n, n2}
m, n, s
check((m,n), s, PublicA)
nonce already used:
30 skip
Fonctions de Hachage
Exemples :
• Caractéristiques de base :
• Rapidité de calcul
• Compression :
• L’entrée de la fonction est un message de taille quelconque
• La sortie de la fonction est un message de taille fixée (la même
pour tous les messages)
• Caractéristiques souhaitées : il doit être impossible
en pratique
• D’inverser la fonction (retrouver le message
correspondant à une empreinte)
• Connaissant un message et une empreinte, de trouver un
second message avec la même empreinte
• De trouver deux messages avec la même empreinte
Exemple : MD5
Vue d’ensemble du
traitement d’un bloc
de 512 bits
Source : Wikipedia
Source : Wikipedia
Rachid Elazouzi Sécurité Informatique
Signature numérique
• Applications
• Certification de clés publiques :
• Une tierce partie de confiance lie l’identité d’un utilisateur à la
clé
• Par la suite, les autres utilisateurs peuvent authentifier la clé sans
l’aide de la tierce partie
• Authentification, intégrité et non-répudiation de
courriels, documents, commandes, paiements…
• Basé sur des cryptosystèmes asymétriques
•Deux types
•Avec appendice : le message original
est nécessaire pour la vérifica9on
(u9lisé le plus souvent)
•Avec rétablissement de message : le
message original est récupéré à par9r
de la signature lors de la vérifica9on
avec
et
• VérificaRon de la signature: