The Java Crypto API ICW Lecture 3 Tom Chothia. Reminder of Last Time: Your programs defines “Classes”. Each class defines “Objects”. An Object is defined.

Slides:



Advertisements
Similar presentations
Security and Privacy over the Internet Chan Hing Wing, Anthony Mphil Yr. 1, CSE, CUHK Oct 19, 1998.
Advertisements

Network Security: Lab#2 J. H. Wang Apr. 28, 2011.
Internet and Intranet Protocols and Applications Lecture 9a: Secure Sockets Layer (SSL) March, 2004 Arthur Goldberg Computer Science Department New York.
NSRC Workshop Some fundamental security concerns... Confidentiality - could someone else read my data? Integrity - has my data been changed? Authentication.
Web Security for Network and System Administrators1 Chapter 4 Encryption.
Java Security Model Lab#1 I. Omaima Al-Matrafi. Safety features built into the JVM Type-safe reference casting Structured memory access (no pointer arithmetic)
Copyright Justin Klein Keane InfoSec Training Encryption.
Lesson Title: Introduction to Cryptography Dale R. Thompson Computer Science and Computer Engineering Dept. University of Arkansas
Dr Alejandra Flores-Mosri Message Authentication Internet Management & Security 06 Learning outcomes At the end of this session, you should be able to:
Cryptography Basic (cont)
Chapter 5 Cryptography Protecting principals communication in systems.
BY MUKTADIUR RAHMAN MAY 06, 2010 INTERODUCTION TO CRYPTOGRAPHY.
CMSC 414 Computer and Network Security Lecture 5 Jonathan Katz.
Distributed Systems1 Lecture 12: RSA Distributed Systems2 Plan for today: Introduce RSA and a toy example using small numbers. This is.
Secure Hashing and DSS Sultan Almuhammadi ICS 454 Principles of Cryptography.
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
CMSC 414 Computer and Network Security Lecture 6 Jonathan Katz.
Cryptography April 20, 2010 MIS 4600 – MBA © Abdou Illia.
Fall 2010/Lecture 311 CS 426 (Fall 2010) Public Key Encryption and Digital Signatures.
Chapter 13: Electronic Commerce and Information Security Invitation to Computer Science, C++ Version, Fourth Edition SP09: Contains security section (13.4)
Secure Sockets SSL/TLS ICW: Lecture 6 Tom Chothia.
Lecture 4 Cryptographic Tools (cont) modified from slides of Lawrie Brown.
Encryption Methods By: Michael A. Scott
Lecture 3: Cryptographic Tools
Csci5233 Computer Security1 GS: Chapter 5 Asymmetric Encryption in Java.
Encryption is a way to transform a message so that only the sender and recipient can read, see or understand it. The mechanism is based on the use of.
1 Chapter 4 Encryption. 2 Objectives In this chapter, you will: Learn the basics of encryption technology Recognize popular symmetric encryption algorithms.
SSL Technology Overview and Troubleshooting Tips.
Sorting Out Digital Certificates Bill blog.codingoutloud.com ··· Boston Azure ··· 13·Dec·2012 ···
CRYPTOGRAPHY PROGRAMMING ON ANDROID Jinsheng Xu Associate Professor North Carolina A&T State University.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Copyright © 2003 T. Trappenberg Overview E 1 E1. Security Module 1 Technology: GR01E - Electronic Commerce Overview.
© Neeraj Suri EU-NSF ICT March 2006 DEWSNet Dependable Embedded Wired/Wireless Networks MUET Jamshoro Computer Security: Principles and Practice Slides.
Chi-Cheng Lin, Winona State University CS 313 Introduction to Computer Networking & Telecommunication Network Security (A Very Brief Introduction)
Lecture 19 Page 1 CS 111 Online Symmetric Cryptosystems C = E(K,P) P = D(K,C) E() and D() are not necessarily the same operations.
CMSC 414 Computer and Network Security Lecture 6 Jonathan Katz.
Linux Networking and Security Chapter 8 Making Data Secure.
Security+ Guide to Network Security Fundamentals, Third Edition Chapter 11 Basic Cryptography.
Crypto Bro Rigby. History
Chapter 8: Scrambling Through Cryptography Security+ Guide to Network Security Fundamentals Second Edition.
CS526: Information Security Prof. Sam Wagstaff September 16, 2003 Cryptography Basics.
Module 3 – Cryptography Cryptography basics Ciphers Symmetric Key Algorithms Public Key Algorithms Message Digests Digital Signatures.
1 Securing Data and Communication. 2 Module - Securing Data and Communication ♦ Overview Data and communication over public networks like Internet can.
Computer Security: Principles and Practice First Edition by William Stallings and Lawrie Brown Lecture slides by Lawrie Brown Chapter 2 – Cryptographic.
Encryption Questions answered in this lecture: How does encryption provide privacy? How does encryption provide authentication? What is public key encryption?
Public / Private Keys was a big year… DES: Adopted as an encryption standard by the US government. It was an open standard. The NSA calls it “One.
Chapter 3 (B) – Key Management; Other Public Key Cryptosystems.
A Quick Tour of Cryptographic Primitives Anupam Datta CMU Fall A: Foundations of Security and Privacy.
Public Key Encryption.
Network Security – Special Topic on Skype Security.
Lecture 2: Introduction to Cryptography
Week 4 - Friday.  What did we talk about last time?  Snow day  But you should have read about  Key management.
Cryptography 1 Crypto Cryptography 2 Crypto  Cryptology  The art and science of making and breaking “secret codes”  Cryptography  making “secret.
14-1 Last time Internet Application Security and Privacy Basics of cryptography Symmetric-key encryption.
Java Security Session 19. Java Security / 2 of 23 Objectives Discuss Java cryptography Explain the Java Security Model Discuss each of the components.
Security fundamentals Topic 4 Encryption. Agenda Using encryption Cryptography Symmetric encryption Hash functions Public key encryption Applying cryptography.
TIBCO BusinessWorks.  Generating the key   You will have to create a certificate as you own the server.  The ‘Keytool’ is a utility provided in the.
1 Thuy, Le Huu | Pentalog VN Web Services Security.
1 Session 4 Module 6: Digital signatures. Digital Signatures / Session4 / 2 of 18 Module 4, 5 - Review (1)  Java 2 security model provides a consistent.
Electronic Mail Security Prepared by Dr. Lamiaa Elshenawy
MM Clements Cryptography. Last Week Firewalls A firewall cannot protect against poor server, client or network configuration A firewall cannot.
Network Security. Three tools Hash Function Block Cipher Public Key / Private Key.
Network Security: Lab#2 J. H. Wang Oct. 9, Objectives To learn to use message digests –MD5 To learn to use secure hash functions –SHA-1, SHA-2 To.
BCIS 4630 Fundamentals of IT Security
SOA Seminar1 Seminar on Service Oriented Architecture RSA.
 Encryption provides confidentiality  Information is unreadable to anyone without knowledge of the key  Hashing provides integrity  Verify the integrity.
Java Cryptography Nick Pullman DSU-MSIA Citigroup Information Security
ENGR 101 Compression and Encryption. Todays Lecture  Encryption  Symmetric Ciphers  Public Key Cryptography  Hashing.
Cryptography Basics and Symmetric Cryptography
Engineering Secure Software
Presentation transcript:

The Java Crypto API ICW Lecture 3 Tom Chothia

Reminder of Last Time: Your programs defines “Classes”. Each class defines “Objects”. An Object is defined as having a number of “Fields” that store data......and a number of “Methods” that perform computation.

This Time: Read and write from files. Generate and handle keys. How to encrypt and decrypt – public key encryption, – and symmetric key encryption. Hashes. Keystores

But this Lecture is Really About: APIs APIs are Application Programming Interfaces. They are libraries of useful programs that do most of the work for us. A lot of programming Java is using the right API.

Reading and Writing to a File Make a java.io.File object. Get the input and output streams. Put wrappers round the steams, e.g., PrintReader for strings. DataInputString for bytes. Read and write using.read and.write. Close using.close.

Code Demo See ReadWriteFile.java

Symmetric Key Encryption Symmetric key encryption uses the same key to encrypt and decrypt the message. encrypt (plain text, key) = cipher text decrypt(cipher text, key) = plain text Symmetric key encryption is fast, but handling the key can be difficult.

Popular Types of Symmetric Encryption Advanced Encryption Stardard (AES) –A good cipher, maybe the best. Data Encryption Standard (DES)/3DES –The old stardard, key now to short. –Still OK if you us it 3 times. –Used in e-passports.

Popular Types of Symmetric Encryption BlowFish –Like AES, RC4: Rivest Cypter 4 –Fast, used in SSL, WPA, problem is related keys are used in different sessions.

Public Key Cryptography Public Key Cryptography uses 2 keys: – A public key for encryption – A private key for decryption. You can tell anyone you public and anyone can encrypt data just for you. Only you can read the message.

Types of Public Key Cryptography Diffie-Hellman – First public key system. – Security based on the logs. RSA – Most common public key system. – Security based on factoring large primes – If in doubt use RSA Elliptic Curve – Based on curves in a finite field.

Useful APIs for Crypto javax.crypto.Cipher: – the Cipher object does the encryption. java.security.Key – a cryptographic key java.secuity.KeyFactory – Turn bytes into Key Objects. Also RSAPublicKey, X509EncodedKeySpec,... (remember cmd-shirt-O in Eclipse).

java.security.KeyGenerator Create the object with: kg = KeyGenerator.getInstance( ); Give the key length (if needed): kg.initialize(1024); Read out the key: Key key = kg.genKeyPair();

java.security.KeyPairGenerator Create the object with: kg = KeyPairGenerator.getInstance( ); Key the key length: kg.initialize(1024); Read out the keys: KeyPair keypair = kg.genKeyPair(); PrivateKey privKey = keypair.getPrivate(); PublicKey publicKey = keypair.getPublic();

Encryption In Java Steps to encrypt data in Java (see example code): Import package Create a cipher object Initiate the cipher object with the scheme you want in encrypt or decrypt mode. Pass the object the data you want to encrypt. Read the cipher text out. Decrypt in the same way.

Code Demo Encrypt file

Summary I've just shown you how to Read and write from files. Generate keys. How to encrypt and decrypt. Still to come: Read and write keys to files Keystores Hashes

Java keytool Most Java programs use existing keys rather than create keys themselves. The keytool command can be used to generate keys outside Java.

Saving a Key We can read and write the bytes of a key to a file. This is a bad idea. We want to – protect read access to private keys, – and make sure the publics ones are real.

The KeyStore Class A KeyStore holds password protected private keys and public keys as certicates. Make keystores using the keytool e.g. keytool -genkey -keyalg RSA -keypass password -alias mykey -storepass storepass -keystore myKeyStore

Demo Making a KeyStore with the keytool

KeyStore Methods getInstance(“JKS”): – creates a keystore Load(file,password): – loads key data from a file using password. getKey(alias,password) – get the key “alias” with given password getCertificate(alias) – gets a public key as a certificate

File Encryption Program Combining these we can write a program to encrypt files. See demo.

Hashes A hash of any Object is a short string generated from that Object. The hash of an object is always the same. Any small change makes the hash total different. It is very hard to go from the hash to the object. It is very unlikely that any two different objects have the same hash.

Types of Hash Algorithm SHA-1, SHA-2 current standard, however it is possible to file two messages that have the same hash. MD5 often used for error checking can also find two files with the same hash.

Hashes in Java See Hash.java

Uses of Hashing Download verification Message Verification Passwords (demo)

Password Cracking If an attacker gets the password shadow file – they can try to guess a password – and check if the hash of their guess is in the list. Truly random passwords are safe. Dictionary words are not.

Exercise 1: SHA1 password cracker. In 1 week I will give you a shadow file of SHA1 hashed passwords. You have to write a program that – Guesses a password – Hashes the Guess – Checks to see if it is in the list. Hint: find a list of common passwords online, and use this to build more.

Conclusion Encryption can be public key or symmetrical. Use a Cipher Object in Java to do de/encryption. Keep your keys in a password protected KeyStore.

Next Time How to make connections across the Internet. TCP/IP protocol Sockets in Java.