developing fast mechanically verified
play

Developing Fast, Mechanically-Verified Cryptographic Code Bryan - PowerPoint PPT Presentation

Developing Fast, Mechanically-Verified Cryptographic Code Bryan Parno Carnegie Mellon University 1 The HTTPS Ecosystem is critical Services & Applications Edge cURL Skype Apache Nginx WebKit IIS Clients Servers HTTPS Ecosystem


  1. Developing Fast, Mechanically-Verified Cryptographic Code Bryan Parno Carnegie Mellon University 1

  2. The HTTPS Ecosystem is critical Services & Applications Edge cURL Skype Apache Nginx WebKit IIS Clients Servers HTTPS Ecosystem • Most widely deployed security protocol? – 40% all Internet traffic (+40%/year) • Web, cloud, email, VoIP, 802.1x, VPNs, … 2

  3. The HTTPS Ecosystem is complex BoringSSL OpenSSL Services & Applications TLS Protocol TLS Protocol Edge cURL Skype Apache Nginx WebKit IIS 30K SLOC 40K SLOC Clients Servers Crypto Crypto HTTPS C Asm C Asm Certification ASN.1 X.509 Authority 100K 60K 160K 150K 100+ pages! TLS SLOC SLOC SLOC SLOC *** RSA SHA ECDH 4Q Crypto Algorithms Stdlib (e.g., buffers, bytes) Untrusted network (TCP, UDP, …) 3

  4. The HTTPS Ecosystem is buggy • 20 years of attacks & fixes Services & Applications Buffer overflows Memory management Edge cURL Skype Apache Nginx WebKit IIS Incorrect state machines Clients Servers Lax certificate parsing Weakly or badly implemented crypto Side channels HTTPS Error-inducing APIs Certification Flawed standards ASN.1 X.509 Authority … TLS • Many implementations *** OpenSSL, Schannel , NSS, … RSA SHA Still patched every month! ECDH 4Q Crypto Algorithms Stdlib (e.g., buffers, bytes) Untrusted network (TCP, UDP, …) 4

  5. Everest : Deploying Verified-Secure Implementations in the HTTPS Ecosystem

  6. Everest Goals • Fully verified replacement Services & Applications Edge cURL Skype Apache Nginx WebKit IIS • Widespread deployment Clients Servers • Trustworthy, usable tools HTTPS $ apt-get install verified_https Certification ASN.1 X.509 $ /etc/init.d/apache2 restart Authority TLS *** RSA SHA ECDH 4Q Crypto Algorithms Stdlib (e.g., buffers, bytes) Untrusted network (TCP, UDP, …) 6

  7. Research Questions • How do we decide whether new protocols are secure? – Especially when interoperating with insecure protocols • Can we make verified systems as fast as unverified? • How do we handle advanced threats? – Ex: Side channels • Why should we trust automated verification tools? • How can verification be more accessible? – Especially to non-experts in verification 7

  8. MSR-Cambridge Patrice Kenji Antoine Godefroid Maillard Delignat-Lavaud MSR-Bangalore Aseem Jay Rastogi MSR-Redmond Bosamiya Barry Bond INRIA Aymeric Chris Fromherz Hawblitzel Nik Swamy CMU Catalin Hritcu Bryan Parno Tahina Ramanandro + interns and many Karthik Cédric Bhargavan other collaborators... Jonathan Fournet Markulf Protzenko Santiago Kohlweiss Zanella-Beguelin Christoph Jean Karim Wintersteiger Zinzindohoue Benjamin Beurdouche

  9. Current Status HTTPS X.509 ASN.1 TLS Crypto Algorithms ChaCha SHA Poly1305 Poly1305 HMAC AES-CBC ECDH AES-GCM 4Q RSA Stdlib (e.g., buffers, bytes) 9

  10. EverCrypt: A Verified Crypto Provider HTTPS X.509 ASN.1 TLS *** RSA SHA ECDH 4Q Crypto Algorithms Network buffers

  11. Why Verify Crypto? • Bugs are real, and potentially devastating! • 24 vulnerabilities in OpenSSL’s libcrypto in ~3 years! “These produce wrong results. The first example does so only on 32 bit, the other three also on 64 bit.” “I believe this affects both the SSE2 and AVX2 code. It does seem to be dependent on this input pattern.” “I'm probably going to write something to generate random inputs and stress all your other poly1305 code paths against a reference implementation.”

  12. Side Channel Challenge (Attacks) Protocol-level Traffic analysis Timing attacks against Memory & Cache side channels cryptographic primitives TLS messages may reveal information Combined analysis of the time and A remote attacker may learn Memory access patterns may expose about the internal protocol state or the length distributions of packets leaks information about crypto secrets by secrets, in particular because caching application data information about the application timing execution time for various inputs may expose sensitive data (e.g. by timing) • • • • Hello message contents (e.g. time CRIME/BREACH (adaptive chosen Bleichenbacher attacks against OpenSSL key recovery in virtual in nonces, SNI) plaintext attack) PKCS#1 decryption and signatures machines • • • • Alerts (e.g. decryption vs. padding User tracking Timing attacks against RC4 (Lucky Cache timing attacks against AES • alerts) Auto-complete input theft 13) • Record headers ECDSA Bleichenbacher BREACH timing Side-channel Vaudenay AES cache timing leaks in Web Tag size CRIME Lucky13 DROWN applications Remote timing attacks are practical 2000 … 2006 2007 2008 2009 2010 2011 20 12 2013 2014

  13. Current State of the Art: OpenSSL • Hand-written mix of Perl and assembly • Customized for 50+ hardware platforms • Why? • Performance!

  14. Features of an Ideal Library (programmer) • Usable • preferably in C or ASM, not “exotic” languages • Comprehensive • one algorithm per processor generation / bitsize • Auto-configurable multiplexing • best algorithm picked automatically • Agility • clients deal with a unified API for each family

  15. Features of an Ideal Library (researcher) • Verifiable • written in a language amenable to verification • Programmer productivity • share as much code as possible / agile • Auto-configurable • doesn’t blue - screen with “missing instruction” • Deep integration • each implementation verifies against the same spec • Abstraction • clients need not know any implementation details EverCrypt provides a comprehensive verification result without compromising performance

  16. EverCrypt Internals EverCrypt mediates between (possibly verified) clients and different implementations C client miTLS Merkle trees clients EverCrypt (C) agile, multiplexing library Low* (C) Vale (ASM) cryptographic providers EverCrypt Features - Agility - same functionality (e.g., hash), multiple algorithms - Multiplexing - same algorithm (e.g., SHA2_256), multiple implementations - Abstraction - clients verify against a single spec and an abstract footprint

  17. EverCrypt is Comprehensive

  18. Talk Overview 1. Introduction to Everest and EverCrypt 2. Verifying Assembly 3. Verifying C + interop 4. Verifying Cryptographic Constructions 5. Achieving Agility and No-Cost Abstraction 6. Verified Applications 18

  19. Cryptographic Implementation Requirements Difficult to meet all three goals. Correct Fast Secure Platform-agnostic Formally prove that Correct control flow implementation and free from leakage & platform-specific optimizations matches specification and side channels 19

  20. Result: Crypto implementations usually fall into one of two camps. Fast but non-verified Verified but slow crypto implementations crypto implementations 20

  21. SHA 256 Latency [100 KB data] Verified implementations Time Time (usec) (usec) Perf gap Unverified implementation OpenSSL Zinzindohoue Appel et al. [ACM TOPLAS ‘15] et al. [ePrint ‘15]

  22. OpenSSL Performance Tricks Mix of ASM + Perl Assembly code sub BODY_00_15 { is a Perl string $code .= <<END #if __ARM_ARCH__>=7 @ ldr $t1,[$inp],#4 C macros for target #if $i==15 instruction ... selection #endif END } C macros for code specialization 22

  23. OpenSSL Performance Tricks Perl variables for register names @V = (“r4”, “r5”, “r6”, “r7”, “r8”, “r9”, “r10”, “r11”); Code expansion for ($i=0; $i<16; $i++) { using loops &BODY_00_15($i, @V); unshift(@V, pop(@V)); } Register selection using Perl arrays 23

  24. sub BODY_00_15 { my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_; $code.=<<END if ($i<16); #if __ARM_ARCH__>=7 @ ldr $t1,[$inp],#4 # if $i==15 str $inp,[sp,#17*4] # endif eor $t0,$e,$e,ror#`$Sigma1[1]-$Sigma1[0]` add $a,$a,$t2 Result: Code becomes difficult to eor $t0,$t0,$e,ror#`$Sigma1[2]-$Sigma1[0]` # ifndef __ARMEB__ understand, debug, and formally rev $t1,$t1 verify for correctness and security. # endif #else @ ldrb $t1,[$inp,#3] add $a,$a,$t2 ldrb $t2,[$inp,#2] ldrb $t0,[$inp,#1] orr $t1,$t1,$t2,lsl#8 ldrb $t2,[$inp],#4 orr $t1,$t1,$t0,lsl#16 # if $i==15 str $inp,[sp,#17*4] # endif 24 eor $t0,$e,$e,ror#`$Sigma1[1]-$Sigma1[0]` orr $t1,$t1,$t2,lsl#24 eor $t0,$t0,$e,ror#`$Sigma1[2]-$Sigma1[0]` @ Sigma1(e) #endif END

  25. Vale : A Firmer Foundation Flexible framework for writing high-performance, proven correct and secure assembly code. Correct Secure Fast 25

  26. Vale : A Firmer Foundation Flexible framework for writing high-performance, proven correct and secure assembly code. Flexible Syntax High Performance High Assurance Vale supports constructs Code generated by Vale Vale can be used to prove for expressing functionality matches or exceeds functional correctness and OpenSSL’s performance. as well as optimizations. correct information flow. 26

  27. Key Language Constructs in Vale Assembly Structured Instructions Control Flow Optimization Constructs e.g. Mov, Rev, and e.g. if, while, AesKeygenAssist and procedure Enable proof Vary according to Customize code composition the target platform generation 27

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend