23
Learning Network Security with SSL The OpenSSL Way Shalendra Chhabra [email protected]. Computer Science and Enginering University of California, Riverside http://www.cs.ucr.edu/ ˜ schhabra Slides Available from http://www.cs.ucr.edu/ ˜ schhabra/scale05.pdf SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.1/23

Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Learning Network Security with SSLThe OpenSSL Way

Shalendra Chhabra

[email protected].

Computer Science and Enginering

University of California, Riverside

http://www.cs.ucr.edu/s̃chhabra

Slides Available from http://www.cs.ucr.edu/s̃chhabra/scale05.pdf

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.1/23

Page 2: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Cryptography and Its Goals

• Confidentiality (secrecy)

• Integrity (anti-tampering)

• Authentication• Non-repudiation

• Snooping (passive eavesdropping)

• Tampering

• Spoofing

• Hijacking

• Capture-replay

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.2/23

Page 3: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Crytographic Algorithms

• Symmetric Key Encryption: DES, 3DES, AES, IDEA, BLOWFISH: Faster

• Public Key Encryption: Diffie Hellman (1976, New Directions inCryptography), RSA, DSA: Slower

• Cryptographic Hash Functions : MD2, MD5 (16 byte), SHA (20 bytes):One Way, Fixed Output, Collision Free

• HMAC: Message Authentication Codes based on Hash Functionsare called HMAC

• Digital Signatures: Hash signed with the Private Key

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.3/23

Page 4: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

A Glimpse of How Transactions in ECommerce Work

(Generally)

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.4/23

Page 5: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

http and https - Watch this "Lock"!

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.5/23

Page 6: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Secure Socket Layer and Transport Layer Security

• History and Versions: SSL/TLSDeveloped by Netscape, 1996 and then served as a basis for TLS, an IETFstandard protocol

• TLS 1.1 - RFC 2246 12/2004, Expires 06/2005

• SSL v 3.0 - Internet Draft Expires 9/96

• “https”: HTTP Over TLS: RFC 2818

• Early Weak KeysEarlier a restriction of 40-bit keyspace small enough to be broken by Brute ForceSearch. Modern implementations use 128-bit (or longer) keys for symmetric keyciphers.

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.6/23

Page 7: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Protocol Stack with TLS

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.7/23

Page 8: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Flow of Application Data Through The Stack

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.8/23

Page 9: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Architecture of TLS v 1.1

• TLS Handshake Protocol• TLS Record Protocol• TLS Change Cipher Spec Protocol

• TLS Alert Protocol

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.9/23

Page 10: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Message Flow for a Full Handshake

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.10/23

Page 11: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Message Flow for a Full Handshake

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.11/23

Page 12: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Digital Signature

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.12/23

Page 13: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Format of ClientHello and ServerHello

struct { ProtocolVersion client_version;Random random;SessionID session_id;CipherSuite cipher_suites<2..216

− 1 >;CompressionMethod compression_methods<1..28

− 1 >;} ClientHello;

struct { ProtocolVersion server_version;Random random;SessionID session_id;CipherSuite cipher_suite;CompressionMethod compression_method;} ServerHello;

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.13/23

Page 14: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Format of an X509 certificate

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.14/23

Page 15: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

OpenSSL

• Go to www.openssl.org

• Click on Source on the left• Download the latest version of openssl:Oct 25 13:44:48 2004 openssl-0.9.7e.tar.gz

• As su install $tar -zxvf /usr/local/openssl-0.9.7e.tar.gz

• $cd /usr/local/openssl-0.9.7e

• $./configure

• $make• $make install• $openssl version

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.15/23

Page 16: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Command Line Interface

• Configuration Filesca,req, x509

• Format of the OpenSSL Configuration File:Organized in Sections and Each section contains a set of keys and each key hasan associated value

• cat /usr/share/ssl/openssl.cnf

• openssl dgst -sha1 file.txt

• openssl sha1 -out digst.txt file.txt

• openssl enc -des3 -salt -in file.txt -out ciphertext.bin

• openssl bf-cfb -salt -in file.txt -out ciphertext.bin -passenv: HOME

• openssl base64 -in ciphertext.bin -out base64.txt

• openssl dhparam -out dhparam.pem -2 1024

• openssl dhparam -in dhparam.pem -noout -C

• openssl dsaparam -out dsaparam.pem 1024

• openssl genrsa -out rsaprivatekey.pem -passout pass:test-des3 1024

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.16/23

Page 17: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Creating a Self-Signed Root Certificate

• openssl req -x509 -newkey rsa -out cacert.pem -outform PEM

• cat cacert.pem

• openssl x509 -in cacert.pem -text -noout

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.17/23

Page 18: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Writing some Client Server Programs using OpenSSL in C

• $cd /usr/local/openssl-0.9.7e/demos/ssl

• $ls• $serv.cpp cli.cpp

• Compile Server i.e. serv.cpp

• $g++ -c serv.cppor

• $g++ -I/usr/local/include -c serv.cpp

• $g++ serv.o -lssl -o servertestor

• $g++ serv.o /usr/local/lib/libssl.a /usr/local/lib/libcrypto.a -o servertest

• Compile Client i.e. cli.cpp in the same manner

• Wait we need Server Certificate and Private Key

• $openssl req -x509 -newkey rsa -out cert.pem -outform PEM

• $ cat cert.pem privkey.pem » foo-cert.pem

• $./servertest• $./clientest• $ Run SSLDump SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.18/23

Page 19: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

SSLDump and SSLSniffer

$openssl s_client -connect www.paypal.com:443$ssldump -i eth0 port 443New TCP connection 1: 192.168.1.103(32952) <-> 206.65.183.42(443)1 1 0.0834 (0.0834) C>S HandshakeClientHelloVersion 3.1resume [32]=23 22 00 00 b9 8d c0 23 0e fe 0d cb b4 c8 89 e98e 8c 14 da e4 d5 2d 0a 56 ed c5 61 11 48 4a 84cipher suitesUnknown value 0x39Unknown value 0x38Unknown value 0x35Unknown value 0x33Unknown value 0x32TLS_RSA_WITH_RC4_128_MD5TLS_RSA_WITH_RC4_128_SHA·

2 3 0.1954 (0.0000) S>C ChangeCipherSpec2 4 0.1954 (0.0000) S>C Handshake2 5 0.1984 (0.0029) C>S ChangeCipherSpec2 6 0.1984 (0.0000) C>S Handshake2 7 0.1984 (0.0000) C>S application_data2 8 0.2955 (0.0970) S>C application_data2 9 0.2955 (0.0000) S>C application_data2 10 0.2970 (0.0015) C>S Alert2 0.2971 (0.0001) C>S TCP FIN2 0.2980 (0.0008) S>C TCP FIN

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.19/23

Page 20: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

Security Analysis of SSL Protocol

• Version Rollback Attack• Attacks on Handshack Protocol• If using Public Key Crytography (Diffie Hellman) Man in the Middle Attack

• Analysis of the SSL 3.0 Protocol, D. Wagner and B. SchneierThe Second USENIX Workshop on Electronic Commerce Proceedings, USENIXPress, November 1996, pp. 29-40.

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.20/23

Page 21: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

"Network Security with OpenSSL"

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.21/23

Page 22: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

"SSL and TLS: Designing and Building Secure Systems"

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.22/23

Page 23: Learning Network Security with SSL The OpenSSL Way...History and Versions: SSL/TLS Developed by Netscape, 1996 and then served as a basis for TLS, an IETF standard protocol TLS 1.1

References

1. SSL 3.0 Specification: http://wp.netscape.com/eng/ssl3/

2. OpenSSL: http://www.openssl.org

3. SSLDump: http://www.rtfm.com/ssldump/

4. Network Security With OpenSSL by John Viega, Matt Messier and Pravir Chandra

5. Slides available from http://www.cs.ucr.edu/s̃chhabra/scale05.pdf

SCALE 05: Southern California Linux Expo 2005, LA, 02-13-2005 – p.23/23