Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in...

33
© August 2014 Cryptographic Basics Greg Boyd www.mainframecrypto.com Share 15659

Transcript of Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in...

Page 1: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

August 2014

Cryptographic BasicsGreg Boyd

www.mainframecrypto.com

Share 15659

Page 2: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Copyrights and Trademarks

• Presentation based on material copyrighted by IBM, and developed by myself, as well as many others that I worked with over the past 10 years

• Copyright © 2014 Greg Boyd, Mainframe Crypto, LLC. All rights reserved. • All trademarks, trade names, service marks and logos referenced herein belong to their

respective companies. IBM, System z, zEnterprise and z/OS are trademarks of International Business Machines Corporation in the United States, other countries, or both. All trademarks, trade names, service marks and logos referenced herein belong to their respective companies.

• THIS PRESENTATION IS FOR YOUR INFORMATIONAL PURPOSES ONLY. Greg Boyd and Mainframe Crypto, LLC assumes no responsibility for the accuracy or completeness of the information. TO THE EXTENT PERMITTED BY APPLICABLE LAW, THIS DOCUMENT IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NONINFRINGEMENT. In no event will Greg Boyd or Mainframe Crypto, LLC be liable for any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost investment, business interruption, goodwill, or lost data, even if expressly advised in advance of the possibility of such damages.

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 2

Page 3: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

QR Code

• Share #15659

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 3

Page 4: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

What we’re going to cover

• Some context• Cryptographic Functions

• Symmetric Algorithms• Asymmetric Algorithms• Hashing • Digital Signatures and Digital Certificates• Financial

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 4

Page 5: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Today’s Business Environment

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics Page 5 of 33

GovernmentHospital

Finance

Insurance

TransportationDistribution

RemoteUser

InternetIntranet

Endless Possibilities, but they require confidence

Page 6: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Business Requirements

• Trust• Confidentiality

• Trade Secrets• Business transactions

• Privacy• Personal Information

• Accountability/ Auditability

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics Page 6 of 33

Page 7: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Industry Pressures: Addressing Regulations

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics Page 7 of 33

1995EU Data Protection

Directive EU

1996HIPAA

US

2002Sarbanes-Oxley Act

US

1999Gramm-Leach-

Bliley Act (GLBA)US

1987Computer Security

Act US

2000PIPEDACanada

1997Personal Health Information Act

Canada

1998Data Protection Act

UK

2001USA PATRIOT

ActUS

2008 PCI DSS v1.2

Industry

2000 COPPA and CIPA

US

2002Corporate Law

Economic Reform ProgramAustralia

2003Basel II

EU

2003California Individual Privacy (SB1386)

California

Financial Integrity and Solvency Regulations

Privacy Regulations

Other Regulations

2006Federal Rules of Evidence

US

2006Financial Instruments and Exchange Law

(J-SOX)Japan

20058th Company Law

Directive (Euro SOX)

EU

2012Solvency II

EU

Page 8: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Cryptography

• Secrecy• Integrity• Financial Authentication• Key Protection

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 8

Page 9: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Secrecy Algorithms - Symmetric

• Symmetric - One key shared by both parties

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 9

Symmetric Algorithm(encrypt)

CleartextCiphertext

Symmetric Algorithm(decrypt)Ciphertext

Cleartext

+ Speed (compared to asymmetric)- Key Distribution

Page 10: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Secrecy Algorithms - Asymmetric

• Asymmetric – two different, but mathematically related keys (public and private)

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 10

Asymmetric Algorithm(encrypt)

CleartextCiphertext

Asymmetric Algorithm(decrypt)

CiphertextCleartext

Public Key

Private Key

+ Key Distribution- Speed (compared to symmetric)

Page 11: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Algorithms

• Symmetric• DES/TDES*• AES*• Blowfish / Twofish• Serpent• IDEA• RC2 / RC4• Skipjack• ….

• Asymmetric• RSA*• Diffie-Hellman*• ECC*

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 11

*Supported on IBM Hardware

Page 12: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

DES Algorithm - Encrypt

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 12

Data (Cleartext)

Ciphertext

8-Byte Key

DES Encrypt

Page 13: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

DES

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 13

http://courses.cs.washington.edu/courses/cse467/99au/admin/Slides/Week6Lecture1/sld006.htm

Page 14: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

DES Algorithm – Encrypt & Decrypt

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 14

Data (Cleartext)

Ciphertext

8-Byte Key

DES Encrypt

8-Byte Key

Ciphertext

DES Decrypt

Data (Cleartext)

Page 15: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

TDES Algorithm - Enrcrypt

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 15

Data (Cleartext)

Ciphertext1

8-Byte Key

DES Encrypt 8-Byte

Key

Ciphertext2

DES Decrypt

Ciphertext3

DES Encrypt8-Byte

Key

Page 16: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

TDES Algorithm – Encrypt & Decrypt

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 16

Data (Cleartext)

Ciphertext1

8-Byte Key

DES Encrypt 8-Byte

Key

Ciphertext2

DES Decrypt

Ciphertext3

DES Encrypt

8-Byte Key

Ciphertext3

DES Decrypt

8-Byte Key

Ciphertext2

8-Byte Key

8-Byte Key

Ciphertext1

DES Encrypt

DES Decrypt

Data (Cleartext)

Page 17: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

TDES Algorithm – DES Compatibility

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 17

Data (Cleartext)

Ciphertext1

8-Byte Key

DES Encrypt 8-Byte

Key

DES Decrypt

Ciphertext1

DES Encrypt8-Byte

Key

Data (Cleartext)

Page 18: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

AES Algorithm

• Multiple Rounds• 128-bit keys, 10 cycles• 192-bit keys, 12 cycles• 256-bit keys, 14 cycles

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 18

Page 19: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Asymmetric Algorithms

• RSA• Diffie-Hellman• Elliptic Curve

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 19

Page 20: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Generating RSA Keys• RSA Keys consists of two parts, a modulus (N) and an exponent (E for the public

key; D for the private key)• Public Key => N E• Private Key => N D

• The modulus is calculated by multiplying two prime numbers (P & Q) together• P = 5 Q = 11 (in reality, these should be very large prime numbers, 100s of digits long)• N = P x Q => 5 x 11 = 55

• Next, select an odd number, E, that will be the exponent for the public key• Good values include 3 or 65537 (64K+1)

Public Key => N E => 55 3

• Finally, calculate the exponent for the private key, D, where 1 = (D * E) MOD ((P-1)(Q-1))

• In our example, solve for 1 = (D * 3) MOD 40 => D = 27!Private Key => N D => 55 27

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics Page 20

=55 3 55 27

Page 21: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Encipher the Message ‘GPB’Public Key (N E) => 55 3Private Key (N D) => 55 27Convert characters to numeric (a=1, b=2, c=3, etc.)

‘G’ = 7; ‘P’ = 16; ‘B’ = 2;

ciphertext = (cleartext**E) Mod N• For ‘G’ (7**3) MOD 55 => 343 MOD 55 = 13• For ‘P’ (16**3) MOD 55 => 4096 MOD 55 = 26• For ‘B’ (2**3) MOD 55 => 8 MOD 55 = 8

Ciphertext is 13 26 8

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics Page 21

=55 3 55 27

Page 22: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Decipher the message 13 26 8Public Key (N E) => 55 3Private Key (N D) => 55 27Cleartext = (ciphertext**D) MOD N

• For 13 13**27 MOD 55 = 7(13**27 = 1192533292512492016559195008117)

• For 26 26**27 MOD 55 = 16(26**27 = 1.6005910908538609008071353149841e+38)

• For 8 8**27 mod 55 = 2(8**27 = 2417851639229258349412352)

• My decrypted message is 7 16 2 => “G” “P” “B”

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics Page 22

=55 3 55 27

Page 23: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

ECC Algorithm

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 23

is

Image from crypto.stackexchange.com

Effective Key Size

Symmetric RSA ECC

80 1024 163

112 2048 224

128 3072 256

192 7680 384

256 15360 512

From NIST SP 800-57 Part 1 (Table 2) at www.nist.gov

Page 24: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Complimentary algorithms• Symmetric

• Fast for large messages, but key distribution is a problem

• Asymmetric• Expensive, so only use for small messages, but easy to distribute keys

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 24

Page 25: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Hashing• One iteration in a SHA-2 family compression function. The blue components

perform the following operations:

• The bitwise rotation uses different constants for SHA-512. The given numbers are for SHA-256. The red is addition modulo 232.

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 25

from wikipedia

Page 26: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Hashing – Modification Detection Code

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 26

Data

Hash Algorithm

MDC

• Characteristics of a good hash algorithm– One-way – can’t recover the data from the hash– Hard to find collisions– The result does not reveal information about the input

Page 27: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Hashing – Message Authentication Code

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 27

Data

Hash Algorithm

MAC

• Add a secret key into the calculation

Page 28: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Digital Signatures

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 28

Message

Hash Algorithm

MDC

Digital Signature

Page 29: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Digital Certificate

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 29

Subject Name Info

Subject Public KeyDates

Version / Serial Number Algorithms

Issuer Name Info

Keystore

Certificate Request

MDC

Certificate Authority Private Key

Subject Name Info

Subject Public KeyDates

Version / Serial Number Algorithms

Issuer Name Info

Digital Signature

Digital Signature

Certificate

MDC Certificate Authority Public Key

Page 30: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Financial Authentication

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 30

Routing Number: 12345678Account Number: 9876543210Sequence Number: 1

PIN Block:4567898765432101 8A092F6E7D637B25

Decimalization Table

0 -> 0 1 -> 1 2 -> 2 3 -> 3

4 -> 4 5 -> 5 6 -> 6 7 -> 7

8 -> 8 9 -> 9 A -> 0 B -> 1

C -> 2 D -> 3 E -> 4 F -> 5

0925

Pin Block FormatsECI-2, ECI-3, ISO-0, ISO-1, ISO-2, ISO-3,VISA-2, VISA-3, VISA-4, 3621, 3624, 4704-EPP

Offset: 1234

1159

Page 31: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

References

• Cryptography Books• Bruce Schneier, ‘Applied Cryptography, Second Edition:

Protocols, Algorithms, and Source Code in “C”’, John Wiley & Sons, Inc. 1996

• Simon Singh, ‘The Code Book’, Anchor Books, 1999• Niels Ferguson, Bruce Schneier, ‘Practical Cryptography’,

Wiley Publishing, Inc. 2003• Free Stuff

• www.schneier.com – Bruce Schneier website, with monthly newsletter Crypto-gram

• Standards• csrc.nist.gov – Computer Security Resource Center of NIST• www.emc.com/emc-plus/rsalabs - RSA Labs

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 31

Page 32: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

Questions?

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 32

[email protected]

Page 33: Cryptographic Basics - the Conference Exchange€¦ · any loss or damage, direct or indirect, in connection with this presentation, including, without limitation, lost profits, lost

©

QR Code

• Share #15659

Share Pittsburgh, Aug 2014 Share 15659: Cryptographic Basics 33