Public Key Cryptography - A Brief Overview

PUBLIC KEY
CRYPTOGRAPHY
A brief overview
By Andy Brodie
PUBLIC/PRIVATE KEYS
• A normal lock, for example on a door, has one key.
• If you have a key, you can lock and unlock the door.
• This is a useful way of securing content (whatever is behind the door).
• Asymmetric keys mean that the lock has two keys.
• One key can only lock the door (a public key)
• One key can only unlock the door (a private key)
• Encryption and decryption is a metaphor for locking and unlocking the door to get
at whatever is behind the door.
• This is really, really powerful.
BENEFITS OF ASYMMETRIC KEYS
• If you give away the public key (that encrypts) then anyone can protect
content.
• No-one else can decrypt and read the content unless they have the private
key.
• But, there’s more… it works the other way around too!
BUT HOW DO THEY WORK?
• Private keys must be unguessable.
• It must be impossible to derive the private key from the public key.
• Keys are calculated from very, very large prime numbers.
• Key “strength” is measure in bits, i.e. the number of bits the key consists of.
• E.g. an 8-bit key has a range of 256 potential values (28).
• This is not very secure as it would be trivial to manufacture all 256 keys and try them
against the lock (a brute force attack)
• A 2048 bit key has a range of 3.23x10616.
• 3.23 with 616 zeros after the end.
• Even the Milliard Gargantubrain could only manage ~1x1057 in a millisecond!
MATHS
• Select 2 large primes: 𝑝 and 𝑞.
• Calculate product of the keys 𝑛 = 𝑝𝑞
• Calculate the totient of 𝑛.
• For any integer, 𝑥, the totient of 𝑥, written 𝜑(𝑥) is the number of integers smaller than 𝑥 that are
relatively prime to 𝑥.
• For any prime number 𝜑 𝑥 = 𝑥 − 1, therefore for the product of two primes, 𝜑(𝑛) = (𝑝 − 1)(𝑞 − 1).
• Choose any integer, 𝑒, smaller than and relatively prime to 𝜑(𝑛). 𝑒 is called the public key
exponent.
• Calculate an integer 𝑑 such that 𝑑𝑒 = 1 𝑚𝑜𝑑 𝜑 𝑛 .
• I.e.
𝑑𝑒
𝜑 𝑛
results in any number with remainder 1.
• This is done reliably using a multiplicative inverse function… which is TMI for now.
• Once calculated, 𝑑 is called the private key exponent.
• The public key pair is the modulus and the public key exponent: 𝑛, 𝑒
• The private key is the modulus and the private key exponent: (𝑛, 𝑑)
REAL MATHS!
• Let’s pick 2 random small primes: 𝑝 = 3, 𝑞 = 11
• Modulus of keys 𝑛 = 𝑝𝑞 = 33
• Totient 𝜑 𝑛 = 3 − 1 11 − 1 = 2 ∗ 10 = 20
• Choose 𝑒, any prime less than 20. Choices are 7, 11, 13, 17, 19. Pick 𝑒 = 7.
• Therefore public key pair = (33, 7)
• For private key exponent, calculate multiplicative inverse, i.e. 𝑑𝑒 ≡ 𝑚𝑜𝑑 𝜑(𝑛).
• 𝑑 ∗ 7 = 1 𝑚𝑜𝑑 20
• I.e. some number, multiplied by 7 and divided by 20 leaves a remainder of 1.
• In our heads, we know that 21 𝑚𝑜𝑑 20 = 1, so 𝑑 =
21
7
= 3
• Private key pair = (33, 3)
ENCRYPTING AND DECRYPTING
• Encrypting and decrypting is (comparatively) very, very simple.
• Our key pairs: Public 𝑛, 𝑒 = 33, 7 ; Private 𝑛, 𝑑 = 33, 3
• So, let’s encrypt the number 14
• To encrypt: 𝑝 𝑒
= 𝑝′
𝑚𝑜𝑑 𝑛
• 𝑝 is the byte to encrypt
• 𝑝’ is the encrypted byte
• 𝑛 is the modulus
• 𝑒 is the public key exponent
• Real values:
• 147
= 105413504
• 𝑝’ = 10541348 𝑚𝑜𝑑 33 = 𝟐𝟎
• To decrypt: 𝑝′ 𝑑
= 𝑝′
𝑚𝑜𝑑 𝑛
• 𝑝 is the byte to encrypt
• 𝑝’ is the encrypted byte
• 𝑛 is the modulus
• 𝑒 is the public key exponent
• Real values:
• 𝟐𝟎3
= 8000
• 𝑝 = 8000 𝑚𝑜𝑑 33 = 𝟏𝟒
END
This work is licensed under the Creative Commons Attribution 4.0
International License.
1 of 8

Recommended

Alice & bob public key cryptography 101 by
Alice & bob  public key cryptography 101Alice & bob  public key cryptography 101
Alice & bob public key cryptography 101Joshua Thijssen
16.6K views155 slides
3 public key cryptography by
3 public key cryptography3 public key cryptography
3 public key cryptographyRutvik Mehta
8.3K views58 slides
PUBLIC KEY ENCRYPTION by
PUBLIC KEY ENCRYPTIONPUBLIC KEY ENCRYPTION
PUBLIC KEY ENCRYPTIONraf_slide
28.9K views19 slides
Public Key Cryptosystem by
Public Key CryptosystemPublic Key Cryptosystem
Public Key CryptosystemDevakumar Kp
16.5K views19 slides
Public key cryptography by
Public key cryptographyPublic key cryptography
Public key cryptographyIsrael Herraiz
2.2K views44 slides
Public Key Authentication With SSH by
Public Key Authentication With SSHPublic Key Authentication With SSH
Public Key Authentication With SSHDon Norwood
2.6K views15 slides

More Related Content

Viewers also liked

Cryptography by
CryptographyCryptography
Cryptographysharmili priyadarsini
1K views21 slides
IDRBT Project: Application Development in Java for public key cryptography by
IDRBT Project: Application Development in Java for public key cryptographyIDRBT Project: Application Development in Java for public key cryptography
IDRBT Project: Application Development in Java for public key cryptographyShivashish Kumar
1.7K views42 slides
Kerberos using public key cryptography by
Kerberos using public key cryptographyKerberos using public key cryptography
Kerberos using public key cryptographyishmecse13
1.5K views13 slides
Cryptography by
CryptographyCryptography
Cryptographyamiable_indian
4.7K views31 slides
Cryptography - key sharing - RSA by
Cryptography - key sharing - RSACryptography - key sharing - RSA
Cryptography - key sharing - RSAJohn Paul Prassanna
1.5K views20 slides
Public Key Cryptography by
Public Key CryptographyPublic Key Cryptography
Public Key CryptographyIsrael Herraiz
1.4K views43 slides

Viewers also liked(18)

IDRBT Project: Application Development in Java for public key cryptography by Shivashish Kumar
IDRBT Project: Application Development in Java for public key cryptographyIDRBT Project: Application Development in Java for public key cryptography
IDRBT Project: Application Development in Java for public key cryptography
Shivashish Kumar1.7K views
Kerberos using public key cryptography by ishmecse13
Kerberos using public key cryptographyKerberos using public key cryptography
Kerberos using public key cryptography
ishmecse131.5K views
Public key Cryptography & RSA by Amit Debnath
Public key Cryptography & RSAPublic key Cryptography & RSA
Public key Cryptography & RSA
Amit Debnath1.7K views
RSA - ALGORITHM by Muthugomathy and Meenakshi Shetti of GIT COLLEGE by Qualcomm
RSA - ALGORITHM by Muthugomathy and Meenakshi Shetti of GIT COLLEGE RSA - ALGORITHM by Muthugomathy and Meenakshi Shetti of GIT COLLEGE
RSA - ALGORITHM by Muthugomathy and Meenakshi Shetti of GIT COLLEGE
Qualcomm4.1K views
Public Key Cryptography by anusachu .
Public Key CryptographyPublic Key Cryptography
Public Key Cryptography
anusachu .2.8K views
Public Key Cryptography and RSA algorithm by Indra97065
Public Key Cryptography and RSA algorithmPublic Key Cryptography and RSA algorithm
Public Key Cryptography and RSA algorithm
Indra9706516.2K views
Public Key Cryptography by Gopal Sakarkar
Public Key CryptographyPublic Key Cryptography
Public Key Cryptography
Gopal Sakarkar33.2K views
Cryptography and Message Authentication NS3 by koolkampus
Cryptography and Message Authentication NS3Cryptography and Message Authentication NS3
Cryptography and Message Authentication NS3
koolkampus6K views

Recently uploaded

Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Moses Kemibaro
29 views38 slides
Ransomware is Knocking your Door_Final.pdf by
Ransomware is Knocking your Door_Final.pdfRansomware is Knocking your Door_Final.pdf
Ransomware is Knocking your Door_Final.pdfSecurity Bootcamp
76 views46 slides
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueShapeBlue
46 views15 slides
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...ShapeBlue
48 views17 slides
Kyo - Functional Scala 2023.pdf by
Kyo - Functional Scala 2023.pdfKyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdfFlavio W. Brasil
434 views92 slides
DRBD Deep Dive - Philipp Reisner - LINBIT by
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBITShapeBlue
62 views21 slides

Recently uploaded(20)

Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by Moses Kemibaro
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro29 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue46 views
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue48 views
DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue62 views
HTTP headers that make your website go faster - devs.gent November 2023 by Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn28 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson133 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue56 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue50 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays40 views
State of the Union - Rohit Yadav - Apache CloudStack by ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue145 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray1080 views
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... by ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue57 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue63 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue91 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue82 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi141 views
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue111 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10369 views

Public Key Cryptography - A Brief Overview

  • 1. PUBLIC KEY CRYPTOGRAPHY A brief overview By Andy Brodie
  • 2. PUBLIC/PRIVATE KEYS • A normal lock, for example on a door, has one key. • If you have a key, you can lock and unlock the door. • This is a useful way of securing content (whatever is behind the door). • Asymmetric keys mean that the lock has two keys. • One key can only lock the door (a public key) • One key can only unlock the door (a private key) • Encryption and decryption is a metaphor for locking and unlocking the door to get at whatever is behind the door. • This is really, really powerful.
  • 3. BENEFITS OF ASYMMETRIC KEYS • If you give away the public key (that encrypts) then anyone can protect content. • No-one else can decrypt and read the content unless they have the private key. • But, there’s more… it works the other way around too!
  • 4. BUT HOW DO THEY WORK? • Private keys must be unguessable. • It must be impossible to derive the private key from the public key. • Keys are calculated from very, very large prime numbers. • Key “strength” is measure in bits, i.e. the number of bits the key consists of. • E.g. an 8-bit key has a range of 256 potential values (28). • This is not very secure as it would be trivial to manufacture all 256 keys and try them against the lock (a brute force attack) • A 2048 bit key has a range of 3.23x10616. • 3.23 with 616 zeros after the end. • Even the Milliard Gargantubrain could only manage ~1x1057 in a millisecond!
  • 5. MATHS • Select 2 large primes: 𝑝 and 𝑞. • Calculate product of the keys 𝑛 = 𝑝𝑞 • Calculate the totient of 𝑛. • For any integer, 𝑥, the totient of 𝑥, written 𝜑(𝑥) is the number of integers smaller than 𝑥 that are relatively prime to 𝑥. • For any prime number 𝜑 𝑥 = 𝑥 − 1, therefore for the product of two primes, 𝜑(𝑛) = (𝑝 − 1)(𝑞 − 1). • Choose any integer, 𝑒, smaller than and relatively prime to 𝜑(𝑛). 𝑒 is called the public key exponent. • Calculate an integer 𝑑 such that 𝑑𝑒 = 1 𝑚𝑜𝑑 𝜑 𝑛 . • I.e. 𝑑𝑒 𝜑 𝑛 results in any number with remainder 1. • This is done reliably using a multiplicative inverse function… which is TMI for now. • Once calculated, 𝑑 is called the private key exponent. • The public key pair is the modulus and the public key exponent: 𝑛, 𝑒 • The private key is the modulus and the private key exponent: (𝑛, 𝑑)
  • 6. REAL MATHS! • Let’s pick 2 random small primes: 𝑝 = 3, 𝑞 = 11 • Modulus of keys 𝑛 = 𝑝𝑞 = 33 • Totient 𝜑 𝑛 = 3 − 1 11 − 1 = 2 ∗ 10 = 20 • Choose 𝑒, any prime less than 20. Choices are 7, 11, 13, 17, 19. Pick 𝑒 = 7. • Therefore public key pair = (33, 7) • For private key exponent, calculate multiplicative inverse, i.e. 𝑑𝑒 ≡ 𝑚𝑜𝑑 𝜑(𝑛). • 𝑑 ∗ 7 = 1 𝑚𝑜𝑑 20 • I.e. some number, multiplied by 7 and divided by 20 leaves a remainder of 1. • In our heads, we know that 21 𝑚𝑜𝑑 20 = 1, so 𝑑 = 21 7 = 3 • Private key pair = (33, 3)
  • 7. ENCRYPTING AND DECRYPTING • Encrypting and decrypting is (comparatively) very, very simple. • Our key pairs: Public 𝑛, 𝑒 = 33, 7 ; Private 𝑛, 𝑑 = 33, 3 • So, let’s encrypt the number 14 • To encrypt: 𝑝 𝑒 = 𝑝′ 𝑚𝑜𝑑 𝑛 • 𝑝 is the byte to encrypt • 𝑝’ is the encrypted byte • 𝑛 is the modulus • 𝑒 is the public key exponent • Real values: • 147 = 105413504 • 𝑝’ = 10541348 𝑚𝑜𝑑 33 = 𝟐𝟎 • To decrypt: 𝑝′ 𝑑 = 𝑝′ 𝑚𝑜𝑑 𝑛 • 𝑝 is the byte to encrypt • 𝑝’ is the encrypted byte • 𝑛 is the modulus • 𝑒 is the public key exponent • Real values: • 𝟐𝟎3 = 8000 • 𝑝 = 8000 𝑚𝑜𝑑 33 = 𝟏𝟒
  • 8. END This work is licensed under the Creative Commons Attribution 4.0 International License.