SlideShare uma empresa Scribd logo
1 de 71
Baixar para ler offline
@adam_englander
PHP[TEK] 2018
Wifi:
Sheraton Conference
Pass: phptek2018
Twitter:
#phptek
Rate the Talks
https://joind.in/event/phptek-2018
@adam_englander
Cryptography Advances
in PHP 7.2
Adam Englander
Software Architect, iovation
@adam_englander
Half of the changes identified in the
PHP7.2.0 release announcements
were related to cryptography.
@adam_englander
SSL is Dead!
Long live TLS!
@adam_englander
Streams
ssl:// is now an alias of tls://
@adam_englander
Steam Defaults
STREAM_CRYPTO_METHOD_TLS_SERVER,
STREAM_CRYPTO_METHOD_TLS_CLIENT,
and tls:// default to
TLSv1.0 + TLSv1.1 + TLSv1.2
Instead of TLSv1.0 only
@adam_englander
Goodbye MCrypt!
@adam_englander
@adam_englander
Hello NaCl!
(Sodium)
@adam_englander
Easy, Secure, and Fast
@adam_englander
Easy Like Laravel
@adam_englander
Opinionated for your pleasure
@adam_englander
Simplifies Common Tasks
@adam_englander
Does a Lot of Heavy Lifting
@adam_englander
Secure Like the Phantom Zone
@adam_englander
Strong Authenticated Encryption
@adam_englander
Modern Algorithms
Poly1305
XSalsa20ChaCha20
Argon2i
Blake2
@adam_englander
Helpers for Security
@adam_englander
Constant-Time Test for Equality
"abcdefg" == "hijklmnop"
sodium_memcmp("abcdefg", "hijklmnop")
"abcdefg" == "abcdefq"
sodium_memcmp("abcdefg", "abcdefq")
@adam_englander
String Memory Overwrite
sodium_memzero($value);
$value = "000000";
$value = "secret";
@adam_englander
Fast Like the Millennium Falcon
@adam_englander
ChaCha20 vs AES
https://security.googleblog.com/2014/04/speeding-up-and-strengthening-https.html
@adam_englander
BLAKE2 vs Everything
https://blake2.net/
@adam_englander
Key Derivation
a.k.a. password hashing
@adam_englander
Argon2i
@adam_englander
Best in Class
@adam_englander
Blake2 Inside
@adam_englander
Time based rather count based
iterations
@adam_englander
Parallelism and Memory
Requirements
@adam_englander
Exposed via Password Function
@adam_englander
scrypt without PECL
@adam_englander
Hashing
Generic hashing
@adam_englander
Blake2b for data validation
@adam_englander
SipHash-2-4 for short hashes
@adam_englander
Symmetric Key Encryption
a.k.a secret key encryption
@adam_englander
Authenticated encryption via
auth tag
@adam_englander
Stream based encryption
@adam_englander
Encrypted message sets
@adam_englander
XSalsa20-Poly1305
@adam_englander
AES256-GCM if you like pain
@adam_englander
Asymmetric Key Cryptography
a.k.a. public key encryption
@adam_englander
MAC authenticated encryption
@adam_englander
Signatures can be attached or
detached
@adam_englander
XSalsa20-Poly1305
@adam_englander
Example
@adam_englander
Ed25519 signatures
@adam_englander
Key Exchange
Use with care!
@adam_englander
Examples
@adam_englander
Encryption
@adam_englander
Key Generation
$keyPair = sodium_crypto_box_keypair();
@adam_englander
Getting Public/Private Key Pairs
$secretKey = sodium_crypto_box_secretkey(
$keyPair);
$publicKey = sodium_crypto_box_publickey(
$keyPair);
@adam_englander
Creating Mixed Key Pairs
sodium_crypto_box_keypair_from_secretkey_and_publickey(
$mySecretKey, $theirPublicKey
);
@adam_englander
Encryption
$nonce = random_bytes(
SODIUM_CRYPTO_BOX_NONCEBYTES);
$ciphertext = sodium_crypto_box(
"Hello ,World!",
$nonce,
$keyPair);
@adam_englander
Decryption
$plaintext = sodium_crypto_box_open(
$ciphertext, $nonce, $keyPair);
@adam_englander
Digital Signatures
@adam_englander
Key Generation
$keyPair = sodium_crypto_sign_keypair();
@adam_englander
Getting Public/Private Key Pairs
$secretKey = sodium_crypto_sign_secretkey(
$keyPair);
$publicKey = sodium_crypto_sign_publickey(
$keyPair);
@adam_englander
Signing
$signedMsg = sodium_crypto_sign(
"Hello, World!",
$secretKey
);
@adam_englander
Signature Verification
$originalMsg = sodium_crypto_sign_open(
$signedMsg,
$publicKey
);
if ($originalMsg === false) {
throw new Exception("Fail!");
}
@adam_englander
Hashing
@adam_englander
Standard Hash
$h = sodium_crypto_generichash("Msg");
print base64_encode($h);
URvIHd4RGAg4xWLIK7NfMiP0YGHr3kqVXCez9InPHgM=
@adam_englander
Signed Hash
$key = random_bytes(
SODIUM_CRYPTO_GENERICHASH_KEYBYTES);
$h = sodium_crypto_generichash(
"Msg", $key);
print base64_encode($h);
/qV2j5MfGBjJ9g60PQnnQYSt1Y/1csjJzq37C1pE4SE=
@adam_englander
Short Hash
$key = random_bytes(
SODIUM_CRYPTO_SHORTHASH_KEYBYTES);
$h = sodium_crypto_shorthash(
"Msg", $key);
print base64_encode($h);
eCTWVTKkkKw=
@adam_englander
Key Derivation
@adam_englander
Create KDF Hash
$hash = sodium_crypto_pwhash_str(
'Password',
SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE,
SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE
);
print base64_encode($hash);
$argon2id$v=19$m=65536,t=2,p=1$qCcD3BqZjmbYEFMKxgsUjA$5BzYYNuACwp3Zq
p29QnT9upRxVZykU/P8isst91uKYE==
@adam_englander
Verify KDF Hash
sodium_crypto_pwhash_str_verify(
$hash,
'Password'
);
@adam_englander
Password Extension
@adam_englander
Create Password Hash
$hash = password_hash(
'Password',
PASSWORD_ARGON2I
);
$argon2i$v=19$m=1024,t=2,p=2$WW15cG1NLjR0cXZET3Nzeg$ImFwKTaVgDHme95M
ROV5S9ssG+e458gdpLz9Cwwiba8
@adam_englander
Resources
https://download.libsodium.org/doc/
https://paragonie.com/book/pecl-libsodium
http://php.net/manual/en/book.sodium.php
http://php.net/manual/en/function.password-hash.php
@adam_englander
Thanks to
Our Sponsors
@adam_englander
Rate This Talk
https://joind.in/talk/48fbd

Mais conteúdo relacionado

Mais procurados (6)

The state of curl 2020
The state of curl 2020The state of curl 2020
The state of curl 2020
 
What is WebRTC? What can I do with it?
What is WebRTC? What can I do with it?What is WebRTC? What can I do with it?
What is WebRTC? What can I do with it?
 
DNS over HTTPS
DNS over HTTPSDNS over HTTPS
DNS over HTTPS
 
Dhcp security #netseckh
Dhcp security #netseckhDhcp security #netseckh
Dhcp security #netseckh
 
Ahmad Siddiq Wi-Fi Ninjutsu Exploitation
Ahmad Siddiq Wi-Fi Ninjutsu ExploitationAhmad Siddiq Wi-Fi Ninjutsu Exploitation
Ahmad Siddiq Wi-Fi Ninjutsu Exploitation
 
Decrypting and Selectively Inspecting Modern Traffic
Decrypting and Selectively Inspecting Modern TrafficDecrypting and Selectively Inspecting Modern Traffic
Decrypting and Selectively Inspecting Modern Traffic
 

Semelhante a php[tek] 2108 - Cryptography Advances in PHP 7.2

us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-La...
us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-La...us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-La...
us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-La...
sonjeku1
 
Sniffing SSL Traffic
Sniffing SSL TrafficSniffing SSL Traffic
Sniffing SSL Traffic
dkaya
 

Semelhante a php[tek] 2108 - Cryptography Advances in PHP 7.2 (20)

Solving HTTP Problems With Code and Protocols
Solving HTTP Problems With Code and ProtocolsSolving HTTP Problems With Code and Protocols
Solving HTTP Problems With Code and Protocols
 
TLS Perf: from three to zero in one spec
TLS Perf:  from three to zero in one specTLS Perf:  from three to zero in one spec
TLS Perf: from three to zero in one spec
 
us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-La...
us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-La...us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-La...
us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-La...
 
HTTP/3 is next generation HTTP
HTTP/3 is next generation HTTPHTTP/3 is next generation HTTP
HTTP/3 is next generation HTTP
 
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
 
SSL/TLS Eavesdropping with Fullpath Control
SSL/TLS Eavesdropping with Fullpath ControlSSL/TLS Eavesdropping with Fullpath Control
SSL/TLS Eavesdropping with Fullpath Control
 
HTTP/3 for everyone
HTTP/3 for everyoneHTTP/3 for everyone
HTTP/3 for everyone
 
Evolving HTTP and making things QUIC
Evolving HTTP and making things QUICEvolving HTTP and making things QUIC
Evolving HTTP and making things QUIC
 
Sniffing SSL Traffic
Sniffing SSL TrafficSniffing SSL Traffic
Sniffing SSL Traffic
 
HTTP/2
HTTP/2HTTP/2
HTTP/2
 
HTTP/3 over QUIC. All is new but still the same!
HTTP/3 over QUIC. All is new but still the same!HTTP/3 over QUIC. All is new but still the same!
HTTP/3 over QUIC. All is new but still the same!
 
Advancing IoT Communication Security with TLS and DTLS v1.3
Advancing IoT Communication Security with TLS and DTLS v1.3Advancing IoT Communication Security with TLS and DTLS v1.3
Advancing IoT Communication Security with TLS and DTLS v1.3
 
SIP over TLS
SIP over TLSSIP over TLS
SIP over TLS
 
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
Iot Conference Berlin M2M,IoT, device management: one protocol to rule them all?
 
Developing the fastest HTTP/2 server
Developing the fastest HTTP/2 serverDeveloping the fastest HTTP/2 server
Developing the fastest HTTP/2 server
 
Http3 fullstackfest-2019
Http3 fullstackfest-2019Http3 fullstackfest-2019
Http3 fullstackfest-2019
 
HTTPS: All you need to know
HTTPS: All you need to knowHTTPS: All you need to know
HTTPS: All you need to know
 
Random musings on SSL/TLS configuration
Random musings on SSL/TLS configurationRandom musings on SSL/TLS configuration
Random musings on SSL/TLS configuration
 
Securing Network Access with Open Source solutions
Securing Network Access with Open Source solutionsSecuring Network Access with Open Source solutions
Securing Network Access with Open Source solutions
 
HTTP/2 : why upgrading the web? - apidays Paris
HTTP/2 : why upgrading the web? - apidays ParisHTTP/2 : why upgrading the web? - apidays Paris
HTTP/2 : why upgrading the web? - apidays Paris
 

Mais de Adam Englander

Mais de Adam Englander (20)

Making PHP Smarter - Dutch PHP 2023.pptx
Making PHP Smarter - Dutch PHP 2023.pptxMaking PHP Smarter - Dutch PHP 2023.pptx
Making PHP Smarter - Dutch PHP 2023.pptx
 
Practical API Security - PyCon 2019
Practical API Security - PyCon 2019Practical API Security - PyCon 2019
Practical API Security - PyCon 2019
 
Threat Modeling for Dummies
Threat Modeling for DummiesThreat Modeling for Dummies
Threat Modeling for Dummies
 
ZendCon 2018 - Practical API Security
ZendCon 2018 - Practical API SecurityZendCon 2018 - Practical API Security
ZendCon 2018 - Practical API Security
 
ZendCon 2018 - Cryptography in Depth
ZendCon 2018 - Cryptography in DepthZendCon 2018 - Cryptography in Depth
ZendCon 2018 - Cryptography in Depth
 
Threat Modeling for Dummies - Cascadia PHP 2018
Threat Modeling for Dummies - Cascadia PHP 2018Threat Modeling for Dummies - Cascadia PHP 2018
Threat Modeling for Dummies - Cascadia PHP 2018
 
Dutch PHP 2018 - Cryptography for Beginners
Dutch PHP 2018 - Cryptography for BeginnersDutch PHP 2018 - Cryptography for Beginners
Dutch PHP 2018 - Cryptography for Beginners
 
php[tek] 2018 - Biometrics, fantastic failure point of the future
php[tek] 2018 - Biometrics, fantastic failure point of the futurephp[tek] 2018 - Biometrics, fantastic failure point of the future
php[tek] 2018 - Biometrics, fantastic failure point of the future
 
Biometrics: Sexy, Secure and... Stupid - RSAC 2018
Biometrics: Sexy, Secure and... Stupid - RSAC 2018Biometrics: Sexy, Secure and... Stupid - RSAC 2018
Biometrics: Sexy, Secure and... Stupid - RSAC 2018
 
Practical API Security - PyCon 2018
Practical API Security - PyCon 2018Practical API Security - PyCon 2018
Practical API Security - PyCon 2018
 
Practical API Security - Midwest PHP 2018
Practical API Security - Midwest PHP 2018Practical API Security - Midwest PHP 2018
Practical API Security - Midwest PHP 2018
 
Cryptography for Beginners - Midwest PHP 2018
Cryptography for Beginners - Midwest PHP 2018Cryptography for Beginners - Midwest PHP 2018
Cryptography for Beginners - Midwest PHP 2018
 
Cryptography for Beginners - Sunshine PHP 2018
Cryptography for Beginners - Sunshine PHP 2018Cryptography for Beginners - Sunshine PHP 2018
Cryptography for Beginners - Sunshine PHP 2018
 
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the FutureConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
 
Con Foo 2017 - Don't Loose Sleep - Secure Your REST
Con Foo 2017 - Don't Loose Sleep - Secure Your RESTCon Foo 2017 - Don't Loose Sleep - Secure Your REST
Con Foo 2017 - Don't Loose Sleep - Secure Your REST
 
ZendCon 2017 - Cryptography for Beginners
ZendCon 2017 - Cryptography for BeginnersZendCon 2017 - Cryptography for Beginners
ZendCon 2017 - Cryptography for Beginners
 
ZendCon 2017: The Red Team is Coming
ZendCon 2017: The Red Team is ComingZendCon 2017: The Red Team is Coming
ZendCon 2017: The Red Team is Coming
 
ZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async PrimerZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async Primer
 
Symfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
Symfony Live San Franciso 2017 - BDD API Development with Symfony and BehatSymfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
Symfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
 
Coder Cruise 2017 - The Red Team Is Coming
Coder Cruise 2017 - The Red Team Is ComingCoder Cruise 2017 - The Red Team Is Coming
Coder Cruise 2017 - The Red Team Is Coming
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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...
 

php[tek] 2108 - Cryptography Advances in PHP 7.2