26
Chapter 4: Public Key Basics RSA (Factorizing Primes) Elliptic Curve (Elliptic Curves) ElGamal (Discrete Logs) Prof Bill Buchanan OBE http://asecuritysite.com/crypto04 http://asecuritysite.com/encryption

chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

Chapter4:PublicKey Basics RSA(FactorizingPrimes) EllipticCurve(EllipticCurves)ElGamal(DiscreteLogs) ProfBillBuchananOBE http://asecuritysite.com/crypto04http://asecuritysite.com/encryption

Page 2: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

PublicKeyMethods

Page 3: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

PublicKeyMethods

• IntegerFactorization.Usingprimenumbers.Example:RSA.DigitalCerts/SSL.

• DiscreteLogarithms.Y=GxmodP.Example:ElGamal.

• EllipticCurveRelationships.Example:EllipticCurve.SmartCards,IoT,Tor,Bitcoin.

Page 4: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

PublicKeyMethods

• IntegerFactorization.Usingprimenumbers.Example:RSA.DigitalCerts/SSL.

• DiscreteLogarithms.Y=GxmodP.Example:ElGamal.

• EllipticCurveRelationships.Example:EllipticCurve.SmartCards,IoT,Tor,Bitcoin.

Page 5: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

PublicKeyMethods

• IntegerFactorization.Usingprimenumbers.Example:RSA.DigitalCerts/SSL.

• DiscreteLogarithms.Y=GxmodP.Example:ElGamal.

• EllipticCurveRelationships.Example:EllipticCurve.SmartCards,IoT,Tor,Bitcoin.

Page 6: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

Chapter4:PublicKey RSAProfBillBuchananOBE http://asecuritysite.com/crypto04http://asecuritysite.com/encryption

Page 7: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y
Page 8: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y
Page 9: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

RSA

• Twoprimesp,q.• CalculateN(modulus)aspxqeg3

and11.n=33.• CalculatePHIas(p-1)x(q-1).PHI=20• Selectefornocommonfactorwith

PHI.e=3.• Encryptionkey[e,n]or[3,33].• (dxe)mod20=1• (dx3)mod20=1• d=7• Decryptionkey[d,n]or[7,33]

Page 10: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

RSA• Encryptionkey[e,n]or[3,33].• Decryptionkey[d,n]or[7,33]• Cipher=MemodNegM=5.• Cipher=53mod33=26• Decipher=CdmodN• Decipher=(26)7mod33=5

Example

Calc

Page 11: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

Chapter4:PublicKey EllipticCurveProfBillBuchananOBE http://asecuritysite.com/crypto04http://asecuritysite.com/encryption

Page 12: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

EllipticCurve(EC)

• Pickapointontheellipticcurve(G).

• Generatearandomnumber(n)–thiswillbetheprivatekey.

• PublickeyisP=nxG• Bitcoin,IoTandToruseCurve55219[here].

Page 13: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

BitcoinKeyGeneration

Page 14: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

BitcoinTransaction

Page 15: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

EllipticCurve(EC)C\>opensslecparam-namesecp256k1-genkey-outpriv.pem

C\>typeec-priv.pem-----BEGINECPARAMETERS-----BgUrgQQACg==-----ENDECPARAMETERS----------BEGINECPRIVATEKEY-----MHQCAQEEIEa56GG2PTUJyIt4FydaMNItYsjNj6ZIbd7jXvDY4ElfoAcGBSuBBAAKoUQDQgAEJQDn8/vd8oQpA/VE3ch0lM6VAprOTiV9VLp38rwfOog3qUYcTxxX/sxJl1M4HncqEopYIKkkovoFFi62Yph6nw==-----ENDECPRIVATEKEY-----

Example

Page 16: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

EllipticCurve(EC)C\>opensslecparam-namesecp256k1-genkey-outpriv.pem

C\>typeec-priv.pem-----BEGINECPARAMETERS-----BgUrgQQACg==-----ENDECPARAMETERS----------BEGINECPRIVATEKEY-----MHQCAQEEIEa56GG2PTUJyIt4FydaMNItYsjNj6ZIbd7jXvDY4ElfoAcGBSuBBAAKoUQDQgAEJQDn8/vd8oQpA/VE3ch0lM6VAprOTiV9VLp38rwfOog3qUYcTxxX/sxJl1M4HncqEopYIKkkovoFFi62Yph6nw==-----ENDECPRIVATEKEY-----

Example

Page 17: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

EllipticCurve(EC)C\>opensslecparam-namesecp256k1-genkey-outpriv.pem

C\>typeec-priv.pem-----BEGINECPARAMETERS-----BgUrgQQACg==-----ENDECPARAMETERS----------BEGINECPRIVATEKEY-----MHQCAQEEIEa56GG2PTUJyIt4FydaMNItYsjNj6ZIbd7jXvDY4ElfoAcGBSuBBAAKoUQDQgAEJQDn8/vd8oQpA/VE3ch0lM6VAprOTiV9VLp38rwfOog3qUYcTxxX/sxJl1M4HncqEopYIKkkovoFFi62Yph6nw==-----ENDECPRIVATEKEY-----

C\>opensslec-inpriv.pem-text-nooutreadECkeyPrivate-Key(256bit)priv46b9e861b63d3509c88b7817275a30d22d62c8cd8fa6486ddee35ef0d8e0495fpub042500e7f3fbddf2842903f544ddc87494ce95029ace4e257d54ba77f2bc1f3a8837a9461c4f1c57fecc499753381e772a128a5820a924a2fa05162eb662987a9fASN1OIDsecp256k1

Example

Page 18: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

EllipticCurve(EC)C\>opensslecparam-namesecp256k1-genkey-outpriv.pem

C\>typeec-priv.pem-----BEGINECPARAMETERS-----BgUrgQQACg==-----ENDECPARAMETERS----------BEGINECPRIVATEKEY-----MHQCAQEEIEa56GG2PTUJyIt4FydaMNItYsjNj6ZIbd7jXvDY4ElfoAcGBSuBBAAKoUQDQgAEJQDn8/vd8oQpA/VE3ch0lM6VAprOTiV9VLp38rwfOog3qUYcTxxX/sxJl1M4HncqEopYIKkkovoFFi62Yph6nw==-----ENDECPRIVATEKEY-----

Example

Page 19: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

EllipticCurve(EC)C\>opensslecparam-namesecp256k1-genkey-outpriv.pem

C\>typeec-priv.pem-----BEGINECPARAMETERS-----BgUrgQQACg==-----ENDECPARAMETERS----------BEGINECPRIVATEKEY-----MHQCAQEEIEa56GG2PTUJyIt4FydaMNItYsjNj6ZIbd7jXvDY4ElfoAcGBSuBBAAKoUQDQgAEJQDn8/vd8oQpA/VE3ch0lM6VAprOTiV9VLp38rwfOog3qUYcTxxX/sxJl1M4HncqEopYIKkkovoFFi62Yph6nw==-----ENDECPRIVATEKEY-----

C\>opensslec-inpriv.pem-text-nooutreadECkeyPrivate-Key(256bit)priv46b9e861b63d3509c88b7817275a30d22d62c8cd8fa6486ddee35ef0d8e0495fpub042500e7f3fbddf2842903f544ddc87494ce95029ace4e257d54ba77f2bc1f3a8837a9461c4f1c57fecc499753381e772a128a5820a924a2fa05162eb662987a9fASN1OIDsecp256k1

Example

Page 20: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

EllipticCurve(EC)C\>opensslecparam-namesecp256k1-genkey-outpriv.pem

C\>typeec-priv.pem-----BEGINECPARAMETERS-----BgUrgQQACg==-----ENDECPARAMETERS----------BEGINECPRIVATEKEY-----MHQCAQEEIEa56GG2PTUJyIt4FydaMNItYsjNj6ZIbd7jXvDY4ElfoAcGBSuBBAAKoUQDQgAEJQDn8/vd8oQpA/VE3ch0lM6VAprOTiV9VLp38rwfOog3qUYcTxxX/sxJl1M4HncqEopYIKkkovoFFi62Yph6nw==-----ENDECPRIVATEKEY-----

C\>opensslec-inpriv.pem-text-nooutreadECkeyPrivate-Key(256bit)priv46b9e861b63d3509c88b7817275a30d22d62c8cd8fa6486ddee35ef0d8e0495fpub042500e7f3fbddf2842903f544ddc87494ce95029ace4e257d54ba77f2bc1f3a8837a9461c4f1c57fecc499753381e772a128a5820a924a2fa05162eb662987a9fASN1OIDsecp256k1

Example C:>opensslecparam-inpriv.pem-text-param_encexplicit-nooutFieldType:prime-fieldPrime:00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:fe:ff:ff:fc:2fA:0B:7(0x7)Generator(uncompressed):04:79:be:66:7e:f9:dc:bb:ac:55:a0:62:95:ce:87:0b:07:02:9b:fc:db:2d:ce:28:d9:59:f2:81:5b:16:f8:17:98:48:3a:da:77:26:a3:c4:65:5d:a4:fb:fc:0e:11:08:a8:fd:17:b4:48:a6:85:54:19:9c:47:d0:8f:fb:10:d4:b8Order:00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:fe:ba:ae:dc:e6:af:48:a0:3b:bf:d2:5e:8c:d0:36:41:41Cofactor:1(0x1)

Page 21: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

EllipticCurveDiffieHellman(ECDH)

Page 22: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

EllipticCurveDiffieHellman(ECDH)

Page 23: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

EllipticCurveDiffieHellman(ECDH)

Page 24: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

Chapter4:PublicKey ElGamal ProfBillBuchananOBE http://asecuritysite.com/crypto04http://asecuritysite.com/encryption

Page 25: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

ElGamal

• Y=Gxmodp• Gispickedfromcyclicgroup

(ExplainedinKeyHandshakingsection).Here.

• pisaprimenumber.• Examplehere.

Page 26: chapter04 public key - Security and So Many Things · Public Key Methods • Integer Factorization.Using prime numbers. Example: RSA. Digital Certs/SSL. • Discrete Logarithms.Y

Chapter4:PublicKey Basics RSAEllipticCurveElGamal ProfBillBuchananOBE http://asecuritysite.com/crypto04http://asecuritysite.com/encryption