Presentation on theme: "SSL: Secure Sockets Layer"— Presentation transcript:
1SSL: Secure Sockets Layer Widely deployed security protocolSupported by almost all browsers and web servershttpsTens of billions $ spent per year over SSLOriginally designed by Netscape in 1993Number of variations:TLS: transport layer security, RFC 2246ProvidesConfidentialityIntegrityAuthenticationOriginal goals:Had Web e-commerce transactions in mindEncryption (especially credit-card numbers)Web-server authenticationOptional client authenticationMinimum hassle in doing business with new merchantAvailable to all TCP applicationsSecure socket interface
3SSL and TCP/IP Application Application SSL TCP TCP IP IP Normal ApplicationApplicationSSLTCPIPwith SSLSSL provides application programming interface (API)to applicationsC and Java SSL libraries/classes readily available
4Could do something like PGP: KA-H( ).KA( ).-KA(H(m))-mKSKS( ).++mInternetKB( ).+KSKB(KS )+KB+But want to send byte streams & interactive dataWant a set of secret keys for the entire connectionWant certificate exchange part of protocol: handshake phase
5Toy SSL: a simple secure channel Handshake: Alice and Bob use their certificates and private keys to authenticate each other and exchange shared secretKey Derivation: Alice and Bob use shared secret to derive set of keysData Transfer: Data to be transferred is broken up into a series of recordsConnection Closure: Special messages to securely close connection
7RECALL: Certification Authorities When Alice wants Bob’s public key:gets Bob’s certificate (Bob or elsewhere).apply CA’s public key to Bob’s certificate, get Bob’s public keyKB+digitalsignature(decrypt)Bob’spublickeyKB+Bob’s CertificateCApublickey+KCA
8Toy: Key derivationConsidered bad to use same key for more than one cryptographic operationUse different keys for message authentication code (MAC) and encryptionFour keys:Kc = encryption key for data sent from client to serverMc = MAC key for data sent from client to serverKs = encryption key for data sent from server to clientMs = MAC key for data sent from server to clientKeys derived from key derivation function (KDF)Takes master secret and (possibly) some additional random data and creates the keys
9Recall MAC s = shared secret s message compare H( ) Recall that HMAC is a standardized MAC algorithmSSL uses a variation of HMACTLS uses HMAC
10Toy: Data RecordsWhy not encrypt data in constant stream as we write it to TCP?Where would we put the MAC? If at end, no message integrity until all data processed.For example, with instant messaging, how can we do integrity check over all bytes sent before displaying?Instead, break stream in series of recordsEach record carries a MACReceiver can act on each record as it arrivesIssue: in record, receiver needs to distinguish MAC from dataWant to use variable-length recordslengthdataMAC
11Toy: Sequence NumbersAttacker can capture and replay record or re-order recordsSolution: put sequence number into MAC:MAC = MAC(Mx, sequence||data)Note: no sequence number fieldAttacker could still replay all of the recordsUse random nonce
12Toy: Control information Truncation attack:attacker forges TCP connection close segmentOne or both sides thinks there is less data than there actually is.Solution: record types, with one type for closuretype 0 for data; type 1 for closureMAC = MAC(Mx, sequence||type||data)lengthtypedataMAC
13Short Question:In the SSL record, there is a field for SSL seq. numbers?True or False?False. Both sides maintain Seq. no independently.
15Question Suppose Seq. number is NOT used. Question: In an SSL session, Can Trudy (woman-in-the-middle) delete a TCP segment?Question: What effect will it have?
16Question Suppose Seq. number is USED. In an SSL session, an attacker inserts a bogus TCP segment into a packet stream with correct TCP checksum and seq. no.Question: Will SSL at the receiving side accept bogus packet and pass the payload to upper-level?FALSE, Mx is used for MAC calculation.
17Question. KDCKDC (Key Distribution Center): a server that shares a unique secret symmetric key with each registered user. KA-KDC, KB-KDCCan session key be distributed using KDC?S1. KA-KDC(A,B)2.KA-KDC(S, KB-KDC(A,S))3.KB-KDC(A,S)AB
18Toy SSL isn’t complete How long are the fields? What encryption protocols?No negotiationAllow client and server to support different encryption algorithmsAllow client and server to choose together specific algorithm before data transfer
19Most common symmetric ciphers in SSL DES – Data Encryption Standard: block3DES – Triple strength: blockRC2 – Rivest Cipher 2: blockRC4 – Rivest Cipher 4: streamPublic key encryptionRSA
20SSL Cipher Suite Cipher Suite SSL supports a variety of cipher suites Public-key algorithmSymmetric encryption algorithmMAC algorithmSSL supports a variety of cipher suitesNegotiation: client and server must agree on cipher suiteClient offers choice; server picks one
21Real SSL: Handshake (1) Purpose Server authentication Negotiation: agree on crypto algorithmsEstablish keysClient authentication (optional)
22Real SSL: Handshake (2)Client sends list of algorithms it supports, along with client nonceServer chooses algorithms from list; sends back: choice + certificate + server nonceClient verifies certificate, extracts server’s public key, generates pre_master_secret, encrypts with server’s public key, sends to serverClient and server independently compute encryption and MAC keys from pre_master_secret and noncesClient sends a MAC of all the handshake messagesServer sends a MAC of all the handshake messages
23Real SSL: Handshaking (3) Last 2 steps protect handshake from tamperingClient typically offers range of algorithms, some strong, some weakMan-in-the middle could delete the stronger algorithms from listLast 2 steps prevent thisLast two messages are encrypted
24Real SSL: Handshaking (4) Why the two random nonces?Suppose Trudy sniffs all messages between Alice & Bob.Next day, Trudy sets up TCP connection with Bob, sends the exact same sequence of records,.Bob (Amazon) thinks Alice made two separate orders for the same thing.Solution: Bob sends different random nonce for each connection. This causes encryption keys to be different on the two days.Trudy’s messages will fail Bob’s integrity check.
25Handshake typesAll handshake messages (with SSL header) have 1 byte type field: TypesClientHelloServerHelloCertificateServerKeyExchangeCertificateRequestServerHelloDoneCertificateVerifyClientKeyExchangeFinished
27SSL Record Protocol data MAC fragment encrypted data and MAC headerrecord header: content type; version; lengthMAC: includes sequence number, MAC key MxFragment: each SSL fragment 214 bytes (~16 Kbytes)
28SSL Record Format content type SSL version length MAC data 1 byte 2 bytes3 bytesData and MAC encrypted (symmetric algo)
29Content types in record header application_data (23)alert (21)signaling errors during handshakehandshake (22)initial handshake messages are carried in records of type “handshake”Hankshake messages in turn have their own “sub” typeschange_cipher_spec (20)indicates change in encryption and authentication algorithms
30Real Connection Everything henceforth is encrypted TCP Fin follow handshake: ClientHellohandshake: ServerHellohandshake: Certificatehandshake: ServerHelloDonehandshake: ClientKeyExchangeChangeCipherSpechandshake: Finishedapplication_dataAlert: warning, close_notifyEverythinghenceforthis encryptedTCP Fin follow
31Short QuestionIn which step of SSL handshake, can Alice discover that she is not talking with Bob?handshake: ClientHellohandshake: ServerHelloBob’s certificateAliceTrudyBobhandshake: ClientKeyExchangeChangeCipherSpechandshake: Finished
32P19.Packet 112 sent by client or server?Server IP and port?What is the seq. no of the next TCP segment sent by client?Client(https)79 (seq) (len) = 283
33P19.d) Does packet 112 contain a Master Secret?e) Assume HandShake type field is 1 byte, each length field is 3 bytes, what are the values of the first / last bytes of Master Secret?YesFirst: bc; Last: 29
34Key derivationClient nonce, server nonce, and pre-master secret input into pseudo random-number generator.Produces master secretMaster secret and new nonces inputed into another random-number generator: “key block”Because of session resumption: Talk later.Key block sliced and diced:client MAC keyserver MAC keyclient encryption keyserver encryption keyclient initialization vector (IV)server initialization vector (IV)
35RECALL: Cipher Block Chaining (CBC) CBC generates its own random numbersHave encryption of current block depend on result of previous blockc(i) = KS( m(i) c(i-1) )m(i) = KS( c(i)) c(i-1)How do we encrypt first block?Initialization vector (IV): random block = c(0)IV does not have to be secretChange IV for each message (or session)Guarantees that even if the same message is sent repeatedly, the ciphertext will be completely different each time
36Short Question:Suppose an SSL session employs a block cipher with CBC (cipher block chaining).The server sends Initialization Vector (VI) in clear-text?True or False?False. Each side can derive it.
37Short Question: What is the purpose of random nonces in SSL handshake? Defend against Playback Attack
38SSL PerformanceBig-number operations in public-key crypto are CPU intensiveServer handshakeTypically over half SSL handshake CPU time goes to RSA decryption of the encrypted pre_master_secretClient handshakePublic key encryption is less expensiveServer is handshake bottleneckData transferSymmetric encryptionMAC calculationNeither as CPU intensive as public-key decryption
39Session resumptionFull handshake is expensive: CPU time and number of RTTsIf the client and server have already communicated once, they can skip handshake and proceed directly to data transferFor a given session, client and server store session_id, master_secret, negotiated ciphersClient sends session_id in ClientHelloServer then agrees to resume in ServerHelloNew key_block computed from master_secret and client and server random numbers
40Client authentication SSL can also authenticate clientServer sends a CertificateRequest message to client