intro to crypto · unscrambling the complexity of crypto! © tdes algorithm february 2020 zexchange...

31
© Unscrambling the Complexity of Crypto! Unscrambling the Complexity of Crypto! February 2020 Intro to Crypto Greg Boyd ( [email protected])

Upload: others

Post on 30-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Unscrambling the Complexity of Crypto!

February 2020

Intro to CryptoGreg Boyd

([email protected])

Page 2: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Copyrights and Trademarks

• Copyright © 2020 Greg Boyd, Mainframe Crypto, LLC. All rights reserved. • Presentation based on material copyrighted by IBM, and developed by

myself, as well as many others that I worked with over the past 30+ years

• 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.

zExchange Intro to Crypto Page 2February 2020

Page 3: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Agenda – Intro To Crypto

• Some background• Crypto Functions

• Symmetric algorithms• Asymmetric algorithms• Hashes• PIN Support

zExchange Intro to Crypto Page 3February 2020

Page 4: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Historical Ciphers

zExchange Intro to Crypto Page 4February 2020

Scytale

Caesar Cipher, Key = 3

MAINFRAME

PDLQIUDPH

Vigenere Square, Key = BOYD

MAINFRAME

BOYDBOYDB

NOGQGFYPF

Page 5: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Today’s Business Environment

zExchange Intro to Crypto Page 5February 2020

GovernmentHospital

Finance

Insurance

TransportationDistribution

RemoteUser

TrustConfidentiality

Trade SecretsBusiness transactions

PrivacyPersonal Information

Accountability/ Auditability

Endless Possibilities, but they require confidence

Internet/Intranet

Page 6: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

What is Cryptography?

Cryptography (or cryptology; from Greek κρυπτός, kryptos, "hidden, secret"; and γράφω, gráphō, "I write", or -λογία, -logia, respectively)[1] is the practice and study of hiding information. In modern times cryptography is considered a branch of both mathematics and computer science and is affiliated closely with information theory, computer security and engineering.

From Wikipedia

zExchange Intro to Crypto Page 6February 2020

Page 7: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Cryptographic FunctionsData Confidentiality

Symmetric – DES/TDES, AESAsymmetric – RSA, Diffie-Hellman, ECC

Data IntegrityModification DetectionMessage AuthenticationNon-repudiation

Financial FunctionsKey Security & Integrity

zExchange Intro to Crypto Page 7February 2020

Page 8: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Confidentiality – Symmetric Algorithms• Symmetric - One key shared by both parties

zExchange Intro to Crypto Page 8February 2020

Symmetric Algorithm

(encrypt)

CleartextCiphertext

Symmetric Algorithm

(decrypt)Ciphertext

Cleartext

Page 9: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Symmetric Algorithms

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

*Supported on IBM Hardware

zExchange Intro to Crypto Page 9February 2020

Page 10: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

DES Algorithm - Encrypt

zExchange Intro to Crypto Page 10February 2020

Data (Cleartext)

Cipher text

8-Byte Key

DES Encrypt

Page 11: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Single Round of DES Encrypt

zExchange Intro to Crypto Page 11February 2020

Page 12: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

DES Algorithm - Decrypt

zExchange Intro to Crypto Page 12February 2020

Data (Cleartext)

Cipher text

8-Byte Key

DES Encrypt

8-Byte Key

Cipher text

DES Decrypt

Data (Cleartext)

Page 13: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

TDES Algorithm

zExchange Intro to Crypto Page 13February 2020

Data (Cleartext)

Cipher text1

8-Byte Key

DES Encrypt 8-Byte

Key

Cipher text2

DES Decrypt

Cipher text

DES Encrypt

8-Byte Key

Cipher text

DES Decrypt

8-Byte Key

Cipher text2

8-Byte Key

8-Byte Key

Cipher text1

DES Encrypt

DES Decrypt

Data (Cleartext)

Page 14: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

TDES Algorithm

zExchange Intro to Crypto Page 14February 2020

Data (Cleartext)

Ciphertext1

8-Byte Key

DES Encrypt 8-Byte

Key

DES Decrypt

Cipher text

DES Encrypt8-Byte

Key

Data (Cleartext)

Page 15: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Data Confidentiality - AES

• Rijndael Algorithm• Block Cipher (16-byte blocks)• 128-, 192-, 256-bit key length

• 128 bit key=> 3.4x10**38 (340 Undecillion)• 192 bit key=> 6.2x10**57 (6.2 Octodecillion)• 256 bit key=> 1.1x10**77 (almost a Googol)

• Multiple round• Four steps per round (Byte substitution, shift row, mix column,

add round key)

zExchange Intro to Crypto Page 15February 2020

Image from http://www.esat.kuleuven.ac.be/~rijmen/rijndael

Page 16: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Secrecy Algorithms - Asymmetric

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

zExchange Intro to Crypto Page 16February 2020

Asymmetric Algorithm

(encrypt)

CleartextCiphertext

Asymmetric Algorithm

(decrypt)

CiphertextCleartext

Public Key

Private Key

Page 17: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Asymmetric Algorithms

• Public Key Architecture - PKA• RSA - factorization• Diffie-Hellman - logarithmic• Elliptic Curve – point multiplication

zExchange Intro to Crypto Page 17February 2020

ABCD @!&1 ABCD

Public key Private key

Encryption Decryption

Plain text Plain textCipher text

Page 18: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

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 (prime numbers and should be very large)• 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) or 5, 17 or 257 with HCR77C0

Public Key=> N E => 55 3

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

zExchange Intro to Crypto Page 18February 2020

=55 3 55 27

• 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 (prime numbers and should be very large)• 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) or 5, 17 or 257 with HCR77C0

Public Key=> N E => 55 3

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

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

Page 19: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Encipher the Message ‘MFC’

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

‘M’ = 13; ‘F’ = 6; ‘C’ = 3; ciphertext = (cleartext**E) Mod N

• For ‘M’ (13**3) MOD 55 => 2197 MOD 55 = 52• For ‘F’ (6**3) MOD 55 => 216 MOD 55 = 51• For ‘C’ (3**3) MOD 55 => 9 MOD 55 = 27

Ciphertext is 52 51 27

zExchange Intro to Crypto Page 19February 2020

=55 3 55 27

Page 20: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Decipher the message 52 51 27

Public Key (N E) => 55 3Private Key (N D) => 55 27Cleartext = (ciphertext**D) MOD N

• For 52 52**27 MOD 55 = 13(52**27 = 2.1482769967144679013436706816572e+46)

• For 51 51**27 MOD 55 = 6(51**27 = 1.2717295264013893903823981998699e+46)

• For 27 27**27 mod 55 = 3(27**27 = 4.4342648824303776994824963061915e+38)

• My decrypted message is 13 6 3 => “M” “F” “C”

zExchange Intro to Crypto Page 20February 2020

=55 3 55 27

Page 21: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

ECC Algorithm

zExchange Intro to Crypto Page 21February 2020

Image from crypto.stackexchange.com

Effective Key Size (bits)Symmetric RSA ECC

80 1024 163112 2048 224128 3072 256192 7680 384256 15360 512From NIST SP 800-57 Part 1 (Table 2) at www.nist.gov

Page 22: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Why Asymmetric and Symmetric Keys?• Asymmetric

• plus - its strength, can be used to establish a secret between two parties

• minus – expensive in terms of performance

• Symmetric• plus - less resource intensive• minus - requires key to be shared securely

zExchange Intro to Crypto Page 22February 2020

=≠

Page 23: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Hashing

zExchange Intro to Crypto Page 23February 2020

Data

Hash Algorithm

Hash

• 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 24: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

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 modulo 232 addition.

zExchange Intro to Crypto Page 24February 2020

from wikipedia

Page 25: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Hashing – Message Authentication Code

zExchange Intro to Crypto Page 25February 2020

Message

Keyed authentication

MAC

Message Block 1

XOR ICV=0

ENC w/ MAC Key

Message Block 2

XOR

ENC w/ MAC Key

Message Block 3

XOR

ENC w/ MAC Key

Message Block 4

XOR

ENC w/ MAC Key

Message Block 5

XOR

ENC w/ MAC Key

MAC

Page 26: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Digital Signatures

zExchange Intro to Crypto Page 26February 2020

Message

Hash Algorithm

Hash

Digital Signature

Private Key

Page 27: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Digital Certificates

zExchange Intro to Crypto Page 27February 2020

Subject Name Info

Subject Public KeyDates

Version / Serial

Number AlgorithmsIssuer

Name Info

Keystore

Certificate Request

Hash

Certificate Authority Private

Key

Digital Signature

Digital Signature

Certificate

Hash Certificate Authority

Public Key

Subject Name Info

Subject Public KeyDates

Version / Serial

Number AlgorithmsIssuer

Name Info

Page 28: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Financial Authentication - PINs

zExchange Intro to Crypto Page 28February 2020

Routing Number: 12345678

Account Number: 9876543210

Sequence 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 Formats

ECI-2, ECI-3, ISO-0, ISO-1, ISO-2, ISO-3,

VISA-2, VISA-3, VISA-4, 3621, 3624, 4704-EPP

Offset: 1234

2159

Page 29: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

References

• Cryptography Books• Bruce Schneier, “Applied Cryptography, Second Edition: Protocols,

Algorithms, and Source Code in ‘C’”, Addison Weley Longman, Inc. 1997• 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 Cryptogram

zExchange Intro to Crypto Page 29February 2020

Page 30: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Standards Doc

• RSA• PKCS #1 RSA Cryptography Specifications Version 2.2

(https://tools.ietf.org/html/rfc8017) • ECC

• https://en.wikipedia.org/wiki/Elliptic-curve_cryptography• Also see ‘Recommendation for Pair-Wise Key-Establishment Schemes

Using Discrete Logarithm Cryptography https://csrc.nist.gov/publications/detail/sp/800-56a/rev-3/final

• AES• FIPS 197 Announcing the AES (https://doi.org/10.6028/NIST.FIPS.197)

• DES• FIPS 46-3 Data Encryption Standard - Withdrawn

(http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf)• TDES

• SP 800-67 Recommendation for the Triple Data Encryption Algorithm (TDEA) Block Cipher (https://csrc.nist.gov/publications/detail/sp/800-67/rev-2/final)

zExchange Intro to Crypto Page 30February 2020

Page 31: Intro to Crypto · Unscrambling the Complexity of Crypto! © TDES Algorithm February 2020 zExchange Intro to Crypto Page 13 Data (Cleartext) Cipher text1 8-Byte Key DES Encrypt 8-Byte

©Unscrambling the Complexity of Crypto!

Questions …

zExchange Intro to Crypto Page 31February 2020