Do not store the result !
The key only live in
memory
Derived when need
Key Derivation
Slide 26
Slide 26 text
Password KDF(pwd)
Slide 27
Slide 27 text
Specialised stored encrypted
by the Master Key
1 Master Key
N Specialised Keys
On key per usage
Key Rules
Slide 28
Slide 28 text
Password KDF(pwd)
Setup
Slide 29
Slide 29 text
Encrypt
Sub Key 1
Master Key
Data
Encryption
Encrypted Keys
database
Slide 30
Slide 30 text
Password KDF(pwd)
Next connections
Slide 31
Slide 31 text
Decrypt
Master Key
6B693D6A1
398424A …
Sub Key 1
Slide 32
Slide 32 text
Data
Encryption
Slide 33
Slide 33 text
data encryption
Slide 34
Slide 34 text
No content
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
What’s just happen ??
Slide 37
Slide 37 text
Know what you’re doing
APIs are usually
terrible and don’t help
Stack Overflow is not
a way to learn crypto
Data
Encryption
Slide 38
Slide 38 text
The harder part :
use it correctly
Choose a mode
(if relevant)
Choose an algorithm
Encryption :
How to ?
Slide 39
Slide 39 text
What about certifications ?
Good cryptanalysis,
well implemented
Symmetric encryption
algorithm
Which
algorithm ?
Slide 40
Slide 40 text
Won’t save you
RGS (ANSSI) in France
FIPS for US
& international
Certifications
See keylength.com
Slide 41
Slide 41 text
Have a doubt ?
A E S
dvance crypton tandard
Slide 42
Slide 42 text
Cryptography
History
2001
NIST select
Rijndael as AES
Crypto. Dark
Ages
Brave new
world*
*For at least a week or two
Slide 43
Slide 43 text
Most studied algorithm,
no realistic attack
Universally supported
« Nobody ever get fired
for choosing AES »
AES
Slide 44
Slide 44 text
Choose your AES mode
(You thought it was that simple ?)
Slide 45
Slide 45 text
No content
Slide 46
Slide 46 text
blabla blabla blabla blabla not ECB blabla
blabla blabla blabla blabla blabla blabla blabla
not OCB blabla blabla block cipher blabla
blabla blabla blabla blabla blabla blabla blabla
blabla blabla blabla CBC blabla blabla blabla
blabla blabla blabla blabla padding blabla blabla
blabla CTR blabla blabla blabla blabla blabla
blabla blabla blabla stream cipher blabla blabla
counter blabla blabla blabla blabla blabla blabla
Please
stop
It’s
already
18h no ?
I want
to die…
I will never
do crypto…
Slide 47
Slide 47 text
Just tell me what to choose…
Slide 48
Slide 48 text
What do we need ?
Confidentiality
Slide 49
Slide 49 text
What do we need ?
Confidentiality
Not just
Slide 50
Slide 50 text
How to detect
tampering ?
Some modes are
very malleable
Attacks are rarely
read-only
Cipher text
tampering
Slide 51
Slide 51 text
What do we need ?
Confidentiality
Slide 52
Slide 52 text
What do we need ?
Confidentiality, Authentication, Integrity
Slide 53
Slide 53 text
What do we need ?
Authenticated Encryption
Slide 54
Slide 54 text
Automatically checks
before decrypting
Computes an auth tag
along the cipher text
New recommended
encryption scheme
AE
Slide 55
Slide 55 text
Plain text Cipher Cipher text
MAC
MAC
function
AE : encrypt
Slide 56
Slide 56 text
Cipher text Cipher Plain text
MAC
MAC
MAC
function
= ?
AE : decrypt
Slide 57
Slide 57 text
Block cipher in
counter mode
Recommended
by the NIST
Dedicated AES mode
AES GCM
Slide 58
Slide 58 text
What if I don’t have GCM ?
Do It Yourself style*
*Not recommended
Slide 59
Slide 59 text
One key for each
algorithm
A MAC function : HMAC
(at least SHA-256)
A good AES mode :
CBC or CTR
What you
need
Slide 60
Slide 60 text
One rule
Encrypt-Then-Mac
Slide 61
Slide 61 text
HMAC_update (IV, key1)
1
AES_encrypt (data, key2, IV) = cipher text
2
HMAC_update (cipher text, key1)
3
concat ( IV + cipher text + MAC)
5
HMAC_final () = MAC
4
Slide 62
Slide 62 text
Prevent messages
reordering
Encrypt-then-MAC
each piece
Chunk it in small pieces
What about
large data ?
Slide 63
Slide 63 text
A word about IVs
Depends of your AES mode …
Slide 64
Slide 64 text
No content
Slide 65
Slide 65 text
Not a secret, can be stored
along the cipher text
CTR/GCM : never reuse a
key + nonce combinaison
CBC : unique per msg and
unpredictable aka. random
IV / Nonce
Slide 66
Slide 66 text
Done ?
Slide 67
Slide 67 text
Nope
Slide 68
Slide 68 text
Forget all
of this
Slide 69
Slide 69 text
In fact, if you type the
letters « A-E-S »
you’ve already lost
Slide 70
Slide 70 text
Treat crypto primitives
like plutonium not
AAA batteries
Slide 71
Slide 71 text
Attackers have a lot of
imagination
One error can invalidate
your whole system
Using crypto primitives
is incredibly tricky
Why ?
Avoid OpenSSL
Choose mature OSS lib,
carefully audited
Only use high-level
crypto library
The right
tools
Slide 75
Slide 75 text
Don’t write a line before
extensive learning
Errors messages
are information
Be careful not
leaking information
The right
use
Slide 76
Slide 76 text
Bindings exist in
multiple languages
Carefully designed to be
safe and easy to use
Currently the most lib
recommended by experts
NaCl/
LibSodium
Slide 77
Slide 77 text
New kid in the block,
so no certification
Stream cipher, good
perf. even in software
NaCl’s underlying
primitives
Chacha20/
Salsa20
Slide 78
Slide 78 text
Perish in flames
Huuu…
Keyczar in Java,
Python, C++
Alternatives
Slide 79
Slide 79 text
It will hurt
By crypto experts
Every line of crypto
should be audited
Audit
Slide 80
Slide 80 text
Be prepared for
JS WebCryptocalypse
Watch out for
CAESAR competition
All I’ve said will probably
be wrong in some months
Stay
tuned
Slide 81
Slide 81 text
Bibliography
Cryptography Engineering by N. Ferguson & B. Schneier
Some cryptographers to follow
- Adam Langley (imperialviolet.org)
- Matthew Green (blog.cryptographyengineering.com)
- Thomas Ptacek (@tqbf & tptacek on Hacker News)
- JP Aumasson (@veorq)
http://www.cryptofails.com
https://cryptocoding.net/