Khóa phiên và khóa trao đổi• Alice muốn gửi một bản tin m cho Bob – Assume public key encryption it to encipher m • To be used for this message only • Called a session key • k B encipher
Trang 1Quản lý khóa
• Khóa phiên và khóa trao đổi
• Trao đổi khóa
• Hạ tầng khóa mã hóa
• Lưu trữ và thu hồi khóa
• Chữ ký số
Trang 2Ký pháp
• X Y : { Z || W } kX,Y
– X gửi cho Y bản tin được tạo bằng cách ghép Z và W
• A T : { Z } kA || { W } kA,T
– A gửi cho T một bản tin bao gồm Z được mã hóa bằng
k A,T , khóa chia sẻ giữa A và T
• r1, r2 nonces (các số ngẫu nhiên không lặp lại)
Trang 3Khóa phiên và khóa trao đổi
• Alice muốn gửi một bản tin m cho Bob
– Assume public key encryption
it to encipher m
• To be used for this message only
• Called a session key
• k B enciphers all session keys Alice uses to communicate with Bob
• Called an interchange key
Trang 4Lợi ích của khóa phiên
• Hạn chế lượng dữ liệu được mã hóa bằng 1 khóa
– Standard practice, to decrease the amount of traffic an attacker can obtain
• Ngăn chặn một số tấn công
– Example: Alice will send Bob message that is either
“BUY” or “SELL” Eve computes possible ciphertexts
{ “BUY” } k B and { “SELL” } k B Eve intercepts
enciphered message, compares, and gets plaintext at once
Trang 5Các giải thuật trao đổi khóa
• Mục tiêu: Alice, Bob có được khóa chung
– Key cannot be sent in clear
• Attacker can listen in
• Key can be sent enciphered, or derived from exchanged data plus data not known to an eavesdropper
– Alice, Bob may trust third party
– All cryptosystems, protocols publicly known
• Only secret data is the keys, ancillary information known only
to Alice and Bob needed to derive keys
• Anything transmitted is assumed known to attacker
Trang 6Phương pháp truyền thống
• Vấn đề khởi đầu: how do Alice, Bob begin?
– Alice can’t send it to Bob in the clear!
• Giả sử có bên thứ 3 tin cậy, Cathy
– Alice and Cathy share secret key kA
– Bob and Cathy share secret key kB
• Sử dụng các khóa này để trao đổi khóa
chung ks
Trang 7Simple Protocol
Trang 8– Session key reuse: Eve replays message from Alice
to Bob, so Bob re-uses session key
• Phải cung cấp chức năng xác thực để chống lại tấn công gửi lặp
Trang 9Alice { Alice || Bob || r1 || k s || { Alice || k s } k B } k A Cathy
Trang 10Phân tích: Alice talking to Bob
• Bản tin thứ 2
– Enciphered using key only she, Cathy knows
• So Cathy enciphered it
– Response to first message
• As r1 in it matches r1 in first message
• Bản tin thứ 3
– Alice knows only Bob can read it
• As only Bob can derive session key from message
– Any messages enciphered with that key are from Bob
Trang 11Phân tích: Bob talking to Alice
• Bản tin thứ 3
– Enciphered using key only he, Cathy know
• So Cathy enciphered it
– Names Alice, session key
• Cathy provided session key, says Alice is other party
• Bản tin thứ 4
– Uses session key to determine if it is replay from Eve
• If not, Alice will respond correctly in fifth message
• If so, Eve can’t decipher r2 and so can’t respond, or responds
Trang 12Cải tiến của Denning-Sacco
• Giả thiết: Tất cả khóa đều bí mật
• Tình huống: Giả sử Eve có thể lấy khóa phiên
Ảnh hưởng tới giao thức trao đổi khóa?
{ r2 – 1 } k s
Trang 13Giải pháp
• Trong giao thức trên, Eve giả mạo Alice
• Vấn đề: Gửi lặp trong bản tin thứ 3
– First in previous slide
• Giải pháp: Sử dụng trường thời gian T để phát hiện
Trang 14Needham-Schroeder with Denning-Sacco Modification
Alice { Alice || Bob || r1 || k s || { Alice || T || k s } k B } k A Cathy
Trang 15Giao thức Otway-Rees
• Khắc phục vấn đề
– That is, Eve replaying the third message in the protocol
• Không dùng trường thời gian
– Not vulnerable to the problems that
Denning-Sacco modification has
• Sử dụng số nguyên n để kết hợp tất cả các
bản tin trong một trao đổi cụ thể
Trang 16The Protocol
Alice n || Alice || Bob || { r1 || n || Alice || Bob } k A Bob
Cathy n || Alice || Bob || { r1 || n || Alice || Bob } k A || Bob
{ r2 || n || Alice || Bob } k B
Trang 17Phân tích: Alice talking to Bob
• Bản tin thứ 4
– If n matches first message, Alice knows it is
part of this protocol exchange
– Cathy generated ks because only she, Alice
know kA
– Enciphered part belongs to exchange as r1
matches r1 in encrypted part of first message
Trang 18Phân tích: Bob talking to Alice
• Bản tin thứ 3
– If n matches second message, Bob knows it is
part of this protocol exchange
– Cathy generated ks because only she, Bob know
kB
– Enciphered part belongs to exchange as r2
matches r2 in encrypted part of second message
Trang 19Tấn công gửi lặp
• Eve có khóa cũ ks, và bản tin trong bước 3
– n || { r1 || k s } k A || { r2 || k s } k B
• Eve gửi cho Alice
– Alice has no ongoing key exchange with Bob: n
matches nothing, so is rejected
– Alice has ongoing key exchange with Bob: n does not
match, so is again rejected
• If replay is for the current key exchange, and Eve sent the relevant part before Bob did, Eve could simply listen to traffic;
no replay involved
Trang 21Ý tưởng
• User u xác thực tại Kerberos server
– Obtains ticket T u,TGS for ticket granting service (TGS)
• User u muốn sử dụng dịch vụ s:
– User sends authenticator A u , ticket T u,TGS to TGS asking for ticket for service
– TGS sends ticket T u,s to user
– User sends A u , T u,s to server as request to use s
• Details follow
Trang 22– k u,s is session key for user and service
– Valid time is interval for which ticket valid
– u’s address may be IP address or something else
• Note: more fields, but not relevant here
Trang 23Thẻ xác thực
• Giấy xác nhận chứa nhận diện của người gửi thẻ
– Used to confirm sender is entity to which ticket was
– k t is alternate session key
– Generation time is when authenticator generated
• Note: more fields, not relevant here
Trang 24user user || { k u,s } k u,TGS || T u,s TGS
Trang 25Phân tích
• Hai bước đầu lấy thẻ người dùng để sử dụng
TGS
– User u can obtain session key only if u knows key
shared with Cathy
• Bốn bước tiếp theo chi ra cách u lấy và sử dụng thẻ cho dịch vụ s
– Service s validates request by checking sender
(using Au,s) is same as entity ticket issued to
– Step 6 optional; used when u requests confirmation
Trang 26Vấn đề
• Dựa vào đồng hồ được đồng bộ
– If not synchronized and old tickets,
authenticators not cached, replay is possible
• Thẻ có một số trường cố định
– Dictionary attacks possible
– Kerberos 4 session keys weak (had much less than 56 bits of randomness); researchers at
Purdue found them from tickets in minutes
Trang 27Public Key Key Exchange
• Khóa trao đổi được công khai
– e A , e B Alice and Bob’s public keys known to all
– d A , d B Alice and Bob’s private keys known only to
owner
• Simple protocol
– k s is desired session key
Trang 28Vấn đề và giải pháp
• Dễ bị tấn công giả mạo hoặc gửi lặp
Alice sent message
• Simple fix uses Alice’s private key
– k s is desired session key
Trang 29• Có thể kèm theo bản tin mã hóa bằng khóa ks
• Giả sử Bob có khóa công khai của Alice và ngược lại
– If not, each must get it from public server
– If keys not bound to identity of owner, attacker Eve can
launch a man-in-the-middle attack (next slide; Cathy is
public server providing public keys)
• Solution to this (binding identity to keys) discussed later as public key infrastructure (PKI)
Trang 30Man-in-the-Middle Attack
Eve intercepts message
Trang 31Cryptographic Key Infrastructure
• Mục tiêu: Gắn các thực thể với khóa
• Truyền thống: Không khả thi vì các khóa được chia sẻ
– Use protocols to agree on a shared key (see earlier)
• Public key: Gắn thực thể với khóa công khai
– Crucial as people will use key to communicate with principal whose identity is bound to key
– Erroneous binding means no secrecy between
principals
– Assume principal identified by an acceptable name
Trang 32Certificates: Chứng chỉ
• Tạo một thẻ (bản tin) có chứa:
– Identity of principal (here, Alice)
– Corresponding public key
– Timestamp (when issued)
– Other information (perhaps identity of signer)
signed by trusted authority (here, Cathy)
CA = { eA || Alice || T } dC
Trang 33• Bob nhận chứng chỉ của Alice
– If he knows Cathy’s public key, he can decipher the
certificate
• When was certificate issued?
• Is the principal Alice?
– Now Bob has Alice’s public key
• Vấn đề: Bob cần khóa công khai của Cathy để xác minh chứng chỉ (certificate)
– Problem pushed “up” a level
– Two approaches: Merkle’s tree, signature chains
Trang 34Certificate Signature Chains
• Tạo chứng chỉ
– Generate hash of certificate
– Encipher hash with issuer’s private key
• Xác minh
– Obtain issuer’s public key
– Decipher enciphered hash
– Recompute hash from certificate and compare
• Vấn đề: Lấy được khóa công khai của người
cấp
Trang 35X.509 Chains
• Some certificate components in X.509v3:
– Version
– Serial number
– Signature algorithm identifier: hash algorithm
– Issuer’s name; uniquely identifies issuer
– Interval of validity
– Subject’s name; uniquely identifies subject
– Subject’s public key
– Signature: enciphered hash
Trang 36Xác minh chứng chỉ X.509
• Lấy khóa công khai của người cấp
– The one for the particular signature algorithm
• Giải mã chữ ký
– Gives hash of certificate
• Tính lại mã băm từ chứng chỉ và so sánh
– If they differ, there’s a problem
• Kiểm tra thời gian
– This confirms that certificate is current
Trang 37Issuers: Người cấp
• Certification Authority (CA): Đơn vị phát
hành chứng chỉ
– Multiple issuers pose validation problem
– Alice’s CA is Cathy; Bob’s CA is Don; how
can Alice validate Bob’s certificate?
– Have Cathy and Don cross-certify
• Each issues certificate for the other
Trang 38• Alice validates Bob’s certificate
– Alice obtains Cathy<<Dan>>
– Alice uses (known) public key of Cathy to validate
Cathy<<Dan>>
– Alice uses Cathy<<Dan>> to validate Dan<<Bob>>
Trang 39PGP Chains
• Chứng chỉ OpenPGP có cấu trúc dạng các gói tin
– One public key packet
– Zero or more signature packets
• Gói tin khóa công khai:
– Version (3 or 4; 3 compatible with all versions of PGP,
4 not compatible with older versions of PGP)
– Creation time
– Validity period (not present in version 3)
– Public key algorithm, associated parameters
– Public key
Trang 40Gói tin chữ ký OpenPGP
• Version 3 signature packet
– Version (3)
– Signature type (level of trust)
– Creation time (when next fields hashed)
– Signer’s key identifier (identifies key to encipher hash)– Public key algorithm (used to encipher hash)
– Hash algorithm
– Part of signed hash (used for quick check)
– Signature (enciphered hash)
• Version 4 packet more complex
Trang 41• Một chứng chỉ có thể có nhiều chữ ký
• Thuộc tính “độ tin cậy” được đưa vào mỗi chữ ký
– Range from “untrusted” to “ultimate trust”
– Signer defines meaning of trust level (no standards!)
• Version 4: Khóa được ký bởi chính chủ thể
– Called “self-signing”
Trang 42Xác minh chứng chỉ
• Alice needs to validate
Bob’s OpenPGP cert
– Does not know Fred,
Giselle, or Ellen
• Alice gets Giselle’s cert
– Knows Henry slightly, but
his signature is at “casual”
level of trust
• Alice gets Ellen’s cert
– Knows Jack, so uses his
cert to validate Ellen’s, then
hers to validate Bob’s Bob
FredGiselle
EllenIrene
Henry
JackArrows show signaturesSelf signatures not shown
Trang 43Lưu trữ khóa
• Trong các hệ thống đa người dùng hoặc môi
trường mạng: Kẻ tấn công có thể vượt qua hệ
thống điều khiển truy cập
– Encipher file containing key
• Attacker can monitor keystrokes to decipher files
• Key will be resident in memory that attacker may be able to read
– Use physical devices like “smart card”
• Key never enters system
• Card can be stolen, so have 2 devices combine bits to make
Trang 44Thu hồi khóa
• Chứng chỉ không còn hợp lệ trước khi hết hạn
– Usually due to compromised key
– May be due to change in circumstance (e.g., someone
leaving company)
• Vấn đề:
– Entity revoking certificate authorized to do so
– Revocation information circulates to everyone fast
enough
• Network delays, infrastructure problems may delay information
Trang 45• PGP: Người ký được thu hồi chữ kỹ, người sở hữu
có thể thu hồi cả chứng chỉ, hoặc cho phép người khác thu hồi
– Revocation message placed in PGP packet and signed
– Flag marks it as revocation message
Trang 46Chữ ký số
• Một cấu trúc dùng để xác thực nguồn gốc và nội dung của bản tin và có thể chứng minh sự xác thực
đó với 1 bên thứ 3 khách quan.
• Người gửi không thể từ chối đã gửi bản tin (dịch
vụ “không thể chối cãi”)
– Limited to technical proofs
• Inability to deny one’s cryptographic key was used to sign
– One could claim the cryptographic key was stolen or compromised
• Legal proofs, etc., probably required; not dealt with here
Trang 47Sai lầm thường gặp
• Thông thường: Alice, Bob share key k
– Alice sends m || { m } k to Bob
Trang 48Chữ ký số truyền thống
• Cần có bên thứ 3 tin cậy
– Alice, Bob each share keys with trusted party Cathy
• Để giải quyết tranh chấp, người giải quyêt lấy { m } k Alice, {
m } k Bob, và yêu cầu Cathy giải mã; nếu 2 bản tin khớp, thì tương đương hợp đồng 2 bên đã ký
{ m }k Alice { m }k Alice { m }k Bob
Trang 49Chữ ký số khóa công khai
• Khóa của Alice: dAlice, eAlice
• Alice gửi cho Bob
m || { m } dAlice
• Khi có tranh chấp, người giải quyết tính:
{ { m } dAlice } eAlice
• Nếu kết quả là m, Alice đã ký bản tin
– She’s the only one who knows dAlice!
Trang 50Chữ ký số RSA
• Dùng khóa riêng để mã hóa bản tin
– Protocol for use is critical
• Các điểm chính:
– Never sign random documents, and when
signing, always sign hash and never document
• Mathematical properties can be turned against signer
– Sign message first, then encipher
• Changing public keys causes forgery
Trang 51– Alice computes 0517 mod 77 = 08; corresponding
signature is 0319 mod 77 = 57; claims Bob signed 08
• Signature validated; Bob is toast
Trang 52Attack #2: Bob’s Revenge
• Bob, Alice đồng ý ký HĐ 06
• Alice mã hóa, sau đó ký:
• Bob thay đổi khóa công khai
• Bob tuyên bố HĐ là13 Tính:
– Verified; now Alice is toast
Trang 53Key Points
• Key management critical to effective use of
cryptosystems
– Different levels of keys (session vs interchange)
• Keys need infrastructure to identify holders, allow revoking
– Key escrowing complicates infrastructure
• Digital signatures provide integrity of origin and content
Much easier with public key cryptosystems than with
classical cryptosystems