SlideShare a Scribd company logo
1 of 40
Download to read offline
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 1/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
THESODIUMCRYPTOLIBRARYTHESODIUMCRYPTOLIBRARY
OFPHP7.2OFPHP7.2
by
Senior Software Engineer
, Verona (Italy), May 12
Enrico Zimuel
Rogue Wave Software, Inc.
phpDay 2018
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 2/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
ABOUTMEABOUTME
Developer since 1996
Senior Software Engineer at
Inc.
Core team of ,
and
and international speaker
Research Programmer at
Co-founder of (Italy)
Rogue Wave Software
Apigility
Expressive Zend Framework
TEDx
Amsterdam University
PUG Torino
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 3/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
OVERVIEWOVERVIEW
NaCl/Sodium libraries
Elliptic Curve Cryptography
Sodium in PHP 7.2:
1. Encrypt with a shared-key
2. Authenticate with a shared-key
3. Sending secret messages
4. Digital signature
5. AEAD AES-GCM
6. Store passwords safely
7. Derive a key from a user's password
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 4/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
CRYPTOGRAPHYCRYPTOGRAPHY
Cryptography is hard. Hard to design, hard to implement,
hard to use, and hard to get right.
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 5/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
NACLNACL
NaCl: Networking and Cryptography library
High-speed software library for network
communication, encryption, decryption, signatures, etc
by Prof. , and
Highly-secure primitives and constructions,
implemented with extreme care to avoid
Daniel J. Bernstein others
side-channel
attacks
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 6/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
SIDE-CHANNELATTACKSIDE-CHANNELATTACK
Attack based on information gained from the
implementation of a computer system, rather than
weaknesses in the implemented algorithm itself
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 7/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
DECODERSAKEYUSINGPOWERANALYSISDECODERSAKEYUSINGPOWERANALYSIS
Source: Protecting Against Side-Channel Attacks with an Ultra-Low Power Processor
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 8/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
TIMINGATTACKTIMINGATTACK
An attacker measures the CPU time to perform some
procedures involving a secret (e.g. encryption key). If this
time depends on the secret, the attacker may be able to
deduce information about the secret.
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 9/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
EXAMPLEINPHPEXAMPLEINPHP
function compare(string $expected, string $actual): bool
{
$lenExpected = strlen($expected);
$lenActual = strlen($actual);
if ($lenExpected !== $lenActual) {
return false;
}
for($i=0; $i < $lenActual; $i++) {
if ($expected[$i] !== $actual[$i]) {
return false;
}
}
return true;
}
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 10/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
PREVENTTIMINGATTACK*PREVENTTIMINGATTACK*
* constant-time comparison
function compare(string $expected, string $actual): bool
{
$lenExpected = strlen($expected);
$lenActual = strlen($actual);
$len = min($lenExpected, $lenActual);
$result = 0;
for ($i = 0; $i < $len; $i++) {
$result |= ord($expected[$i]) ^ ord($actual[$i]);
}
$result |= $lenExpected ^ $lenActual;
return ($result === 0);
}
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 11/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
BESTTIMINGATTACKBESTTIMINGATTACK
In 2006 Adi Shamir, Eran Tromer, and Dag Arne Osvik
used a timing attack to discover, in 65 milliseconds, the
secret key used in widely deployed software for hard-
disk encryption.
Source: Cache Attacks and Countermeasures: the Case of AES
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 12/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
SODIUMCRYPTOLIBRARYSODIUMCRYPTOLIBRARY
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 13/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
SODIUMSODIUM
Sodium (libsodium) is a fork of NaCl
A portable, cross-compilable, installable, packageable,
API-compatible version of NaCl
Same implementations of crypto primitives as NaCl
Shared library and a standard set of headers (portable
implementation)
O cial web site: libsodium.org
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 14/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
FEATURESFEATURES
Authenticated public-key and authenticated shared-
key encryption
Public-key and shared-key signatures
Hashing
Keyed hashes for short messages
Secure pseudo-random numbers generation
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 15/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
ALGORITHMSINSODIUMALGORITHMSINSODIUM
Di e–Hellman key-exchange function
, stream ciphers
message-authentication code
public-key signature system
, password hashing
authenticated encryption algorithm
Curve25519
Salsa20 ChaCha20
Poly1305
Ed25519
Argon2 Scrypt
AES-GCM
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 16/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
ELLIPTICCURVESELLIPTICCURVES
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 17/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
ELLIPTICCURVESELLIPTICCURVES
= + ax + by
2
x
3
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 18/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
ADD2POINTSADD2POINTS
A + B = C, A + C = D, A + D = E
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 19/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
SCALARMULTIPLICATIONSCALARMULTIPLICATION
Given and nd such that is hard
P + P = 2P
P Q k Q = kP
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 20/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 21/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
SODIUMINPHPSODIUMINPHP
Available (as standard library) from PHP 7.2
PECL extension ( ) for PHP 7.0/7.1
85 functions with pre x sodium_
e.g. sodium_crypto_box_keypair()
libsodium
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 22/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
EXAMPLE1:EXAMPLE1:
ENCRYPTWITHASHARED-KEYENCRYPTWITHASHARED-KEY
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 23/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
SYMMETRICENCRYPTIONSYMMETRICENCRYPTION
Note: the encryption is always authenticated, you need to store also nonce + ciphertext
Algorithms: to encrypt and for MAC
$msg = 'This is a super secret message!';
// Generating an encryption key and a nonce
$key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES); // 256 bit
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES); // 24 bytes
// Encrypt
$ciphertext = sodium_crypto_secretbox($msg, $nonce, $key);
// Decrypt
$plaintext = sodium_crypto_secretbox_open($ciphertext, $nonce, $key);
echo $plaintext === $msg ? 'Success' : 'Error';
XSalsa20 Poly1305
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 24/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
EXAMPLE2:EXAMPLE2:
AUTHENTICATEWITHASHARED-KEYAUTHENTICATEWITHASHARED-KEY
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 25/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
SYMMETRICAUTHENTICATIONSYMMETRICAUTHENTICATION
Note: the message is not encrypted
Algorithm:
$msg = 'This is the message to authenticate!';
$key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES); // 256 bit
// Generate the Message Authentication Code
$mac = sodium_crypto_auth($msg, $key);
// Altering $mac or $msg, verification will fail
echo sodium_crypto_auth_verify($mac, $msg, $key) ? 'Success' : 'Error';
HMAC-SHA512
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 26/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
EXAMPLE3:EXAMPLE3:
SENDINGSECRETMESSAGESSENDINGSECRETMESSAGES
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 27/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
PUBLIC-KEYENCRYPTIONPUBLIC-KEYENCRYPTION
Note: it provides con dentiality, integrity and non-repudiation
Algorithms: to encrypt, for MAC, and for key exchange
$aliceKeypair = sodium_crypto_box_keypair();
$alicePublicKey = sodium_crypto_box_publickey($aliceKeypair);
$aliceSecretKey = sodium_crypto_box_secretkey($aliceKeypair);
$bobKeypair = sodium_crypto_box_keypair();
$bobPublicKey = sodium_crypto_box_publickey($bobKeypair); // 32 bytes
$bobSecretKey = sodium_crypto_box_secretkey($bobKeypair); // 32 bytes
$msg = 'Hi Bob, this is Alice!';
$nonce = random_bytes(SODIUM_CRYPTO_BOX_NONCEBYTES); // 24 bytes
$keyEncrypt = $aliceSecretKey . $bobPublicKey;
$ciphertext = sodium_crypto_box($msg, $nonce, $keyEncrypt);
$keyDecrypt = $bobSecretKey . $alicePublicKey;
$plaintext = sodium_crypto_box_open($ciphertext, $nonce, $keyDecrypt);
echo $plaintext === $msg ? 'Success' : 'Error';
XSalsa20 Poly1305 XS25519
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 28/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
EXAMPLE4:EXAMPLE4:
DIGITALSIGNATUREDIGITALSIGNATURE
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 29/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
DIGITALSIGNATUREDIGITALSIGNATURE
Note: the message is not encrypted, signedMsg includes signature + msg
Algorithm:
$keypair = sodium_crypto_sign_keypair();
$publicKey = sodium_crypto_sign_publickey($keypair); // 32 bytes
$secretKey = sodium_crypto_sign_secretkey($keypair); // 64 bytes
$msg = 'This message is from Alice';
// Sign a message
$signedMsg = sodium_crypto_sign($msg, $secretKey);
// Or generate only the signature (detached mode)
$signature = sodium_crypto_sign_detached($msg, $secretKey); // 64 bytes
// Verify the signed message
$original = sodium_crypto_sign_open($signedMsg, $publicKey);
echo $original === $msg ? 'Signed msg ok' : 'Error signed msg';
// Verify the signature
echo sodium_crypto_sign_verify_detached($signature, $msg, $publicKey) ?
'Signature ok' : 'Error signature';
Ed25519
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 30/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
EXAMPLE5:EXAMPLE5:
AES-GCMAES-GCM
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 31/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
AEADAES-256-GCMAEADAES-256-GCM
Note: you need to store also ad and nonce + ciphertext
if (! sodium_crypto_aead_aes256gcm_is_available()) {
throw new Exception("AES-GCM is not supported on this platform");
}
$msg = 'Super secret message!';
$key = random_bytes(SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES);
$nonce = random_bytes(SODIUM_CRYPTO_AEAD_AES256GCM_NPUBBYTES);
// AEAD encryption
$ad = 'Additional public data';
$ciphertext = sodium_crypto_aead_aes256gcm_encrypt(
$msg,
$ad,
$nonce,
$key
);
// AEAD decryption
$decrypted = sodium_crypto_aead_aes256gcm_decrypt(
$ciphertext,
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 32/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
EXAMPLE6:EXAMPLE6:
STOREPASSWORDSSAFELYSTOREPASSWORDSSAFELY
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 33/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
ARGON2IARGON2I
An example of Argon2i hash:
$password = 'password';
$hash = sodium_crypto_pwhash_str(
$password,
SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE,
SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE
); // 97 bytes
echo sodium_crypto_pwhash_str_verify($hash, $password) ?
'OK' : 'Error';
$argon2id$v=19$m=65536,t=2,p=1$EF1BpShRmCYHN7ryxlhtBg$zLZO4IWjx3E...
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 34/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
ARGON2INPHP7.2ARGON2INPHP7.2
Comparing with Sodium:
Note: password_hash() is not compatible with sodium_crypto_pwhash_str()
$password = 'password';
// Argon2i without Sodium
$hash = password_hash($password, PASSWORD_ARGON2I); // 95 bytes
echo password_verify($password, $hash) ? 'OK' : 'Error';
$argon2id$v=19$m=65536,t=2,p=1$EF1BpShRmCYH... // 97 bytes, Sodium
$argon2i$v=19$m=1024,t=2,p=2$Y3pweEtMdS82SG... // 95 bytes, PHP
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 35/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
EXAMPLE7:EXAMPLE7:
DERIVEAKEYFROMAUSER'SPASSWORDDERIVEAKEYFROMAUSER'SPASSWORD
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 36/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
PASSWORDAREBADPASSWORDAREBAD
Not random
Predictable (most of the time)
Only a subset of ASCII codes (typically vs )
Never use it as encryption/authentication key!
Use KDF to derive a key from a password
68 256
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 37/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
DERIVEAKEYUSINGARGON2IDERIVEAKEYUSINGARGON2I
Example: generating a binary key of 32 bytes
Note: you need to store also the salt to generate the same key from password
$password = 'password';
$salt = random_bytes(SODIUM_CRYPTO_PWHASH_SALTBYTES);
$key = sodium_crypto_pwhash(
32,
$password,
$salt,
SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE,
SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE
);
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 38/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
UTILITYINSODIUMUTILITYINSODIUM
Wiping Sensitive Data from Memory:
Hex2bin / Bin2Hex:
Constant-time string comparison:
sodium_memzero(&$secret)
sodium_hex2bin(string $hex, string $ignore = '
sodium_bin2hex(string $bin)
sodium_compare(string $str1, string $str2)
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 39/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
REFERENCESREFERENCES
D.J. Bernstein, T.Lange, and P.Schwabe, ,
Lecture Notes in Computer Science 7533, Springer, 2012. ISBN 978-3-642-33480-1
Daniel J. Bernstein,
OpenDNS Security Research, , March 6, 2013
D.A. Osvik, A.Shamir, E.Tromer, , Lecture
Notes in Computer Science, vol 3860. Springer, 2006
Anthony Ferrara, , 2014
Eric Sesterhenn, , 2017
Angela Raucher, ,
Synopsys
Willy Raedy, , Full Stack Academy of Code
Scott Arciszewski, , Paragonie, 2017
The security impact of a new cryptographic library
Cryptography in NaCl
Introducing Sodium, a new cryptographic library
Cache Attacks and Countermeasures: the Case of AES
It's All About Time
Benchmarking memcmp() for timing attacks
Protecting Against Side-Channel Attacks with an Ultra-Low Power Processor
Elliptic Curve Cryptography Tutorial
Libsodium Quick Reference
5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018
https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 40/40
© 2018 Rogue Wave Software, Inc. All Rights Reserved.
THANKS!THANKS!
Rate this talk at
This work is licensed under a
.
I used to make this presentation.
joind.in/talk/5769a
Creative Commons Attribution-ShareAlike 3.0 Unported License
reveal.js

More Related Content

Similar to The Sodium crypto library of PHP 7.2 (PHP Day 2018)

20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge
20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge
20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatengeKarin Patenge
 
UC18NA-D3D202-Dianomic-IZoratti-Introduction-To-FogLAMP.pdf
UC18NA-D3D202-Dianomic-IZoratti-Introduction-To-FogLAMP.pdfUC18NA-D3D202-Dianomic-IZoratti-Introduction-To-FogLAMP.pdf
UC18NA-D3D202-Dianomic-IZoratti-Introduction-To-FogLAMP.pdfWlamir Molinari
 
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
Speed up web APIs with Expressive and Swoole (PHP Day 2018) Speed up web APIs with Expressive and Swoole (PHP Day 2018)
Speed up web APIs with Expressive and Swoole (PHP Day 2018) Zend by Rogue Wave Software
 
Meeting rooms are talking! are you listening?
Meeting rooms are talking! are you listening?Meeting rooms are talking! are you listening?
Meeting rooms are talking! are you listening?Cisco DevNet
 
OpenAPI v.Next - Events, Alternative Schemas & the Road Ahead
OpenAPI v.Next - Events, Alternative Schemas & the Road AheadOpenAPI v.Next - Events, Alternative Schemas & the Road Ahead
OpenAPI v.Next - Events, Alternative Schemas & the Road AheadTed Epstein
 
OSS Tools: Creating a Reverse Engineering Plug-in for r2frida
OSS Tools: Creating a Reverse Engineering Plug-in for r2fridaOSS Tools: Creating a Reverse Engineering Plug-in for r2frida
OSS Tools: Creating a Reverse Engineering Plug-in for r2fridaNowSecure
 
Breaking Extreme Networks WingOS: How to own millions of devices running on A...
Breaking Extreme Networks WingOS: How to own millions of devices running on A...Breaking Extreme Networks WingOS: How to own millions of devices running on A...
Breaking Extreme Networks WingOS: How to own millions of devices running on A...Priyanka Aash
 
" Breaking Extreme Networks WingOS: How to own millions of devices running on...
" Breaking Extreme Networks WingOS: How to own millions of devices running on..." Breaking Extreme Networks WingOS: How to own millions of devices running on...
" Breaking Extreme Networks WingOS: How to own millions of devices running on...PROIDEA
 
Oracle Modern AppDev Approach to Cloud & Container Native App
Oracle Modern AppDev Approach to Cloud & Container Native AppOracle Modern AppDev Approach to Cloud & Container Native App
Oracle Modern AppDev Approach to Cloud & Container Native AppPaulo Alberto Simoes ∴
 
Git hub videowhisper-php-webcam-video-conference_ video conference_ web bas...
Git hub   videowhisper-php-webcam-video-conference_ video conference_ web bas...Git hub   videowhisper-php-webcam-video-conference_ video conference_ web bas...
Git hub videowhisper-php-webcam-video-conference_ video conference_ web bas...bos trevel
 
SFO15-205: OP-TEE Content Decryption with Microsoft PlayReady on ARM
SFO15-205: OP-TEE Content Decryption with Microsoft PlayReady on ARMSFO15-205: OP-TEE Content Decryption with Microsoft PlayReady on ARM
SFO15-205: OP-TEE Content Decryption with Microsoft PlayReady on ARMLinaro
 
20180417 hivemall meetup#4
20180417 hivemall meetup#420180417 hivemall meetup#4
20180417 hivemall meetup#4Takeshi Yamamuro
 
swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...
swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...
swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...Ivan Kravets
 
Optimizing your SparkML pipelines using the latest features in Spark 2.3
Optimizing your SparkML pipelines using the latest features in Spark 2.3Optimizing your SparkML pipelines using the latest features in Spark 2.3
Optimizing your SparkML pipelines using the latest features in Spark 2.3DataWorks Summit
 
Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)Logico
 
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...Codemotion
 
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...Codemotion
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Toolsrjsmelo
 
Overpowered Kubernetes: CI/CD for K8s on Enterprise IaaS
Overpowered Kubernetes: CI/CD for K8s on Enterprise IaaSOverpowered Kubernetes: CI/CD for K8s on Enterprise IaaS
Overpowered Kubernetes: CI/CD for K8s on Enterprise IaaSJ On The Beach
 

Similar to The Sodium crypto library of PHP 7.2 (PHP Day 2018) (20)

20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge
20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge
20180921_DOAG_BigDataDays_OracleSpatialandPython_kpatenge
 
UC18NA-D3D202-Dianomic-IZoratti-Introduction-To-FogLAMP.pdf
UC18NA-D3D202-Dianomic-IZoratti-Introduction-To-FogLAMP.pdfUC18NA-D3D202-Dianomic-IZoratti-Introduction-To-FogLAMP.pdf
UC18NA-D3D202-Dianomic-IZoratti-Introduction-To-FogLAMP.pdf
 
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
Speed up web APIs with Expressive and Swoole (PHP Day 2018) Speed up web APIs with Expressive and Swoole (PHP Day 2018)
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
 
Meeting rooms are talking! are you listening?
Meeting rooms are talking! are you listening?Meeting rooms are talking! are you listening?
Meeting rooms are talking! are you listening?
 
OpenAPI v.Next - Events, Alternative Schemas & the Road Ahead
OpenAPI v.Next - Events, Alternative Schemas & the Road AheadOpenAPI v.Next - Events, Alternative Schemas & the Road Ahead
OpenAPI v.Next - Events, Alternative Schemas & the Road Ahead
 
OSS Tools: Creating a Reverse Engineering Plug-in for r2frida
OSS Tools: Creating a Reverse Engineering Plug-in for r2fridaOSS Tools: Creating a Reverse Engineering Plug-in for r2frida
OSS Tools: Creating a Reverse Engineering Plug-in for r2frida
 
Breaking Extreme Networks WingOS: How to own millions of devices running on A...
Breaking Extreme Networks WingOS: How to own millions of devices running on A...Breaking Extreme Networks WingOS: How to own millions of devices running on A...
Breaking Extreme Networks WingOS: How to own millions of devices running on A...
 
" Breaking Extreme Networks WingOS: How to own millions of devices running on...
" Breaking Extreme Networks WingOS: How to own millions of devices running on..." Breaking Extreme Networks WingOS: How to own millions of devices running on...
" Breaking Extreme Networks WingOS: How to own millions of devices running on...
 
Oracle Modern AppDev Approach to Cloud & Container Native App
Oracle Modern AppDev Approach to Cloud & Container Native AppOracle Modern AppDev Approach to Cloud & Container Native App
Oracle Modern AppDev Approach to Cloud & Container Native App
 
Git hub videowhisper-php-webcam-video-conference_ video conference_ web bas...
Git hub   videowhisper-php-webcam-video-conference_ video conference_ web bas...Git hub   videowhisper-php-webcam-video-conference_ video conference_ web bas...
Git hub videowhisper-php-webcam-video-conference_ video conference_ web bas...
 
SFO15-205: OP-TEE Content Decryption with Microsoft PlayReady on ARM
SFO15-205: OP-TEE Content Decryption with Microsoft PlayReady on ARMSFO15-205: OP-TEE Content Decryption with Microsoft PlayReady on ARM
SFO15-205: OP-TEE Content Decryption with Microsoft PlayReady on ARM
 
20180417 hivemall meetup#4
20180417 hivemall meetup#420180417 hivemall meetup#4
20180417 hivemall meetup#4
 
swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...
swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...
swampUP: Over-The-Air (OTA) firmware upgrades for Internet of Things devices ...
 
Develop microservices in php
Develop microservices in phpDevelop microservices in php
Develop microservices in php
 
Optimizing your SparkML pipelines using the latest features in Spark 2.3
Optimizing your SparkML pipelines using the latest features in Spark 2.3Optimizing your SparkML pipelines using the latest features in Spark 2.3
Optimizing your SparkML pipelines using the latest features in Spark 2.3
 
Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)
 
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...
 
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...
Stève Sfartz - Meeting rooms are talking! Are you listening? - Codemotion Ber...
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Tools
 
Overpowered Kubernetes: CI/CD for K8s on Enterprise IaaS
Overpowered Kubernetes: CI/CD for K8s on Enterprise IaaSOverpowered Kubernetes: CI/CD for K8s on Enterprise IaaS
Overpowered Kubernetes: CI/CD for K8s on Enterprise IaaS
 

More from Zend by Rogue Wave Software

Building and managing applications fast for IBM i
Building and managing applications fast for IBM iBuilding and managing applications fast for IBM i
Building and managing applications fast for IBM iZend by Rogue Wave Software
 
Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i  Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i Zend by Rogue Wave Software
 

More from Zend by Rogue Wave Software (20)

Speed and security for your PHP application
Speed and security for your PHP applicationSpeed and security for your PHP application
Speed and security for your PHP application
 
Building and managing applications fast for IBM i
Building and managing applications fast for IBM iBuilding and managing applications fast for IBM i
Building and managing applications fast for IBM i
 
Building web APIs in PHP with Zend Expressive
Building web APIs in PHP with Zend ExpressiveBuilding web APIs in PHP with Zend Expressive
Building web APIs in PHP with Zend Expressive
 
To PHP 7 and beyond
To PHP 7 and beyondTo PHP 7 and beyond
To PHP 7 and beyond
 
Middleware web APIs in PHP 7.x
Middleware web APIs in PHP 7.xMiddleware web APIs in PHP 7.x
Middleware web APIs in PHP 7.x
 
Ongoing management of your PHP 7 application
Ongoing management of your PHP 7 applicationOngoing management of your PHP 7 application
Ongoing management of your PHP 7 application
 
Developing web APIs using middleware in PHP 7
Developing web APIs using middleware in PHP 7Developing web APIs using middleware in PHP 7
Developing web APIs using middleware in PHP 7
 
The Docker development template for PHP
The Docker development template for PHPThe Docker development template for PHP
The Docker development template for PHP
 
The most exciting features of PHP 7.1
The most exciting features of PHP 7.1The most exciting features of PHP 7.1
The most exciting features of PHP 7.1
 
Unit testing for project managers
Unit testing for project managersUnit testing for project managers
Unit testing for project managers
 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
Deploying PHP apps on the cloud
Deploying PHP apps on the cloudDeploying PHP apps on the cloud
Deploying PHP apps on the cloud
 
Data is dead. Long live data!
Data is dead. Long live data! Data is dead. Long live data!
Data is dead. Long live data!
 
Optimizing performance
Optimizing performanceOptimizing performance
Optimizing performance
 
Resolving problems & high availability
Resolving problems & high availabilityResolving problems & high availability
Resolving problems & high availability
 
Developing apps faster
Developing apps fasterDeveloping apps faster
Developing apps faster
 
Keeping up with PHP
Keeping up with PHPKeeping up with PHP
Keeping up with PHP
 
Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i  Fundamentals of performance tuning PHP on IBM i
Fundamentals of performance tuning PHP on IBM i
 
Getting started with PHP on IBM i
Getting started with PHP on IBM iGetting started with PHP on IBM i
Getting started with PHP on IBM i
 
Continuous Delivery e-book
Continuous Delivery e-bookContinuous Delivery e-book
Continuous Delivery e-book
 

Recently uploaded

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durbanmasabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 

Recently uploaded (20)

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 

The Sodium crypto library of PHP 7.2 (PHP Day 2018)

  • 1. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 1/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. THESODIUMCRYPTOLIBRARYTHESODIUMCRYPTOLIBRARY OFPHP7.2OFPHP7.2 by Senior Software Engineer , Verona (Italy), May 12 Enrico Zimuel Rogue Wave Software, Inc. phpDay 2018
  • 2. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 2/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. ABOUTMEABOUTME Developer since 1996 Senior Software Engineer at Inc. Core team of , and and international speaker Research Programmer at Co-founder of (Italy) Rogue Wave Software Apigility Expressive Zend Framework TEDx Amsterdam University PUG Torino
  • 3. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 3/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. OVERVIEWOVERVIEW NaCl/Sodium libraries Elliptic Curve Cryptography Sodium in PHP 7.2: 1. Encrypt with a shared-key 2. Authenticate with a shared-key 3. Sending secret messages 4. Digital signature 5. AEAD AES-GCM 6. Store passwords safely 7. Derive a key from a user's password
  • 4. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 4/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. CRYPTOGRAPHYCRYPTOGRAPHY Cryptography is hard. Hard to design, hard to implement, hard to use, and hard to get right.
  • 5. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 5/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. NACLNACL NaCl: Networking and Cryptography library High-speed software library for network communication, encryption, decryption, signatures, etc by Prof. , and Highly-secure primitives and constructions, implemented with extreme care to avoid Daniel J. Bernstein others side-channel attacks
  • 6. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 6/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. SIDE-CHANNELATTACKSIDE-CHANNELATTACK Attack based on information gained from the implementation of a computer system, rather than weaknesses in the implemented algorithm itself
  • 7. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 7/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. DECODERSAKEYUSINGPOWERANALYSISDECODERSAKEYUSINGPOWERANALYSIS Source: Protecting Against Side-Channel Attacks with an Ultra-Low Power Processor
  • 8. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 8/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. TIMINGATTACKTIMINGATTACK An attacker measures the CPU time to perform some procedures involving a secret (e.g. encryption key). If this time depends on the secret, the attacker may be able to deduce information about the secret.
  • 9. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 9/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. EXAMPLEINPHPEXAMPLEINPHP function compare(string $expected, string $actual): bool { $lenExpected = strlen($expected); $lenActual = strlen($actual); if ($lenExpected !== $lenActual) { return false; } for($i=0; $i < $lenActual; $i++) { if ($expected[$i] !== $actual[$i]) { return false; } } return true; }
  • 10. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 10/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. PREVENTTIMINGATTACK*PREVENTTIMINGATTACK* * constant-time comparison function compare(string $expected, string $actual): bool { $lenExpected = strlen($expected); $lenActual = strlen($actual); $len = min($lenExpected, $lenActual); $result = 0; for ($i = 0; $i < $len; $i++) { $result |= ord($expected[$i]) ^ ord($actual[$i]); } $result |= $lenExpected ^ $lenActual; return ($result === 0); }
  • 11. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 11/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. BESTTIMINGATTACKBESTTIMINGATTACK In 2006 Adi Shamir, Eran Tromer, and Dag Arne Osvik used a timing attack to discover, in 65 milliseconds, the secret key used in widely deployed software for hard- disk encryption. Source: Cache Attacks and Countermeasures: the Case of AES
  • 12. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 12/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. SODIUMCRYPTOLIBRARYSODIUMCRYPTOLIBRARY
  • 13. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 13/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. SODIUMSODIUM Sodium (libsodium) is a fork of NaCl A portable, cross-compilable, installable, packageable, API-compatible version of NaCl Same implementations of crypto primitives as NaCl Shared library and a standard set of headers (portable implementation) O cial web site: libsodium.org
  • 14. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 14/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. FEATURESFEATURES Authenticated public-key and authenticated shared- key encryption Public-key and shared-key signatures Hashing Keyed hashes for short messages Secure pseudo-random numbers generation
  • 15. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 15/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. ALGORITHMSINSODIUMALGORITHMSINSODIUM Di e–Hellman key-exchange function , stream ciphers message-authentication code public-key signature system , password hashing authenticated encryption algorithm Curve25519 Salsa20 ChaCha20 Poly1305 Ed25519 Argon2 Scrypt AES-GCM
  • 16. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 16/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. ELLIPTICCURVESELLIPTICCURVES
  • 17. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 17/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. ELLIPTICCURVESELLIPTICCURVES = + ax + by 2 x 3
  • 18. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 18/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. ADD2POINTSADD2POINTS A + B = C, A + C = D, A + D = E
  • 19. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 19/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. SCALARMULTIPLICATIONSCALARMULTIPLICATION Given and nd such that is hard P + P = 2P P Q k Q = kP
  • 20. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 20/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved.
  • 21. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 21/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. SODIUMINPHPSODIUMINPHP Available (as standard library) from PHP 7.2 PECL extension ( ) for PHP 7.0/7.1 85 functions with pre x sodium_ e.g. sodium_crypto_box_keypair() libsodium
  • 22. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 22/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. EXAMPLE1:EXAMPLE1: ENCRYPTWITHASHARED-KEYENCRYPTWITHASHARED-KEY
  • 23. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 23/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. SYMMETRICENCRYPTIONSYMMETRICENCRYPTION Note: the encryption is always authenticated, you need to store also nonce + ciphertext Algorithms: to encrypt and for MAC $msg = 'This is a super secret message!'; // Generating an encryption key and a nonce $key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES); // 256 bit $nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES); // 24 bytes // Encrypt $ciphertext = sodium_crypto_secretbox($msg, $nonce, $key); // Decrypt $plaintext = sodium_crypto_secretbox_open($ciphertext, $nonce, $key); echo $plaintext === $msg ? 'Success' : 'Error'; XSalsa20 Poly1305
  • 24. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 24/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. EXAMPLE2:EXAMPLE2: AUTHENTICATEWITHASHARED-KEYAUTHENTICATEWITHASHARED-KEY
  • 25. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 25/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. SYMMETRICAUTHENTICATIONSYMMETRICAUTHENTICATION Note: the message is not encrypted Algorithm: $msg = 'This is the message to authenticate!'; $key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES); // 256 bit // Generate the Message Authentication Code $mac = sodium_crypto_auth($msg, $key); // Altering $mac or $msg, verification will fail echo sodium_crypto_auth_verify($mac, $msg, $key) ? 'Success' : 'Error'; HMAC-SHA512
  • 26. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 26/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. EXAMPLE3:EXAMPLE3: SENDINGSECRETMESSAGESSENDINGSECRETMESSAGES
  • 27. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 27/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. PUBLIC-KEYENCRYPTIONPUBLIC-KEYENCRYPTION Note: it provides con dentiality, integrity and non-repudiation Algorithms: to encrypt, for MAC, and for key exchange $aliceKeypair = sodium_crypto_box_keypair(); $alicePublicKey = sodium_crypto_box_publickey($aliceKeypair); $aliceSecretKey = sodium_crypto_box_secretkey($aliceKeypair); $bobKeypair = sodium_crypto_box_keypair(); $bobPublicKey = sodium_crypto_box_publickey($bobKeypair); // 32 bytes $bobSecretKey = sodium_crypto_box_secretkey($bobKeypair); // 32 bytes $msg = 'Hi Bob, this is Alice!'; $nonce = random_bytes(SODIUM_CRYPTO_BOX_NONCEBYTES); // 24 bytes $keyEncrypt = $aliceSecretKey . $bobPublicKey; $ciphertext = sodium_crypto_box($msg, $nonce, $keyEncrypt); $keyDecrypt = $bobSecretKey . $alicePublicKey; $plaintext = sodium_crypto_box_open($ciphertext, $nonce, $keyDecrypt); echo $plaintext === $msg ? 'Success' : 'Error'; XSalsa20 Poly1305 XS25519
  • 28. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 28/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. EXAMPLE4:EXAMPLE4: DIGITALSIGNATUREDIGITALSIGNATURE
  • 29. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 29/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. DIGITALSIGNATUREDIGITALSIGNATURE Note: the message is not encrypted, signedMsg includes signature + msg Algorithm: $keypair = sodium_crypto_sign_keypair(); $publicKey = sodium_crypto_sign_publickey($keypair); // 32 bytes $secretKey = sodium_crypto_sign_secretkey($keypair); // 64 bytes $msg = 'This message is from Alice'; // Sign a message $signedMsg = sodium_crypto_sign($msg, $secretKey); // Or generate only the signature (detached mode) $signature = sodium_crypto_sign_detached($msg, $secretKey); // 64 bytes // Verify the signed message $original = sodium_crypto_sign_open($signedMsg, $publicKey); echo $original === $msg ? 'Signed msg ok' : 'Error signed msg'; // Verify the signature echo sodium_crypto_sign_verify_detached($signature, $msg, $publicKey) ? 'Signature ok' : 'Error signature'; Ed25519
  • 30. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 30/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. EXAMPLE5:EXAMPLE5: AES-GCMAES-GCM
  • 31. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 31/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. AEADAES-256-GCMAEADAES-256-GCM Note: you need to store also ad and nonce + ciphertext if (! sodium_crypto_aead_aes256gcm_is_available()) { throw new Exception("AES-GCM is not supported on this platform"); } $msg = 'Super secret message!'; $key = random_bytes(SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES); $nonce = random_bytes(SODIUM_CRYPTO_AEAD_AES256GCM_NPUBBYTES); // AEAD encryption $ad = 'Additional public data'; $ciphertext = sodium_crypto_aead_aes256gcm_encrypt( $msg, $ad, $nonce, $key ); // AEAD decryption $decrypted = sodium_crypto_aead_aes256gcm_decrypt( $ciphertext,
  • 32. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 32/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. EXAMPLE6:EXAMPLE6: STOREPASSWORDSSAFELYSTOREPASSWORDSSAFELY
  • 33. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 33/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. ARGON2IARGON2I An example of Argon2i hash: $password = 'password'; $hash = sodium_crypto_pwhash_str( $password, SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE ); // 97 bytes echo sodium_crypto_pwhash_str_verify($hash, $password) ? 'OK' : 'Error'; $argon2id$v=19$m=65536,t=2,p=1$EF1BpShRmCYHN7ryxlhtBg$zLZO4IWjx3E...
  • 34. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 34/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. ARGON2INPHP7.2ARGON2INPHP7.2 Comparing with Sodium: Note: password_hash() is not compatible with sodium_crypto_pwhash_str() $password = 'password'; // Argon2i without Sodium $hash = password_hash($password, PASSWORD_ARGON2I); // 95 bytes echo password_verify($password, $hash) ? 'OK' : 'Error'; $argon2id$v=19$m=65536,t=2,p=1$EF1BpShRmCYH... // 97 bytes, Sodium $argon2i$v=19$m=1024,t=2,p=2$Y3pweEtMdS82SG... // 95 bytes, PHP
  • 35. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 35/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. EXAMPLE7:EXAMPLE7: DERIVEAKEYFROMAUSER'SPASSWORDDERIVEAKEYFROMAUSER'SPASSWORD
  • 36. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 36/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. PASSWORDAREBADPASSWORDAREBAD Not random Predictable (most of the time) Only a subset of ASCII codes (typically vs ) Never use it as encryption/authentication key! Use KDF to derive a key from a password 68 256
  • 37. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 37/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. DERIVEAKEYUSINGARGON2IDERIVEAKEYUSINGARGON2I Example: generating a binary key of 32 bytes Note: you need to store also the salt to generate the same key from password $password = 'password'; $salt = random_bytes(SODIUM_CRYPTO_PWHASH_SALTBYTES); $key = sodium_crypto_pwhash( 32, $password, $salt, SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE );
  • 38. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 38/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. UTILITYINSODIUMUTILITYINSODIUM Wiping Sensitive Data from Memory: Hex2bin / Bin2Hex: Constant-time string comparison: sodium_memzero(&$secret) sodium_hex2bin(string $hex, string $ignore = ' sodium_bin2hex(string $bin) sodium_compare(string $str1, string $str2)
  • 39. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 39/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. REFERENCESREFERENCES D.J. Bernstein, T.Lange, and P.Schwabe, , Lecture Notes in Computer Science 7533, Springer, 2012. ISBN 978-3-642-33480-1 Daniel J. Bernstein, OpenDNS Security Research, , March 6, 2013 D.A. Osvik, A.Shamir, E.Tromer, , Lecture Notes in Computer Science, vol 3860. Springer, 2006 Anthony Ferrara, , 2014 Eric Sesterhenn, , 2017 Angela Raucher, , Synopsys Willy Raedy, , Full Stack Academy of Code Scott Arciszewski, , Paragonie, 2017 The security impact of a new cryptographic library Cryptography in NaCl Introducing Sodium, a new cryptographic library Cache Attacks and Countermeasures: the Case of AES It's All About Time Benchmarking memcmp() for timing attacks Protecting Against Side-Channel Attacks with an Ultra-Low Power Processor Elliptic Curve Cryptography Tutorial Libsodium Quick Reference
  • 40. 5/14/2018 The Sodium crypto library of PHP 7.2 - phpDay 2018 https://www.zimuel.it/slides/phpday2018/sodium?print-pdf#/ 40/40 © 2018 Rogue Wave Software, Inc. All Rights Reserved. THANKS!THANKS! Rate this talk at This work is licensed under a . I used to make this presentation. joind.in/talk/5769a Creative Commons Attribution-ShareAlike 3.0 Unported License reveal.js