cryptography: practice - jmu

74
Cryptography: Practice 2013 JMU Cyber Defense Boot Camp

Upload: others

Post on 21-Jan-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cryptography: Practice - JMU

Cryptography: Practice

2013 JMU Cyber Defense Boot Camp

Page 2: Cryptography: Practice - JMU

Prerequisites

• This unit assumes that you have already known– Symmetric-key encryption– Public-key encryption– Digital signature– Digital certificates

2013 Summer Camp 2

Page 3: Cryptography: Practice - JMU

Step 0

• Use Firefox to log into your vCenter server and find your Windows 2003 VM

• Use the “WLAN and Crypto Security” VM snapshot

2013 Summer Camp 3

Page 4: Cryptography: Practice - JMU

Organization

• Practice– Truecrypt– GPG

2013 Summer Camp 4

Page 5: Cryptography: Practice - JMU

Road Map

• Practice– Truecrypt– GPG

2013 Summer Camp 5

Page 6: Cryptography: Practice - JMU

TrueCrypt

• Open-source disk encryption software– Not just encrypting single files, but the whole disk

• Supports Windows, Linux, and Mac OS– http://www.truecrypt.org/

• Has been used by “bad people” to encrypt laptops and external hard disks

2013 Summer Camp 6

Page 7: Cryptography: Practice - JMU

Step 1

• Download and install– http://www.truecrypt.org/downloads

• NOTE: TrueCrypt has already been installed on your Windows 2003 VM under the “WLAN and Crypto Security” VM snapshot

2013 Summer Camp 7

Page 8: Cryptography: Practice - JMU

Step 2: Run TrueCrypt

• Start > All Programs > TrueCrypt > TrueCrypt

• (You can also run it directly from a shortcut on your Desktop)

2013 Summer Camp 8

Page 9: Cryptography: Practice - JMU

Step 2

• Create a virtual encrypted disk (called file containers)– Put all of your critical files there

2013 Summer Camp 9

Page 10: Cryptography: Practice - JMU

2013 Summer Camp 10

Page 11: Cryptography: Practice - JMU

2013 Summer Camp 11

CREDITS: some of these screen snapshots are from http://www.truecrypt.org/docs/

Page 12: Cryptography: Practice - JMU

2013 Summer Camp 12

Page 13: Cryptography: Practice - JMU

The Location of the Virtual Encrypted Disk

2013 Summer Camp 13

Page 14: Cryptography: Practice - JMU

2013 Summer Camp 14

Page 15: Cryptography: Practice - JMU

2013 Summer Camp 15

Page 16: Cryptography: Practice - JMU

2013 Summer Camp 16

AES is a symmetric encryption algorithm

standard

Select SHA-512, a US crypto hash standard

Page 17: Cryptography: Practice - JMU

2013 Summer Camp 17

The size of your virtual encrypted disk; Choose

2G if you like

Page 18: Cryptography: Practice - JMU

2013 Summer Camp 18

This is the password used to protect your

virtual disk

You can generate a random key and use

it to protect your virtual disk. Let’s not

do this now

Page 19: Cryptography: Practice - JMU

2013 Summer Camp 19

Move your mouse around for 10 seconds

to generate some random

bits

Page 20: Cryptography: Practice - JMU

2013 Summer Camp 20

Page 21: Cryptography: Practice - JMU

2013 Summer Camp 21

Your virtual disk will be

mounted as M:

Page 22: Cryptography: Practice - JMU

2013 Summer Camp 22

Page 23: Cryptography: Practice - JMU

2013 Summer Camp 23

select your virtual disk file

Page 24: Cryptography: Practice - JMU

2013 Summer Camp 24

select an available drive letter first

Page 25: Cryptography: Practice - JMU

2013 Summer Camp 25

This is the password that you set earlier

Page 26: Cryptography: Practice - JMU

2013 Summer Camp 26

Page 27: Cryptography: Practice - JMU

2013 Summer Camp 27

You will have a new M: drive

Page 28: Cryptography: Practice - JMU

2013 Summer Camp 28

You can copy your security-critical files

to/from your M: drive

Page 29: Cryptography: Practice - JMU

Security-critical Files?

• Create a security-critical text file, finance.txt– Save the following information to it

• your SSN and credit numbers in it• Your online banking account information• Your utility bill accounts information• Your other “important” digital stuffs

• Save it to M: drive

2013 Summer Camp 29

Page 30: Cryptography: Practice - JMU

2013 Summer Camp 30

At this moment, your files on M: are in the clear

Page 31: Cryptography: Practice - JMU

2013 Summer Camp 31

You can dismount your M: drive to

protect it

Page 32: Cryptography: Practice - JMU

ExerciseCreate a TrueCrypt virtual disk (filename: your_first_name-last_name)Create a text file, finance.txt, and save it to your virtual diskDismount your virtual diskExamine file your_first_name-last_name to see whether you can find any information about finance.txtCopy your_first_name-last_name to c:\tmpMount c:\tmp\ your_first_name-last_name (the new copy)Open finance.txt

2013 Summer Camp 32

Page 33: Cryptography: Practice - JMU

Is It Really Secure?

• You can examine your virtual disk file

• If a hacker has stolen your virtual disk file, he/she will not be able to see your critical files

2013 Summer Camp 33

Page 34: Cryptography: Practice - JMU

Do You Really Know What You are Doing?

• If you pick a strong password and forget it, you will NOT be able to recover any data on the virtual disk– Probably nobody will be

able to help you

• Know your risk!

2013 Summer Camp 34

Warning

Page 35: Cryptography: Practice - JMU

Road Map

• Practice– Truecrypt– GPG

2013 Summer Camp 35

Page 36: Cryptography: Practice - JMU

Cryptography ≠ Encryption

• Public-key cryptography can be used for digital signature

• The digital counterpart of hand-written signature

2013 Summer Camp 36

Page 37: Cryptography: Practice - JMU

Digital Signature

• Alice uses her private key to digitally sign a message (a bit string)– Everybody can use Alice’s public key to verify Alice’s

digital signature• Algorithm buzzwords

– RSA digital signature– Digital Signature Standard (DSS)– Elliptic-curve digital signature algorithm (ECDSA)

• (Do not confuse digital signature with email signature in MS Outlook!)

2013 Summer Camp 37

Page 38: Cryptography: Practice - JMU

E-mail signature vs. Digital Signature

• E-mail signatureXunhua Wang, PhDDepartment of Computer ScienceJames Madison UniversityE-mail: [email protected]: 540-568-3668

• Digital signature01110011001…

2013 Summer Camp 38

This is not secure! Anybody can change it

Page 39: Cryptography: Practice - JMU

What if I Want to…

• Encryption/sign a single file/email?

• GNU Privacy Guard (GPG)• Windows version• Gpg4win

– http://www.gpg4win.org/

2013 Summer Camp 39

Page 40: Cryptography: Practice - JMU

Step 1

• Download Gpg4win and install it on your Windows 2003 VM– http://gpg4win.org/

• NOTE: Gpg4win has already been installed on your Windows 2003 VM under the “WLAN and Crypto Security” VM snapshot

2013 Summer Camp 40

Page 41: Cryptography: Practice - JMU

Step 2

• Run “Start -> All Programs -> Gpg4win -> Kleopatra”

• (You can also run it directly from a shortcut on your Desktop)

2013 Summer Camp 41

Page 42: Cryptography: Practice - JMU

2013 Summer Camp 42

“File -> New Certificates”

Page 43: Cryptography: Practice - JMU

2013 Summer Camp 43

Choose this one to generate your own public/private key pair

Page 44: Cryptography: Practice - JMU

2013 Summer Camp 44

Enter the required information

Page 45: Cryptography: Practice - JMU

2013 Summer Camp 45

Choose the algorithm

The purposes of your key pair

Page 46: Cryptography: Practice - JMU

2013 Summer Camp 46

Choose a password to protect your private

key

Page 47: Cryptography: Practice - JMU

2013 Summer Camp 47

Click this to back up your privatekey to a file (see next slide)

Everything is cool

Page 48: Cryptography: Practice - JMU

2013 Summer Camp 48

This is your private key in a file

This is your private key, it is supposed to be secret: do not lose it or send it to your friend

Page 49: Cryptography: Practice - JMU

2013 Summer Camp 49

This is my public key; I can export it to a file and email it to Bob

Right click on this to export it to a file

Page 50: Cryptography: Practice - JMU

2013 Summer Camp 50

This is my public key in a file

I can email it to my friends

Page 51: Cryptography: Practice - JMU

Exercise #1

Export your public key to a file and email it to the student next to you

After receiving a public key from your classmate, import it to your Gpg4win (see next slide)

2013 Summer Camp 51

Page 52: Cryptography: Practice - JMU

2013 Summer Camp 52

Click “File -> Import Certificates …” to import the public key

received from your classmate

Page 53: Cryptography: Practice - JMU

Now, I Want to digitally Sign a file and Send it to My Friend

2013 Summer Camp 53

This is the file to be digitally signed (testfile.txt)

Page 54: Cryptography: Practice - JMU

2013 Summer Camp 54

Click “File -> Sign/Encrypt Files …”

Page 55: Cryptography: Practice - JMU

2013 Summer Camp 55

You have three choices

Page 56: Cryptography: Practice - JMU

2013 Summer Camp 56

I want to digitally sign the file this time

Page 57: Cryptography: Practice - JMU

2013 Summer Camp 57

Choose the private key to digitally sign the file

Page 58: Cryptography: Practice - JMU

2013 Summer Camp 58

My private key is protected by a password

Page 59: Cryptography: Practice - JMU

2013 Summer Camp 59

Everything is cool

So, where is the digital signature for my file?

Page 60: Cryptography: Practice - JMU

2013 Summer Camp 60

My file is testfile.txt and the signature file is called testfile.txt.asc

Page 61: Cryptography: Practice - JMU

2013 Summer Camp 61

Next, I email both my file and the signature file to Bob (my classmate)

Page 62: Cryptography: Practice - JMU

2013 Summer Camp 62

Bob: Click “File -> Decrypt/Verify Files …”

Bob selects the signature file received from me

Page 63: Cryptography: Practice - JMU

2013 Summer Camp 63

Bob:

Page 64: Cryptography: Practice - JMU

2013 Summer Camp 64

It tells Bob that this file is really from me, not from an attacker

Page 65: Cryptography: Practice - JMU

Exercise #2

Create a text file your_first_name-last_name-gpg4win.txt and digitally sign itEmail your_first_name-last_name-gpg4win.txt and the digital signature file to your classmateAfter receiving the files from your classmate, try to digitally verify them

2013 Summer Camp 65

Page 66: Cryptography: Practice - JMU

What if I want to digitally sign

• An email?– Not a file

• GnuPG for Outlook (GpgOL)– Use with Microsoft Outlook mail client

2013 Summer Camp 66

Page 67: Cryptography: Practice - JMU

Summary

• Practice– Truecrypt– GPG

2013 Summer Camp 67

Page 68: Cryptography: Practice - JMU

One More Note

• You can encrypt – a MS Word file with a password

• MS Word allows you to do this

– a MS Excel file with a password• MS Excel allows you to do this

– a PDF file with a password• Adobe Acrobat allows you to do this

2013 Summer Camp 68

Page 69: Cryptography: Practice - JMU

GPG on Unix/Linux (1/5)• gpg --gen-key

– User ID: real name, email address, comment– Passphrase for your private key– /home/user/.gnupg/trustdb.gpg

• Revocation certificate– gpg –a --output [email protected] --gen-revoke

[email protected]• Reason: 0

• Publicizing your key– gpg ---output [email protected] --export wangxx– gpg ---output [email protected] --armor --export

wangxx– gpg --keyserver subkeys.gpg.net --send-keys [email protected]

2013 Summer Camp 69

Page 70: Cryptography: Practice - JMU

On Linux

• GPG is also available on Linux

2013 Summer Camp 70

Page 71: Cryptography: Practice - JMU

GPG on Unix/Linux (2/5)

• keyserver x-hkp://subkeys.pgp.net

• Add keys to your keyring (public vs. private)– gpg --recv-keys E68C49BC– gpg --list-keys– gpg --list-secret-keys– gpg --list-keys [email protected]– gpg --import wang.asc

2013 Summer Camp 71

Page 72: Cryptography: Practice - JMU

GPG on Unix/Linux (3/5)• Signing a key

– gpg --fingerprint [email protected]– gpg --sign-key E2F41133

• Viewing key signatures– gpg --list-sigs E2F41133

• Export– gpg --output wangxx.asc --armor --export E2F41133

• Pushing signatures to keyservers– gpg --send-keys E2F41133

• Updating keys– gpg --refresh-keys

2013 Summer Camp 72

Page 73: Cryptography: Practice - JMU

GPG on Unix/Linux (4/5)

• Deleting keys– gpg --delete-keys E2F41133

• gpg --update-trustdb

2013 Summer Camp 73

Page 74: Cryptography: Practice - JMU

GPG on Unix/Linux (5/5)

• To digitally sign a file– gpg –s filename

• To verify a digital signature– gpg --verify filenameOfSignature

• Encrypt data– gpg –e filename

• Decrypt data– gpg --decrypt msg.asc

2013 Summer Camp 74