SlideShare a Scribd company logo
TRESEC MEETUP
Introduction to cryptography
for software developers
Raine Nieminen, February 5, 2019
| © INSTA
Raine Nieminen
Security specialist at Intopalo Digital
Cryptography, software security,
information security, security consulting,
Master of Science (Tech.)
Connect with me on LinkedIn at
https://www.linkedin.com/in/raineniemine
nlinkedin/
About the speaker
| © INSTA
Outline
Cryptography
25% Theory (~5min)
75% Practice (~15min)
| © INSTA| © INSTA
Short
introduction to
cryptography
| © INSTA
Modern cryptography
No handwritten symbols, no mechanical machines anymore
Some crypto related terms:
• Cipher
• Secret, private and public key
• Key exchange
• Cryptographic hash function
• Message authentication code (MAC)
• Digital signature
• Homomorphic encryption
• Multi-party computation (MPC)
• Post-quantum cryptography
| 5
| © INSTA
Symmetric ciphers
One secret key that is used for both encryption and decryption
| 6
Secret message
to TreSec
participants cipher
$4=RGV3%$6ryC!
K$q6$"rr?GJ8Fz
vp)T/^6s{TX
Encryption
$4=RGV3%$6ryC!
K$q6$"rr?GJ8Fz
vp)T/^6s{TX cipher
Secret message
to TreSec
participants
Decryption
| © INSTA
Asymmetric ciphers
Two different keys
| 7
Secret message
to TreSec
participants cipher
xD}D2~$5Y$QP8B
83M5?q@w:9M*)#
MPH7^4`.!3x
Encryption
xD}D2~$5Y$QP8B
83M5?q@w:9M*)#
MPH7^4`.!3x cipher
Secret message
to TreSec
participants
Decryption
| © INSTA
Things to remember
Symmetric and asymmetric ciphers are fundamentally different
• To simplify, symmetric ciphers “scramble” the message and key by doing substitutions
and permutations on a bit level ➔ special hardware exists
• Asymmetric ciphers are based on mathematically difficult problems, which require
large numbers ➔ computations are relatively slow
The security relies fully on the secrecy of the key, not the cipher itself!
| 8
| © INSTA
Cryptographic hash functions
Properties that separate cryptographic hash functions from the regular ones:
• Pre-image resistance
• Second pre-image resistance
• Collision resistance
| 9
A long or
short message…
Hash
function
Fixed size!
“Digest”
2"BTd/{?Ef:T`.
"P%KX8@s;q6a}m
7/*{:"8m?][yDh
| © INSTA
Multi-party computation (MPC)
The idea is to compute a function without knowing the inputs
No third parties involved
Might sound absurd and impossible, but luckily cryptographers are smart!
| 10
function
A
A*
B
C
D
B*
C*
D*
The result
| © INSTA| © INSTA
Practical aspects
for software
developers
| © INSTA
The big picture
Our tool set
Crypto stuff
“Nothing magical”
| © INSTA
When to use crypto
Classical use cases:
• Confidentiality
• Integrity
• Availability
• Non-repudiation
• Authentication
• Authorization
Real life examples:
• Money transfer
• Auction/election
• Electronic contract
• Access control
| 13
| © INSTA
Basic principles
Follow these principles and I won’t need to hunt you down
1. Do not use your own crypto algorithms
2. Do not implement any crypto algorithm (by yourself) in production code
3. Do nothing, go home and quit your job
| 14
| © INSTA
How to use crypto: algorithms and libraries
Well known algorithms:
| 15
Symmetric alg. Asymmetric alg. Hash functions
AES RSA SHA-3
Serpent DSA SHA-2
Twofish ECDH
Example libraries:
OpenSSL Crypto++ Bouncy Castel ACE
C C++ Java, C# C
| © INSTA
How to use crypto: algorithms and libraries
If possible, use cryptographic protocols such as TLS
If not, the algorithms must be used correctly (obviously)
Includes, e.g., implementing padding and choosing mode of operation
• Follow suitable and standardized padding methods (e.g., RFC 5652 section 6.3)
• Electronic Codebook (ECB) mode should be avoided
• The use case determines which mode should be used and how to do authentication
• Initialization vectors (IV) must be unique and random
| 16
| © INSTA
Things to remember
Use existing implementations and do as little as you have to yourself
• Choose appropriate library/libraries for the use case (trustiness, license, language, …)
• FIPS 140-2
• ISO/IEC 19790:2012
• Document the usage of the libraries and possible weaknesses/misusages
• Follow if vulnerabilities are discovered and apply updates
Have basic understanding of what is happening and why
| 17
These things are complex and difficult but easy to get wrong… so take your time.
| © INSTA
Key management
Key management is something that software developers might need to take
care of even when the crypto algorithms are already there
This could include:
• Choosing the key size
• Generating the key
• Storing the key
Recall that the security relies fully on the secrecy of the key
➔ Therefore this is super important
| 18
| © INSTA
Key size
Basically, the longer the key is, the better
However, longer keys reduce the efficiency + overkill is rarely advisable anyway
| 19
AES RSA ECC
Near term 128 3072 256
Long term (>30 years) 256 15360 512
Sources: Algorithms, key size and protocols report. ECRYPT – CSA, 2018
Recommendation for key management, Part 1: General (revised). NIST, 2016
| © INSTA
Rule of thumb (key size)
Most likely 128-bit security is what you want
Symmetric ciphers provide one to one security regarding the key size
Hash function digest length must be twice as large as the security we want
With elliptic curves (asymmetric ciphers) the key size must also be twice as large
Other asymmetric ciphers require 3072-bit keys to provide 128-bit security
| 20
| © INSTA
Key generation
The importance is often underrated
Requires user input (password) or/and random numbers
• True random numbers (very difficult to produce)
• Cryptographically secure pseudo-random number generator (CSPRNG)
Some methods might already be implemented (e.g., Java SecureRandom)
• Take advantage of user behavior over time (e.g., mouse movements)
• Take advantage of hardware (e.g., CPU clock)
• For more, see RFC 4086 (Randomness Requirements for Security)
• Library functions can use different methods depending on the running OS
| 21
| © INSTA
Key storage
Which keys should be stored?
What is the purpose?
Examples:
• Password manager decryption key(s) is not stored but derived from the master password
• Some secret or private keys should be protected in special hardware (e.g., TPM or smart cards)
• Secure Shell (SSH) private keys can be stored locally in a text file
Be careful when storing keys in memory, since it could be accessible by other programs
and complete erasure is difficult (removing the pointer does not remove the key)
| 22
| © INSTA
Things to remember
Poor key management overshadows otherwise good usage of crypto
Short keys might be currently acceptable but not in the future
Important in key generation:
• A proper key derivation function (e.g., Argon2, bcrypt, …)
• The source of the randomness
Store keys carefully
Don’t get a false sense of security
| 23
These things are complex and difficult but easy to get wrong… so take your time.
| © INSTA
Discussion
Topics I skipped but interests you?
Overall thoughts, comments and questions?
| 24
Thank you for listening!

More Related Content

What's hot

Understanding Intrusion Detection Systems with Snort
Understanding Intrusion Detection Systems with SnortUnderstanding Intrusion Detection Systems with Snort
Understanding Intrusion Detection Systems with Snort
Shyamsundar Das
 
Crypto academy
Crypto academyCrypto academy
Crypto academy
Paul Gillingwater, MBA
 
Creating Your Own Threat Intel Through Hunting & Visualization
Creating Your Own Threat Intel Through Hunting & VisualizationCreating Your Own Threat Intel Through Hunting & Visualization
Creating Your Own Threat Intel Through Hunting & Visualization
Raffael Marty
 
Security Onion
Security OnionSecurity Onion
ciso-platform-annual-summit-2013-Fgont-ipv6-myths-dynamic
ciso-platform-annual-summit-2013-Fgont-ipv6-myths-dynamicciso-platform-annual-summit-2013-Fgont-ipv6-myths-dynamic
ciso-platform-annual-summit-2013-Fgont-ipv6-myths-dynamic
Priyanka Aash
 
Loggin alerting and hunting technology hub 2016
Loggin alerting and hunting   technology hub 2016Loggin alerting and hunting   technology hub 2016
Loggin alerting and hunting technology hub 2016
Scot Berner
 
RSA 2015 Realities of Private Cloud Security
RSA 2015 Realities of Private Cloud SecurityRSA 2015 Realities of Private Cloud Security
RSA 2015 Realities of Private Cloud Security
Scott Carlson
 
Application layer Security in IoT: A Survey
Application layer Security in IoT: A SurveyApplication layer Security in IoT: A Survey
Application layer Security in IoT: A Survey
Adeel Ahmed
 
Pki 201 Key Management
Pki 201 Key ManagementPki 201 Key Management
Pki 201 Key ManagementNCC Group
 
Enterprise Forensics 101
Enterprise Forensics 101Enterprise Forensics 101
Enterprise Forensics 101
Mona Arkhipova
 
Realities of Data Security
Realities of Data SecurityRealities of Data Security
Realities of Data Security
Priyanka Aash
 
NTXISSACSC3 - Critical Criteria for (Cloud) Workload Security by Steve Armend...
NTXISSACSC3 - Critical Criteria for (Cloud) Workload Security by Steve Armend...NTXISSACSC3 - Critical Criteria for (Cloud) Workload Security by Steve Armend...
NTXISSACSC3 - Critical Criteria for (Cloud) Workload Security by Steve Armend...
North Texas Chapter of the ISSA
 
Chapter 6 Presentation
Chapter 6 PresentationChapter 6 Presentation
Chapter 6 Presentation
Amy McMullin
 
IoT Malware: Comprehensive Survey, Analysis Framework and Case Studies
IoT Malware: Comprehensive Survey, Analysis Framework and Case StudiesIoT Malware: Comprehensive Survey, Analysis Framework and Case Studies
IoT Malware: Comprehensive Survey, Analysis Framework and Case Studies
Priyanka Aash
 
Nagios Conference 2013 - Spenser Reinhardt - Intro to Network Monitoring Usin...
Nagios Conference 2013 - Spenser Reinhardt - Intro to Network Monitoring Usin...Nagios Conference 2013 - Spenser Reinhardt - Intro to Network Monitoring Usin...
Nagios Conference 2013 - Spenser Reinhardt - Intro to Network Monitoring Usin...
Nagios
 
Qradar as a SOC core
Qradar as a SOC coreQradar as a SOC core
Qradar as a SOC core
Mona Arkhipova
 
DEF CON 23 - vivek ramachadran - chellam
DEF CON 23 - vivek ramachadran - chellamDEF CON 23 - vivek ramachadran - chellam
DEF CON 23 - vivek ramachadran - chellam
Felipe Prado
 
Cloud Breach – Preparation and Response
Cloud Breach – Preparation and ResponseCloud Breach – Preparation and Response
Cloud Breach – Preparation and Response
Priyanka Aash
 
DTS Solution - Software Defined Security v1.0
DTS Solution - Software Defined Security v1.0DTS Solution - Software Defined Security v1.0
DTS Solution - Software Defined Security v1.0Shah Sheikh
 
All Hope is Not Lost Network Forensics Exposes Today's Advanced Security Thr...
All Hope is Not LostNetwork Forensics Exposes Today's Advanced Security Thr...All Hope is Not LostNetwork Forensics Exposes Today's Advanced Security Thr...
All Hope is Not Lost Network Forensics Exposes Today's Advanced Security Thr...
Savvius, Inc
 

What's hot (20)

Understanding Intrusion Detection Systems with Snort
Understanding Intrusion Detection Systems with SnortUnderstanding Intrusion Detection Systems with Snort
Understanding Intrusion Detection Systems with Snort
 
Crypto academy
Crypto academyCrypto academy
Crypto academy
 
Creating Your Own Threat Intel Through Hunting & Visualization
Creating Your Own Threat Intel Through Hunting & VisualizationCreating Your Own Threat Intel Through Hunting & Visualization
Creating Your Own Threat Intel Through Hunting & Visualization
 
Security Onion
Security OnionSecurity Onion
Security Onion
 
ciso-platform-annual-summit-2013-Fgont-ipv6-myths-dynamic
ciso-platform-annual-summit-2013-Fgont-ipv6-myths-dynamicciso-platform-annual-summit-2013-Fgont-ipv6-myths-dynamic
ciso-platform-annual-summit-2013-Fgont-ipv6-myths-dynamic
 
Loggin alerting and hunting technology hub 2016
Loggin alerting and hunting   technology hub 2016Loggin alerting and hunting   technology hub 2016
Loggin alerting and hunting technology hub 2016
 
RSA 2015 Realities of Private Cloud Security
RSA 2015 Realities of Private Cloud SecurityRSA 2015 Realities of Private Cloud Security
RSA 2015 Realities of Private Cloud Security
 
Application layer Security in IoT: A Survey
Application layer Security in IoT: A SurveyApplication layer Security in IoT: A Survey
Application layer Security in IoT: A Survey
 
Pki 201 Key Management
Pki 201 Key ManagementPki 201 Key Management
Pki 201 Key Management
 
Enterprise Forensics 101
Enterprise Forensics 101Enterprise Forensics 101
Enterprise Forensics 101
 
Realities of Data Security
Realities of Data SecurityRealities of Data Security
Realities of Data Security
 
NTXISSACSC3 - Critical Criteria for (Cloud) Workload Security by Steve Armend...
NTXISSACSC3 - Critical Criteria for (Cloud) Workload Security by Steve Armend...NTXISSACSC3 - Critical Criteria for (Cloud) Workload Security by Steve Armend...
NTXISSACSC3 - Critical Criteria for (Cloud) Workload Security by Steve Armend...
 
Chapter 6 Presentation
Chapter 6 PresentationChapter 6 Presentation
Chapter 6 Presentation
 
IoT Malware: Comprehensive Survey, Analysis Framework and Case Studies
IoT Malware: Comprehensive Survey, Analysis Framework and Case StudiesIoT Malware: Comprehensive Survey, Analysis Framework and Case Studies
IoT Malware: Comprehensive Survey, Analysis Framework and Case Studies
 
Nagios Conference 2013 - Spenser Reinhardt - Intro to Network Monitoring Usin...
Nagios Conference 2013 - Spenser Reinhardt - Intro to Network Monitoring Usin...Nagios Conference 2013 - Spenser Reinhardt - Intro to Network Monitoring Usin...
Nagios Conference 2013 - Spenser Reinhardt - Intro to Network Monitoring Usin...
 
Qradar as a SOC core
Qradar as a SOC coreQradar as a SOC core
Qradar as a SOC core
 
DEF CON 23 - vivek ramachadran - chellam
DEF CON 23 - vivek ramachadran - chellamDEF CON 23 - vivek ramachadran - chellam
DEF CON 23 - vivek ramachadran - chellam
 
Cloud Breach – Preparation and Response
Cloud Breach – Preparation and ResponseCloud Breach – Preparation and Response
Cloud Breach – Preparation and Response
 
DTS Solution - Software Defined Security v1.0
DTS Solution - Software Defined Security v1.0DTS Solution - Software Defined Security v1.0
DTS Solution - Software Defined Security v1.0
 
All Hope is Not Lost Network Forensics Exposes Today's Advanced Security Thr...
All Hope is Not LostNetwork Forensics Exposes Today's Advanced Security Thr...All Hope is Not LostNetwork Forensics Exposes Today's Advanced Security Thr...
All Hope is Not Lost Network Forensics Exposes Today's Advanced Security Thr...
 

Similar to Introduction to cryptography for software developers

Secure Your Encryption with HSM
Secure Your Encryption with HSMSecure Your Encryption with HSM
Secure Your Encryption with HSM
Narudom Roongsiriwong, CISSP
 
Lesson 1
Lesson 1Lesson 1
Mobile security recipes for xamarin
Mobile security recipes for xamarinMobile security recipes for xamarin
Mobile security recipes for xamarin
Nicolas Milcoff
 
Analysis of symmetric key cryptographic algorithms
Analysis of symmetric key cryptographic algorithmsAnalysis of symmetric key cryptographic algorithms
Analysis of symmetric key cryptographic algorithms
IRJET Journal
 
IRJET- Ensuring Security in Cloud Computing Cryptography using Cryptography
IRJET-  	  Ensuring Security in Cloud Computing Cryptography using CryptographyIRJET-  	  Ensuring Security in Cloud Computing Cryptography using Cryptography
IRJET- Ensuring Security in Cloud Computing Cryptography using Cryptography
IRJET Journal
 
How to do Cryptography right in Android Part One
How to do Cryptography right in Android Part OneHow to do Cryptography right in Android Part One
How to do Cryptography right in Android Part One
Arash Ramez
 
Not my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructureNot my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructure
Yshay Yaacobi
 
Create a Data Encryption Strategy using ADE
Create a Data Encryption Strategy using ADECreate a Data Encryption Strategy using ADE
Create a Data Encryption Strategy using ADE
Rocket Software
 
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...Ramesh Nagappan
 
Static Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and YouStatic Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and You
Kevin Fealey
 
Proactive monitoring tools or services - Open Source
Proactive monitoring tools or services - Open Source Proactive monitoring tools or services - Open Source
Proactive monitoring tools or services - Open Source
B.A.
 
Cryptography
CryptographyCryptography
Zerotrusting serverless applications protecting microservices using secure d...
Zerotrusting serverless applications  protecting microservices using secure d...Zerotrusting serverless applications  protecting microservices using secure d...
Zerotrusting serverless applications protecting microservices using secure d...
Trupti Shiralkar, CISSP
 
Shytikov on NTLM Authentication
Shytikov on NTLM AuthenticationShytikov on NTLM Authentication
Shytikov on NTLM Authenticationshytikov
 
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
Websec México, S.C.
 
DevSecOps: What Why and How : Blackhat 2019
DevSecOps: What Why and How : Blackhat 2019DevSecOps: What Why and How : Blackhat 2019
DevSecOps: What Why and How : Blackhat 2019
NotSoSecure Global Services
 
Cloud Security and some preferred practices
Cloud Security and some preferred practicesCloud Security and some preferred practices
Cloud Security and some preferred practices
Michael Pearce
 
Rise of the machines -- Owasp israel -- June 2014 meetup
Rise of the machines -- Owasp israel -- June 2014 meetupRise of the machines -- Owasp israel -- June 2014 meetup
Rise of the machines -- Owasp israel -- June 2014 meetup
Shlomo Yona
 
LoginCat from TekMonks
LoginCat from TekMonksLoginCat from TekMonks
LoginCat from TekMonks
Rohit Kapoor
 
Logging : How much is too much? Network Security Monitoring Talk @ hasgeek
Logging : How much is too much? Network Security Monitoring Talk @ hasgeekLogging : How much is too much? Network Security Monitoring Talk @ hasgeek
Logging : How much is too much? Network Security Monitoring Talk @ hasgeek
vivekrajan
 

Similar to Introduction to cryptography for software developers (20)

Secure Your Encryption with HSM
Secure Your Encryption with HSMSecure Your Encryption with HSM
Secure Your Encryption with HSM
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
Mobile security recipes for xamarin
Mobile security recipes for xamarinMobile security recipes for xamarin
Mobile security recipes for xamarin
 
Analysis of symmetric key cryptographic algorithms
Analysis of symmetric key cryptographic algorithmsAnalysis of symmetric key cryptographic algorithms
Analysis of symmetric key cryptographic algorithms
 
IRJET- Ensuring Security in Cloud Computing Cryptography using Cryptography
IRJET-  	  Ensuring Security in Cloud Computing Cryptography using CryptographyIRJET-  	  Ensuring Security in Cloud Computing Cryptography using Cryptography
IRJET- Ensuring Security in Cloud Computing Cryptography using Cryptography
 
How to do Cryptography right in Android Part One
How to do Cryptography right in Android Part OneHow to do Cryptography right in Android Part One
How to do Cryptography right in Android Part One
 
Not my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructureNot my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructure
 
Create a Data Encryption Strategy using ADE
Create a Data Encryption Strategy using ADECreate a Data Encryption Strategy using ADE
Create a Data Encryption Strategy using ADE
 
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
Analysis of Security and Compliance using Oracle SPARC T-Series Servers: Emph...
 
Static Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and YouStatic Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and You
 
Proactive monitoring tools or services - Open Source
Proactive monitoring tools or services - Open Source Proactive monitoring tools or services - Open Source
Proactive monitoring tools or services - Open Source
 
Cryptography
CryptographyCryptography
Cryptography
 
Zerotrusting serverless applications protecting microservices using secure d...
Zerotrusting serverless applications  protecting microservices using secure d...Zerotrusting serverless applications  protecting microservices using secure d...
Zerotrusting serverless applications protecting microservices using secure d...
 
Shytikov on NTLM Authentication
Shytikov on NTLM AuthenticationShytikov on NTLM Authentication
Shytikov on NTLM Authentication
 
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
Echidna, sistema de respuesta a incidentes open source [GuadalajaraCON 2013]
 
DevSecOps: What Why and How : Blackhat 2019
DevSecOps: What Why and How : Blackhat 2019DevSecOps: What Why and How : Blackhat 2019
DevSecOps: What Why and How : Blackhat 2019
 
Cloud Security and some preferred practices
Cloud Security and some preferred practicesCloud Security and some preferred practices
Cloud Security and some preferred practices
 
Rise of the machines -- Owasp israel -- June 2014 meetup
Rise of the machines -- Owasp israel -- June 2014 meetupRise of the machines -- Owasp israel -- June 2014 meetup
Rise of the machines -- Owasp israel -- June 2014 meetup
 
LoginCat from TekMonks
LoginCat from TekMonksLoginCat from TekMonks
LoginCat from TekMonks
 
Logging : How much is too much? Network Security Monitoring Talk @ hasgeek
Logging : How much is too much? Network Security Monitoring Talk @ hasgeekLogging : How much is too much? Network Security Monitoring Talk @ hasgeek
Logging : How much is too much? Network Security Monitoring Talk @ hasgeek
 

Recently uploaded

Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 

Recently uploaded (20)

Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 

Introduction to cryptography for software developers

  • 1. TRESEC MEETUP Introduction to cryptography for software developers Raine Nieminen, February 5, 2019
  • 2. | © INSTA Raine Nieminen Security specialist at Intopalo Digital Cryptography, software security, information security, security consulting, Master of Science (Tech.) Connect with me on LinkedIn at https://www.linkedin.com/in/raineniemine nlinkedin/ About the speaker
  • 3. | © INSTA Outline Cryptography 25% Theory (~5min) 75% Practice (~15min)
  • 4. | © INSTA| © INSTA Short introduction to cryptography
  • 5. | © INSTA Modern cryptography No handwritten symbols, no mechanical machines anymore Some crypto related terms: • Cipher • Secret, private and public key • Key exchange • Cryptographic hash function • Message authentication code (MAC) • Digital signature • Homomorphic encryption • Multi-party computation (MPC) • Post-quantum cryptography | 5
  • 6. | © INSTA Symmetric ciphers One secret key that is used for both encryption and decryption | 6 Secret message to TreSec participants cipher $4=RGV3%$6ryC! K$q6$"rr?GJ8Fz vp)T/^6s{TX Encryption $4=RGV3%$6ryC! K$q6$"rr?GJ8Fz vp)T/^6s{TX cipher Secret message to TreSec participants Decryption
  • 7. | © INSTA Asymmetric ciphers Two different keys | 7 Secret message to TreSec participants cipher xD}D2~$5Y$QP8B 83M5?q@w:9M*)# MPH7^4`.!3x Encryption xD}D2~$5Y$QP8B 83M5?q@w:9M*)# MPH7^4`.!3x cipher Secret message to TreSec participants Decryption
  • 8. | © INSTA Things to remember Symmetric and asymmetric ciphers are fundamentally different • To simplify, symmetric ciphers “scramble” the message and key by doing substitutions and permutations on a bit level ➔ special hardware exists • Asymmetric ciphers are based on mathematically difficult problems, which require large numbers ➔ computations are relatively slow The security relies fully on the secrecy of the key, not the cipher itself! | 8
  • 9. | © INSTA Cryptographic hash functions Properties that separate cryptographic hash functions from the regular ones: • Pre-image resistance • Second pre-image resistance • Collision resistance | 9 A long or short message… Hash function Fixed size! “Digest” 2"BTd/{?Ef:T`. "P%KX8@s;q6a}m 7/*{:"8m?][yDh
  • 10. | © INSTA Multi-party computation (MPC) The idea is to compute a function without knowing the inputs No third parties involved Might sound absurd and impossible, but luckily cryptographers are smart! | 10 function A A* B C D B* C* D* The result
  • 11. | © INSTA| © INSTA Practical aspects for software developers
  • 12. | © INSTA The big picture Our tool set Crypto stuff “Nothing magical”
  • 13. | © INSTA When to use crypto Classical use cases: • Confidentiality • Integrity • Availability • Non-repudiation • Authentication • Authorization Real life examples: • Money transfer • Auction/election • Electronic contract • Access control | 13
  • 14. | © INSTA Basic principles Follow these principles and I won’t need to hunt you down 1. Do not use your own crypto algorithms 2. Do not implement any crypto algorithm (by yourself) in production code 3. Do nothing, go home and quit your job | 14
  • 15. | © INSTA How to use crypto: algorithms and libraries Well known algorithms: | 15 Symmetric alg. Asymmetric alg. Hash functions AES RSA SHA-3 Serpent DSA SHA-2 Twofish ECDH Example libraries: OpenSSL Crypto++ Bouncy Castel ACE C C++ Java, C# C
  • 16. | © INSTA How to use crypto: algorithms and libraries If possible, use cryptographic protocols such as TLS If not, the algorithms must be used correctly (obviously) Includes, e.g., implementing padding and choosing mode of operation • Follow suitable and standardized padding methods (e.g., RFC 5652 section 6.3) • Electronic Codebook (ECB) mode should be avoided • The use case determines which mode should be used and how to do authentication • Initialization vectors (IV) must be unique and random | 16
  • 17. | © INSTA Things to remember Use existing implementations and do as little as you have to yourself • Choose appropriate library/libraries for the use case (trustiness, license, language, …) • FIPS 140-2 • ISO/IEC 19790:2012 • Document the usage of the libraries and possible weaknesses/misusages • Follow if vulnerabilities are discovered and apply updates Have basic understanding of what is happening and why | 17 These things are complex and difficult but easy to get wrong… so take your time.
  • 18. | © INSTA Key management Key management is something that software developers might need to take care of even when the crypto algorithms are already there This could include: • Choosing the key size • Generating the key • Storing the key Recall that the security relies fully on the secrecy of the key ➔ Therefore this is super important | 18
  • 19. | © INSTA Key size Basically, the longer the key is, the better However, longer keys reduce the efficiency + overkill is rarely advisable anyway | 19 AES RSA ECC Near term 128 3072 256 Long term (>30 years) 256 15360 512 Sources: Algorithms, key size and protocols report. ECRYPT – CSA, 2018 Recommendation for key management, Part 1: General (revised). NIST, 2016
  • 20. | © INSTA Rule of thumb (key size) Most likely 128-bit security is what you want Symmetric ciphers provide one to one security regarding the key size Hash function digest length must be twice as large as the security we want With elliptic curves (asymmetric ciphers) the key size must also be twice as large Other asymmetric ciphers require 3072-bit keys to provide 128-bit security | 20
  • 21. | © INSTA Key generation The importance is often underrated Requires user input (password) or/and random numbers • True random numbers (very difficult to produce) • Cryptographically secure pseudo-random number generator (CSPRNG) Some methods might already be implemented (e.g., Java SecureRandom) • Take advantage of user behavior over time (e.g., mouse movements) • Take advantage of hardware (e.g., CPU clock) • For more, see RFC 4086 (Randomness Requirements for Security) • Library functions can use different methods depending on the running OS | 21
  • 22. | © INSTA Key storage Which keys should be stored? What is the purpose? Examples: • Password manager decryption key(s) is not stored but derived from the master password • Some secret or private keys should be protected in special hardware (e.g., TPM or smart cards) • Secure Shell (SSH) private keys can be stored locally in a text file Be careful when storing keys in memory, since it could be accessible by other programs and complete erasure is difficult (removing the pointer does not remove the key) | 22
  • 23. | © INSTA Things to remember Poor key management overshadows otherwise good usage of crypto Short keys might be currently acceptable but not in the future Important in key generation: • A proper key derivation function (e.g., Argon2, bcrypt, …) • The source of the randomness Store keys carefully Don’t get a false sense of security | 23 These things are complex and difficult but easy to get wrong… so take your time.
  • 24. | © INSTA Discussion Topics I skipped but interests you? Overall thoughts, comments and questions? | 24 Thank you for listening!