SlideShare a Scribd company logo
1 of 59
Download to read offline
Cryptography 
(under)engineering 
fictional tale about home-brewed cryptography 
h e l l o 
? * > + 
W O R L D
About me 
Audrius Kovalenko | @slicklash 
NOT Computer Security Expert 
NOT Cryptographer 
Just a developer
The most important bits 
In the next 3 slides
Role of Cryptography 
for user 
Computer illiteracy 
Security illiteracy 
Negative feedback 
click Run
Role of Cryptography 
for developer 
Good security = Prevention + Detection + Response
Role of Cryptography 
for attacker 
STUXNET 
BadUSB 
Expensive door lock 
vs 
Unguarded windows
Story mode 
try to 
Stretch your imagination 
Forgive the folly 
Enjoy
Startup company 
New generation lasers 
Breath taking technology 
Need secure communication 
Alice Bob
Adversary 
Mallory
Agile team 
Roy Moss
“soul 2 soul” app 
architecture 
rendezvous host 
P2P
S2S 1.0 
Handshake 
Application 
Alert 
protocol 
HELLO 
HELLO 
MSG 1 
MSG 2 
ERROR
Implementing secrecy 
Todo In Progress Done 
S2S - 101 
Lorem ipsum dolor 
sitamet, 
consectetur 
adipiscing elit. 
Acceptance criteria: 
should be secure
Ultra secure 
blackbox 
Plaintext Ciphertext Plaintext
Where is code? 
in private repository
Where is code? 
in private repository 
Owned by Mallory
So how does it really work?
So how does it really work? 
“oracle” does the magic
The Magic 
“Coca-Cola” cipher 
Bitwise XOR with repeating key 
0xC0CAC01A 
L O L A A l i c e 
01001100 01001111 01001100 00100000 01000001 01101100 01101001 01100011 01100101 
11000000 11001010 11000000 00011010 11000000 11001010 11000000 00011010 11000000 
10001100 10000101 10001100 00111010 10000001 10100110 10101001 01111001 10100101
Refactoring secrecy 
Todo In Progress Done 
Acceptance criteria: 
S2S - 101 
Lorem ipsum dolor 
sitamet, 
consectetur 
adipiscing elit. 
should use a secure cipher
What is a secure cipher? 
Kerckhoffs’ Principle (1883) 
The security of the encryption scheme 
must depend only on secrecy of the key, 
and not on the secrecy of the algorithm. 
A. Kercoffs
What is a secure cipher? 
confusion and diffusion (1949) 
C. Shannon
What is a secure cipher? 
size matters 
Key size Block size Birthday paradox 
Time to crack1 
56 bits ≈ 2s 
64 bits ≈ 9 minutes 
80 bits ≈ 413 days 
128 bits ≈ 318 ✕ 1012 years 
256 bits ≈ 7.9 ✕ 1042 universe ages 
1 Naive calculations using 
Tianhe-2 (33.86 petaflops) 
Lookup table size2 
32 bits 16 GiB 
56 bits 458 752 TiB 
64 bits 131 072 PiB 
80 bits 10 240 ZiB 
128 bits ≈ 4.5 ✕ 1015 YiB 
2 Size in bytes = 2block size✕ (block size / 8) 
Collisions after3 
32 bits 65 536 messages 
56 bits 268 435 456 
64 bits 4 294 967 296 
80 bits 1 099 511 627 776 
128 bits 18446744073709551616 
3 In the set of 2n elements, 
after seeing 2n / 2 elements there is 50% chance 
two elements will be the same
Cipher choice 
what should we use? 
2000 AES (Rijndael) 
2003 Rabbit 
2004 HC-128 
2005 Salsa20 
2008 ChaCha20
Cipher choice 
the standard! 
1 Rijndael animation 
2000 AES (Rijndael)1 
2003 Rabbit 
2004 HC-128 
2005 Salsa20 
2008 ChaCha20 Still not broken
Message size > Block size 
modes of operation 
ECB CBC CTR
Refactoring secrecy 
Todo In Progress Done 
S2S - 101 
Lorem ipsum dolor 
sitamet, 
consectetur 
adipiscing elit. 
Acceptance criteria: 
should use AES cipher in CTR mode
S2S 1.1 
S2S_WITH_AES_CTR_128 
MSG 1 
MSG 2 
Alice and Bob: agree on 128 bit secret key 
Startup: enter the key 
Nonce: message number
S2S 1.1 
S2S_WITH_AES_CTR_128 
Alice and Bob: agree on 128 bit secret key 
Startup: enter the key 
Nonce: message number 
Owned by Mallory 
MSG 1 
MSG 2
It’s the implementation, dummy! 
day 2 
MSG 1 
MSG 2 
day 1 
MSG 1 
MSG 2
Key reuse 
MSG 1 MSG 1 
Hi Bob K1 
Howdy! K1
Key reuse 
Hi Bob K1 
Howdy! K1
Key reuse 
Hi Bob K1 
Howdy! K1
Key reuse 
Hi Bob Howdy!
Key reuse 
Hi Bob Howdy! 
“Crib” drag attack Bob = dy!
Refactoring secrecy, again 
Todo In Progress Done 
S2S - 101 
Lorem ipsum dolor 
sitamet, 
consectetur 
adipiscing elit. 
Acceptance criteria: 
should use AES in CBC mode
S2S 1.2 
S2S_WITH_AES_CBC_128 
MSG 1 
MSG 2 
Alice and Bob: agree on 128 bit secret key 
Startup: enter the key 
IV: every message has random IV
Infrastructure 
rendezvous host 
ISP ISP
Infrastructure 
rendezvous host 
ISP 
Owned by Mallory 
ISP
Mallory-in-the-middle 
message tampering 
HELLO 
HELLO 
MSG 1 
HELLO 
HELLO 
MSG 1
Homework 
CBC padding oracle attacks 
ERROR 
2002 Serge Vaudenay 
2010 ASP.NET, JSF 
2011 BEAST 
2013 Lucky 13 
2014 POODLE
Preventing malleability 
what should we use? 
Still not broken 
2002 SHA-256 
2004 Whirlpool 
2008 SHA-3 (Keccak) 
2012 BLAKE2
Preventing malleability 
what should we use? 
Still not broken 
2002 SHA-256 
2004 Whirlpool 
2008 SHA-3 (Keccak) 
2012 BLAKE2 
Nope!
Length extension attacks 
1 Generated with HashPump 
Merkle-Damgard construction 
Data: id=123&action=view 
Hashing: MD5(‘secret’ || data) 
Signature: e691a507adce5689a47675a85d91da96 
Desired: id=123&action=view&payload=1 
New data1: id=123&action=viewx80x00x00x00x00x00x00x00x00 
x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00 
x00x00x00x00x00x00xc0x00x00 x00x00x00x00x00&payload=1 
New signature: 2a1dc3230c636cc73d08085dda9bed36
“Safe” MACs 
HMAC1 
SHA-3 
BLAKE2 
1 Hash-based MAC is defined as H(key ∥ H(key ∥ message)), where H is secure hash function.
What to authenticate? 
Source 
Destination 
Timestamp 
Sequence No. 
etc. 
Horton’s Principle 
Authenticate what is being meant, 
not what is being said.
Fixing protocol 
Todo In Progress Done 
S2S - 101 
Lorem ipsum dolor 
sitamet, 
consectetur 
adipiscing elit. 
Acceptance criteria: 
HMAC-SHA-256 should be used as MAC
S2S 1.3 
S2S_WITH_AES_CBC_128_SHA_2561 
Alice and Bob: agree on 128 bit secret key 
Startup: enter the key 
IV: every message has random IV 
MAC: every message is authenticated 
1 Compact notation of HMAC-SHA-256 
MSG 1 
MSG 2
S2S 1.3 
S2S_WITH_AES_CBC_128_SHA_2561 
Owned by Mallory 
MSG 1 
MSG 2 
Alice and Bob: agree on 128 bit secret key 
Startup: enter the key 
IV: every message has random IV 
MAC: every message is authenticated 
1 Compact notation of HMAC-SHA-256
Social engineering 
Mallory learns 
Big fans of
Social engineering 
Mallory learns 
Key: winter is coming
Entropy (randomness) 
bits of security 
Key space 
16 bytes 
128 bits 
≈ 318 ✕ 1012 years* 
Key: winter is coming 
* Naive calculations using Tianhe-2 (33.86 petaflops) 
Reduced space 
set of characters = lowercase + space = 26 + 1 = 27 
entropy per character = log2(27) ≈ 4.75 
entropy of key = 4.75 ✕ 16 = 76 
≈ 25 days* 
Game of Thrones quotes 
set of quotes = 638 
entropy per quote = log2(638) ≈ 9.3 
entropy of key = 9.1 ✕ 1 = 9.3 
instant!
THE END 
Years behind reinventing TLS 
Switches to TextSecure 
Nowhere to be seen
Cryptographic Misuse in 
Android Applications 
11,748 applications reviewed (2013) 
https://www.cs.ucsb.edu/~chris/research/doc/ccs13_cryptolint.pdf
Lessons learned 
Cryptography is a hard subject 
Broken because of implementation errors 
Either stay away from crypto or seek help 
When building a railway always do detection and response first 
Understand your users 
Do not put a burden on your users which they cannot carry
Not covered today 
Asymmetric (Public Key) Cryptography 
Digital Signatures 
Key Exchange 
“Perfect” Forward Secrecy & Ephemeral Keys 
Elliptic Curve Cryptography
Books 
“Zeal without knowledge - fire without light” 
http://www.crypto-textbook.com
Resources 
Matasano Crypto Challenges 
http://cryptopals.com 
Crypto Projects that Might not Suck 
https://github.com/sweis/crypto-might-not-suck 
A Few Thoughts on Cryptographic Engineering 
http://blog.cryptographyengineering.com 
Cryptographic competitions 
http://competitions.cr.yp.to
QA

More Related Content

What's hot

Secure password - CYBER SECURITY
Secure password - CYBER SECURITYSecure password - CYBER SECURITY
Secure password - CYBER SECURITYSupanShah2
 
Hacking cryptography: 0xdec0de01 cryptoCTF solutions and a bit more - Владими...
Hacking cryptography: 0xdec0de01 cryptoCTF solutions and a bit more - Владими...Hacking cryptography: 0xdec0de01 cryptoCTF solutions and a bit more - Владими...
Hacking cryptography: 0xdec0de01 cryptoCTF solutions and a bit more - Владими...HackIT Ukraine
 
0xdec0de01 crypto CTF solutions
0xdec0de01 crypto CTF solutions0xdec0de01 crypto CTF solutions
0xdec0de01 crypto CTF solutionsVlad Garbuz
 
Everything I always wanted to know about crypto, but never thought I'd unders...
Everything I always wanted to know about crypto, but never thought I'd unders...Everything I always wanted to know about crypto, but never thought I'd unders...
Everything I always wanted to know about crypto, but never thought I'd unders...Codemotion
 
WiFi practical hacking "Show me the passwords!"
WiFi practical hacking "Show me the passwords!"WiFi practical hacking "Show me the passwords!"
WiFi practical hacking "Show me the passwords!"DefCamp
 
Dodging WebCrypto API Landmines
Dodging WebCrypto API LandminesDodging WebCrypto API Landmines
Dodging WebCrypto API LandminesErnie Turner
 
DPAPI AND DPAPI-NG: Decryption toolkit. Black Hat 2017
DPAPI AND DPAPI-NG: Decryption toolkit. Black Hat 2017DPAPI AND DPAPI-NG: Decryption toolkit. Black Hat 2017
DPAPI AND DPAPI-NG: Decryption toolkit. Black Hat 2017Paula Januszkiewicz
 
SSL/TLS for Mortals (Devoxx FR 2018)
SSL/TLS for Mortals (Devoxx FR 2018)SSL/TLS for Mortals (Devoxx FR 2018)
SSL/TLS for Mortals (Devoxx FR 2018)Maarten Mulders
 
Black Hat Europe 2017. DPAPI and DPAPI-NG: Decryption Toolkit
Black Hat Europe 2017. DPAPI and DPAPI-NG: Decryption ToolkitBlack Hat Europe 2017. DPAPI and DPAPI-NG: Decryption Toolkit
Black Hat Europe 2017. DPAPI and DPAPI-NG: Decryption ToolkitPaula Januszkiewicz
 
Humantalk Angers 14 Mars
Humantalk Angers 14 MarsHumantalk Angers 14 Mars
Humantalk Angers 14 MarsRémi Dubois
 
"Powershell kung-fu" - Paweł Maziarz
"Powershell kung-fu" - Paweł Maziarz"Powershell kung-fu" - Paweł Maziarz
"Powershell kung-fu" - Paweł MaziarzPROIDEA
 
Intro to Cryptography on the Web
Intro to Cryptography on the WebIntro to Cryptography on the Web
Intro to Cryptography on the WebMichael Wynholds
 
Hiding in plain sight
Hiding in plain sightHiding in plain sight
Hiding in plain sightRob Gillen
 
Secure Storage: COMPOSABLE AND ROBUST OUTSOURCED STORAGE
Secure Storage: COMPOSABLE AND ROBUST OUTSOURCED STORAGESecure Storage: COMPOSABLE AND ROBUST OUTSOURCED STORAGE
Secure Storage: COMPOSABLE AND ROBUST OUTSOURCED STORAGEPriyanka Aash
 
Password Cracking with Rainbow Tables
Password Cracking with Rainbow TablesPassword Cracking with Rainbow Tables
Password Cracking with Rainbow TablesKorhan Bircan
 
SSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso RemotoSSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso RemotoTiago Cruz
 
What the &~#@<!? (Pointers in Rust)
What the &~#@<!? (Pointers in Rust)What the &~#@<!? (Pointers in Rust)
What the &~#@<!? (Pointers in Rust)David Evans
 
Digital Signatures: Reassessing security of randomizable signatures
Digital Signatures: Reassessing security of randomizable signaturesDigital Signatures: Reassessing security of randomizable signatures
Digital Signatures: Reassessing security of randomizable signaturesPriyanka Aash
 

What's hot (20)

Secure password - CYBER SECURITY
Secure password - CYBER SECURITYSecure password - CYBER SECURITY
Secure password - CYBER SECURITY
 
Hacking cryptography: 0xdec0de01 cryptoCTF solutions and a bit more - Владими...
Hacking cryptography: 0xdec0de01 cryptoCTF solutions and a bit more - Владими...Hacking cryptography: 0xdec0de01 cryptoCTF solutions and a bit more - Владими...
Hacking cryptography: 0xdec0de01 cryptoCTF solutions and a bit more - Владими...
 
0xdec0de01 crypto CTF solutions
0xdec0de01 crypto CTF solutions0xdec0de01 crypto CTF solutions
0xdec0de01 crypto CTF solutions
 
Everything I always wanted to know about crypto, but never thought I'd unders...
Everything I always wanted to know about crypto, but never thought I'd unders...Everything I always wanted to know about crypto, but never thought I'd unders...
Everything I always wanted to know about crypto, but never thought I'd unders...
 
WiFi practical hacking "Show me the passwords!"
WiFi practical hacking "Show me the passwords!"WiFi practical hacking "Show me the passwords!"
WiFi practical hacking "Show me the passwords!"
 
Dodging WebCrypto API Landmines
Dodging WebCrypto API LandminesDodging WebCrypto API Landmines
Dodging WebCrypto API Landmines
 
DPAPI AND DPAPI-NG: Decryption toolkit. Black Hat 2017
DPAPI AND DPAPI-NG: Decryption toolkit. Black Hat 2017DPAPI AND DPAPI-NG: Decryption toolkit. Black Hat 2017
DPAPI AND DPAPI-NG: Decryption toolkit. Black Hat 2017
 
SSL/TLS for Mortals (Devoxx FR 2018)
SSL/TLS for Mortals (Devoxx FR 2018)SSL/TLS for Mortals (Devoxx FR 2018)
SSL/TLS for Mortals (Devoxx FR 2018)
 
Python Cryptography & Security
Python Cryptography & SecurityPython Cryptography & Security
Python Cryptography & Security
 
Hack ASP.NET website
Hack ASP.NET websiteHack ASP.NET website
Hack ASP.NET website
 
Black Hat Europe 2017. DPAPI and DPAPI-NG: Decryption Toolkit
Black Hat Europe 2017. DPAPI and DPAPI-NG: Decryption ToolkitBlack Hat Europe 2017. DPAPI and DPAPI-NG: Decryption Toolkit
Black Hat Europe 2017. DPAPI and DPAPI-NG: Decryption Toolkit
 
Humantalk Angers 14 Mars
Humantalk Angers 14 MarsHumantalk Angers 14 Mars
Humantalk Angers 14 Mars
 
"Powershell kung-fu" - Paweł Maziarz
"Powershell kung-fu" - Paweł Maziarz"Powershell kung-fu" - Paweł Maziarz
"Powershell kung-fu" - Paweł Maziarz
 
Intro to Cryptography on the Web
Intro to Cryptography on the WebIntro to Cryptography on the Web
Intro to Cryptography on the Web
 
Hiding in plain sight
Hiding in plain sightHiding in plain sight
Hiding in plain sight
 
Secure Storage: COMPOSABLE AND ROBUST OUTSOURCED STORAGE
Secure Storage: COMPOSABLE AND ROBUST OUTSOURCED STORAGESecure Storage: COMPOSABLE AND ROBUST OUTSOURCED STORAGE
Secure Storage: COMPOSABLE AND ROBUST OUTSOURCED STORAGE
 
Password Cracking with Rainbow Tables
Password Cracking with Rainbow TablesPassword Cracking with Rainbow Tables
Password Cracking with Rainbow Tables
 
SSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso RemotoSSH: Seguranca no Acesso Remoto
SSH: Seguranca no Acesso Remoto
 
What the &~#@<!? (Pointers in Rust)
What the &~#@<!? (Pointers in Rust)What the &~#@<!? (Pointers in Rust)
What the &~#@<!? (Pointers in Rust)
 
Digital Signatures: Reassessing security of randomizable signatures
Digital Signatures: Reassessing security of randomizable signaturesDigital Signatures: Reassessing security of randomizable signatures
Digital Signatures: Reassessing security of randomizable signatures
 

Similar to Cryptography (under)engineering

Block Cipher.cryptography_miu_year5.pptx
Block Cipher.cryptography_miu_year5.pptxBlock Cipher.cryptography_miu_year5.pptx
Block Cipher.cryptography_miu_year5.pptxHodaAhmedBekhitAhmed
 
Renas Rajab Asaad
Renas Rajab Asaad Renas Rajab Asaad
Renas Rajab Asaad Renas Rekany
 
Novel Instruction Set Architecture Based Side Channels in popular SSL/TLS Imp...
Novel Instruction Set Architecture Based Side Channels in popular SSL/TLS Imp...Novel Instruction Set Architecture Based Side Channels in popular SSL/TLS Imp...
Novel Instruction Set Architecture Based Side Channels in popular SSL/TLS Imp...Cybersecurity Education and Research Centre
 
Crypto talk OpenValue meetup 20-3-18
Crypto talk OpenValue meetup 20-3-18Crypto talk OpenValue meetup 20-3-18
Crypto talk OpenValue meetup 20-3-18Roy Wasse
 
CCNA Security 012- cryptographic systems
CCNA Security 012- cryptographic systemsCCNA Security 012- cryptographic systems
CCNA Security 012- cryptographic systemsAhmed Habib
 
[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...
[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...
[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...Aaron Zauner
 
Overview on Cryptography and Network Security
Overview on Cryptography and Network SecurityOverview on Cryptography and Network Security
Overview on Cryptography and Network SecurityDr. Rupa Ch
 
Introduction to Public Key Cryptography
Introduction to Public Key CryptographyIntroduction to Public Key Cryptography
Introduction to Public Key CryptographyKelley Robinson
 
DevDay: Cryptographic Agility, Kostas Chalkias
DevDay: Cryptographic Agility, Kostas ChalkiasDevDay: Cryptographic Agility, Kostas Chalkias
DevDay: Cryptographic Agility, Kostas ChalkiasR3
 
Jaimin chp-8 - network security-new -use this - 2011 batch
Jaimin   chp-8 - network security-new -use this -  2011 batchJaimin   chp-8 - network security-new -use this -  2011 batch
Jaimin chp-8 - network security-new -use this - 2011 batchJaimin Jani
 
Cryptography for Absolute Beginners (May 2019)
Cryptography for Absolute Beginners (May 2019)Cryptography for Absolute Beginners (May 2019)
Cryptography for Absolute Beginners (May 2019)Svetlin Nakov
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_cryptoHarry Potter
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_cryptoJames Wong
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_cryptoYoung Alista
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_cryptoDavid Hoen
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_cryptoTony Nguyen
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_cryptoLuis Goldster
 

Similar to Cryptography (under)engineering (20)

Block Cipher.cryptography_miu_year5.pptx
Block Cipher.cryptography_miu_year5.pptxBlock Cipher.cryptography_miu_year5.pptx
Block Cipher.cryptography_miu_year5.pptx
 
Renas Rajab Asaad
Renas Rajab Asaad Renas Rajab Asaad
Renas Rajab Asaad
 
Novel Instruction Set Architecture Based Side Channels in popular SSL/TLS Imp...
Novel Instruction Set Architecture Based Side Channels in popular SSL/TLS Imp...Novel Instruction Set Architecture Based Side Channels in popular SSL/TLS Imp...
Novel Instruction Set Architecture Based Side Channels in popular SSL/TLS Imp...
 
Crypto talk OpenValue meetup 20-3-18
Crypto talk OpenValue meetup 20-3-18Crypto talk OpenValue meetup 20-3-18
Crypto talk OpenValue meetup 20-3-18
 
AllBits presentation - Security in Theory
AllBits presentation - Security in TheoryAllBits presentation - Security in Theory
AllBits presentation - Security in Theory
 
CCNA Security 012- cryptographic systems
CCNA Security 012- cryptographic systemsCCNA Security 012- cryptographic systems
CCNA Security 012- cryptographic systems
 
Go paranoid
Go paranoidGo paranoid
Go paranoid
 
[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...
[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...
[BlackHat USA 2016] Nonce-Disrespecting Adversaries: Practical Forgery Attack...
 
Overview on Cryptography and Network Security
Overview on Cryptography and Network SecurityOverview on Cryptography and Network Security
Overview on Cryptography and Network Security
 
Introduction to Public Key Cryptography
Introduction to Public Key CryptographyIntroduction to Public Key Cryptography
Introduction to Public Key Cryptography
 
DevDay: Cryptographic Agility, Kostas Chalkias
DevDay: Cryptographic Agility, Kostas ChalkiasDevDay: Cryptographic Agility, Kostas Chalkias
DevDay: Cryptographic Agility, Kostas Chalkias
 
Cryptography
CryptographyCryptography
Cryptography
 
Jaimin chp-8 - network security-new -use this - 2011 batch
Jaimin   chp-8 - network security-new -use this -  2011 batchJaimin   chp-8 - network security-new -use this -  2011 batch
Jaimin chp-8 - network security-new -use this - 2011 batch
 
Cryptography for Absolute Beginners (May 2019)
Cryptography for Absolute Beginners (May 2019)Cryptography for Absolute Beginners (May 2019)
Cryptography for Absolute Beginners (May 2019)
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_crypto
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_crypto
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_crypto
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_crypto
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_crypto
 
Introduction to security_and_crypto
Introduction to security_and_cryptoIntroduction to security_and_crypto
Introduction to security_and_crypto
 

More from slicklash

Code Complexity and Entropy
Code Complexity and EntropyCode Complexity and Entropy
Code Complexity and Entropyslicklash
 
Working Effectively with Legacy Code
Working Effectively with Legacy CodeWorking Effectively with Legacy Code
Working Effectively with Legacy Codeslicklash
 
This World of Ours
This World of OursThis World of Ours
This World of Oursslicklash
 
VGTU Intro to Threats 2015
VGTU Intro to Threats 2015VGTU Intro to Threats 2015
VGTU Intro to Threats 2015slicklash
 
Introduction to Threat Modeling
Introduction to Threat ModelingIntroduction to Threat Modeling
Introduction to Threat Modelingslicklash
 
Security of Web Applications: Top 6 Risks To Avoid
Security of Web Applications: Top 6 Risks To AvoidSecurity of Web Applications: Top 6 Risks To Avoid
Security of Web Applications: Top 6 Risks To Avoidslicklash
 

More from slicklash (6)

Code Complexity and Entropy
Code Complexity and EntropyCode Complexity and Entropy
Code Complexity and Entropy
 
Working Effectively with Legacy Code
Working Effectively with Legacy CodeWorking Effectively with Legacy Code
Working Effectively with Legacy Code
 
This World of Ours
This World of OursThis World of Ours
This World of Ours
 
VGTU Intro to Threats 2015
VGTU Intro to Threats 2015VGTU Intro to Threats 2015
VGTU Intro to Threats 2015
 
Introduction to Threat Modeling
Introduction to Threat ModelingIntroduction to Threat Modeling
Introduction to Threat Modeling
 
Security of Web Applications: Top 6 Risks To Avoid
Security of Web Applications: Top 6 Risks To AvoidSecurity of Web Applications: Top 6 Risks To Avoid
Security of Web Applications: Top 6 Risks To Avoid
 

Recently uploaded

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Cryptography (under)engineering

  • 1. Cryptography (under)engineering fictional tale about home-brewed cryptography h e l l o ? * > + W O R L D
  • 2. About me Audrius Kovalenko | @slicklash NOT Computer Security Expert NOT Cryptographer Just a developer
  • 3. The most important bits In the next 3 slides
  • 4. Role of Cryptography for user Computer illiteracy Security illiteracy Negative feedback click Run
  • 5. Role of Cryptography for developer Good security = Prevention + Detection + Response
  • 6. Role of Cryptography for attacker STUXNET BadUSB Expensive door lock vs Unguarded windows
  • 7. Story mode try to Stretch your imagination Forgive the folly Enjoy
  • 8. Startup company New generation lasers Breath taking technology Need secure communication Alice Bob
  • 11. “soul 2 soul” app architecture rendezvous host P2P
  • 12. S2S 1.0 Handshake Application Alert protocol HELLO HELLO MSG 1 MSG 2 ERROR
  • 13. Implementing secrecy Todo In Progress Done S2S - 101 Lorem ipsum dolor sitamet, consectetur adipiscing elit. Acceptance criteria: should be secure
  • 14. Ultra secure blackbox Plaintext Ciphertext Plaintext
  • 15. Where is code? in private repository
  • 16. Where is code? in private repository Owned by Mallory
  • 17. So how does it really work?
  • 18. So how does it really work? “oracle” does the magic
  • 19. The Magic “Coca-Cola” cipher Bitwise XOR with repeating key 0xC0CAC01A L O L A A l i c e 01001100 01001111 01001100 00100000 01000001 01101100 01101001 01100011 01100101 11000000 11001010 11000000 00011010 11000000 11001010 11000000 00011010 11000000 10001100 10000101 10001100 00111010 10000001 10100110 10101001 01111001 10100101
  • 20. Refactoring secrecy Todo In Progress Done Acceptance criteria: S2S - 101 Lorem ipsum dolor sitamet, consectetur adipiscing elit. should use a secure cipher
  • 21. What is a secure cipher? Kerckhoffs’ Principle (1883) The security of the encryption scheme must depend only on secrecy of the key, and not on the secrecy of the algorithm. A. Kercoffs
  • 22. What is a secure cipher? confusion and diffusion (1949) C. Shannon
  • 23. What is a secure cipher? size matters Key size Block size Birthday paradox Time to crack1 56 bits ≈ 2s 64 bits ≈ 9 minutes 80 bits ≈ 413 days 128 bits ≈ 318 ✕ 1012 years 256 bits ≈ 7.9 ✕ 1042 universe ages 1 Naive calculations using Tianhe-2 (33.86 petaflops) Lookup table size2 32 bits 16 GiB 56 bits 458 752 TiB 64 bits 131 072 PiB 80 bits 10 240 ZiB 128 bits ≈ 4.5 ✕ 1015 YiB 2 Size in bytes = 2block size✕ (block size / 8) Collisions after3 32 bits 65 536 messages 56 bits 268 435 456 64 bits 4 294 967 296 80 bits 1 099 511 627 776 128 bits 18446744073709551616 3 In the set of 2n elements, after seeing 2n / 2 elements there is 50% chance two elements will be the same
  • 24. Cipher choice what should we use? 2000 AES (Rijndael) 2003 Rabbit 2004 HC-128 2005 Salsa20 2008 ChaCha20
  • 25. Cipher choice the standard! 1 Rijndael animation 2000 AES (Rijndael)1 2003 Rabbit 2004 HC-128 2005 Salsa20 2008 ChaCha20 Still not broken
  • 26. Message size > Block size modes of operation ECB CBC CTR
  • 27. Refactoring secrecy Todo In Progress Done S2S - 101 Lorem ipsum dolor sitamet, consectetur adipiscing elit. Acceptance criteria: should use AES cipher in CTR mode
  • 28. S2S 1.1 S2S_WITH_AES_CTR_128 MSG 1 MSG 2 Alice and Bob: agree on 128 bit secret key Startup: enter the key Nonce: message number
  • 29. S2S 1.1 S2S_WITH_AES_CTR_128 Alice and Bob: agree on 128 bit secret key Startup: enter the key Nonce: message number Owned by Mallory MSG 1 MSG 2
  • 30. It’s the implementation, dummy! day 2 MSG 1 MSG 2 day 1 MSG 1 MSG 2
  • 31. Key reuse MSG 1 MSG 1 Hi Bob K1 Howdy! K1
  • 32. Key reuse Hi Bob K1 Howdy! K1
  • 33. Key reuse Hi Bob K1 Howdy! K1
  • 34. Key reuse Hi Bob Howdy!
  • 35. Key reuse Hi Bob Howdy! “Crib” drag attack Bob = dy!
  • 36. Refactoring secrecy, again Todo In Progress Done S2S - 101 Lorem ipsum dolor sitamet, consectetur adipiscing elit. Acceptance criteria: should use AES in CBC mode
  • 37. S2S 1.2 S2S_WITH_AES_CBC_128 MSG 1 MSG 2 Alice and Bob: agree on 128 bit secret key Startup: enter the key IV: every message has random IV
  • 39. Infrastructure rendezvous host ISP Owned by Mallory ISP
  • 40. Mallory-in-the-middle message tampering HELLO HELLO MSG 1 HELLO HELLO MSG 1
  • 41. Homework CBC padding oracle attacks ERROR 2002 Serge Vaudenay 2010 ASP.NET, JSF 2011 BEAST 2013 Lucky 13 2014 POODLE
  • 42. Preventing malleability what should we use? Still not broken 2002 SHA-256 2004 Whirlpool 2008 SHA-3 (Keccak) 2012 BLAKE2
  • 43. Preventing malleability what should we use? Still not broken 2002 SHA-256 2004 Whirlpool 2008 SHA-3 (Keccak) 2012 BLAKE2 Nope!
  • 44. Length extension attacks 1 Generated with HashPump Merkle-Damgard construction Data: id=123&action=view Hashing: MD5(‘secret’ || data) Signature: e691a507adce5689a47675a85d91da96 Desired: id=123&action=view&payload=1 New data1: id=123&action=viewx80x00x00x00x00x00x00x00x00 x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00 x00x00x00x00x00x00xc0x00x00 x00x00x00x00x00&payload=1 New signature: 2a1dc3230c636cc73d08085dda9bed36
  • 45. “Safe” MACs HMAC1 SHA-3 BLAKE2 1 Hash-based MAC is defined as H(key ∥ H(key ∥ message)), where H is secure hash function.
  • 46. What to authenticate? Source Destination Timestamp Sequence No. etc. Horton’s Principle Authenticate what is being meant, not what is being said.
  • 47. Fixing protocol Todo In Progress Done S2S - 101 Lorem ipsum dolor sitamet, consectetur adipiscing elit. Acceptance criteria: HMAC-SHA-256 should be used as MAC
  • 48. S2S 1.3 S2S_WITH_AES_CBC_128_SHA_2561 Alice and Bob: agree on 128 bit secret key Startup: enter the key IV: every message has random IV MAC: every message is authenticated 1 Compact notation of HMAC-SHA-256 MSG 1 MSG 2
  • 49. S2S 1.3 S2S_WITH_AES_CBC_128_SHA_2561 Owned by Mallory MSG 1 MSG 2 Alice and Bob: agree on 128 bit secret key Startup: enter the key IV: every message has random IV MAC: every message is authenticated 1 Compact notation of HMAC-SHA-256
  • 50. Social engineering Mallory learns Big fans of
  • 51. Social engineering Mallory learns Key: winter is coming
  • 52. Entropy (randomness) bits of security Key space 16 bytes 128 bits ≈ 318 ✕ 1012 years* Key: winter is coming * Naive calculations using Tianhe-2 (33.86 petaflops) Reduced space set of characters = lowercase + space = 26 + 1 = 27 entropy per character = log2(27) ≈ 4.75 entropy of key = 4.75 ✕ 16 = 76 ≈ 25 days* Game of Thrones quotes set of quotes = 638 entropy per quote = log2(638) ≈ 9.3 entropy of key = 9.1 ✕ 1 = 9.3 instant!
  • 53. THE END Years behind reinventing TLS Switches to TextSecure Nowhere to be seen
  • 54. Cryptographic Misuse in Android Applications 11,748 applications reviewed (2013) https://www.cs.ucsb.edu/~chris/research/doc/ccs13_cryptolint.pdf
  • 55. Lessons learned Cryptography is a hard subject Broken because of implementation errors Either stay away from crypto or seek help When building a railway always do detection and response first Understand your users Do not put a burden on your users which they cannot carry
  • 56. Not covered today Asymmetric (Public Key) Cryptography Digital Signatures Key Exchange “Perfect” Forward Secrecy & Ephemeral Keys Elliptic Curve Cryptography
  • 57. Books “Zeal without knowledge - fire without light” http://www.crypto-textbook.com
  • 58. Resources Matasano Crypto Challenges http://cryptopals.com Crypto Projects that Might not Suck https://github.com/sweis/crypto-might-not-suck A Few Thoughts on Cryptographic Engineering http://blog.cryptographyengineering.com Cryptographic competitions http://competitions.cr.yp.to
  • 59. QA