Developer Cryptography Best Practices

Total Page:16

File Type:pdf, Size:1020Kb

Developer Cryptography Best Practices 1 Developer Cryptography ì Best Practices Secure Software Systems Fall 2018 2 Design Considerations ì How do I update my crypto? ì In an installed application ì With users in the field ì Gracefully? ì So that over time, all active accounts are transparently upgraded to the latest secure standards? ì Examples ì New KDF (function, or just parameters) after old KDF found to be weak ì New crypto library after security bugs fixed Secure Software Systems Fall 2018 3 ì Application Use Cases Secure Software Systems Fall 2018 4 Application Use Cases ì Password handling (Storing passwords in a database, using human- intelligible secret keys, …) ì Plaintext? NO NO NO ì Old cryptographic hash (MD5)? NO NO ì Old cryptographic hash (MD5) with salt? NO NO ì New cryptographic hash (SHA-2) with salt? NO ì CPU and memory intensive Key Derivation Function? YES! ì bcrypt ì scrypt Secure Software Systems https://blog.tjll.net/please-stop-hashing-passwords/ Fall 2018 5 Application Use Cases ì Encryption of Bulk Data (Hiding from users / hiding from network) ì NaCl / Libsodium default – YES! ì Chacha20 Cipher w/ Poly1305 MAC – YES! ì AES-GCM – YES! ì All options provide AEAD ì Authenticated Encryption with Associated Data Secure Software Systems Fall 2018 6 Application Use Cases ì Symmetric Signatures (Authenticating an API, authenticating cookies, but not encrypting) ì HMAC – YES! ì GMAC – YES! ì But are you sure you don’t also want to be encrypting the data via AEAD? Secure Software Systems Fall 2018 7 Application Use Cases ì Asymmetric Encryption, i.e. Public Keys (Sending messages to many people, who are strangers, who need to decrypt and process it offline) ì NaCl / Libsodium – YES! ì Prefer elliptic curves over RSA ì Assuming curve parameters are safe, fewer ways to go wrong in implementation ì Fewer downgrade attacks possible Secure Software Systems Fall 2018 8 Application Use Cases ì Website security ì TLS – YES! ì BoringSSL (Google) ì LibreSSL (OpenBSD) ì Client-Server Application Security ì TLS! – YES! ì Consider hard-coding TLS 1.2+, ECDHE, AES-GCM (to prevent downgrade attacks) ì Consider self-signing and shipping certificate vs relying on certificate authority Secure Software Systems Fall 2018.
Recommended publications
  • GPU-Based Password Cracking on the Security of Password Hashing Schemes Regarding Advances in Graphics Processing Units
    Radboud University Nijmegen Faculty of Science Kerckhoffs Institute Master of Science Thesis GPU-based Password Cracking On the Security of Password Hashing Schemes regarding Advances in Graphics Processing Units by Martijn Sprengers [email protected] Supervisors: Dr. L. Batina (Radboud University Nijmegen) Ir. S. Hegt (KPMG IT Advisory) Ir. P. Ceelen (KPMG IT Advisory) Thesis number: 646 Final Version Abstract Since users rely on passwords to authenticate themselves to computer systems, ad- versaries attempt to recover those passwords. To prevent such a recovery, various password hashing schemes can be used to store passwords securely. However, recent advances in the graphics processing unit (GPU) hardware challenge the way we have to look at secure password storage. GPU's have proven to be suitable for crypto- graphic operations and provide a significant speedup in performance compared to traditional central processing units (CPU's). This research focuses on the security requirements and properties of prevalent pass- word hashing schemes. Moreover, we present a proof of concept that launches an exhaustive search attack on the MD5-crypt password hashing scheme using modern GPU's. We show that it is possible to achieve a performance of 880 000 hashes per second, using different optimization techniques. Therefore our implementation, executed on a typical GPU, is more than 30 times faster than equally priced CPU hardware. With this performance increase, `complex' passwords with a length of 8 characters are now becoming feasible to crack. In addition, we show that between 50% and 80% of the passwords in a leaked database could be recovered within 2 months of computation time on one Nvidia GeForce 295 GTX.
    [Show full text]
  • PHC: Status Quo
    PHC: status quo JP Aumasson @veorq / http://aumasson.jp academic background principal cryptographer at Kudelski Security, .ch applied crypto research and outreach BLAKE, BLAKE2, SipHash, NORX Crypto Coding Standard Password Hashing Competition Open Crypto Audit Project board member do you use passwords? this talk might interest you! Oct 2013 "hash" = 3DES-ECB( static key, password ) users' hint made the guess game easy... (credit Jeremi Gosney / Stricture Group) May 2014; "encrypted passwords" (?) last week that's only the reported/published cases Lesson if Adobe, eBay, and Avast fail to protect their users' passwords, what about others? users using "weak passwords"? ITsec people using "weak defenses"? developers using "weak hashes"? cryptographers, who never bothered? agenda 1. how (not) to protect passwords 2. the Password Hashing Competition (PHC) 3. the 24-2 PHC candidates 4. next steps, and how to contribute WARNING this is NOT about bikeshed topics as: password policies password managers password-strength meters will-technology-X-replace-passwords? 1. how (not) to protect passwords solution of the 60's store "password" or the modern alternative: obviously a bad idea (assuming the server and its DB are compromised) solution of the early 70's store hash("password") "one-way": can't be efficiently inverted vulnerable to: ● efficient dictionary attacks and bruteforce ● time-memory tradeoffs (rainbow tables, etc.) solution of the late 70's store hash("password", salt) "one-way": can't be efficiently inverted immune to time-memory tradeoffs vulnerable to: ● dictionary attacks and bruteforce (but has to be repeated for different hashes) solution of the 2000's store hash("password", salt, cost) "one-way": can't be efficiently inverted immune to time-memory tradeoffs inefficient dictionary attacks and bruteforce main ideas: ● be "slow" ● especially on attackers' hardware (GPU, FPGA) => exploit fast CPU memory access/writes PBKDF2 (Kaliski, 2000) NIST and PKCS standard in Truecrypt, iOS, etc.
    [Show full text]
  • Modern Password Security for System Designers What to Consider When Building a Password-Based Authentication System
    Modern password security for system designers What to consider when building a password-based authentication system By Ian Maddox and Kyle Moschetto, Google Cloud Solutions Architects This whitepaper describes and models modern password guidance and recommendations for the designers and engineers who create secure online applications. A related whitepaper, Password security ​ for users, offers guidance for end users. This whitepaper covers the wide range of options to consider ​ when building a password-based authentication system. It also establishes a set of user-focused recommendations for password policies and storage, including the balance of password strength and usability. The technology world has been trying to improve on the password since the early days of computing. Shared-knowledge authentication is problematic because information can fall into the wrong hands or be forgotten. The problem is magnified by systems that don't support real-world secure use cases and by the frequent decision of users to take shortcuts. According to a 2019 Yubico/Ponemon study, 69 percent of respondents admit to sharing passwords with ​ ​ their colleagues to access accounts. More than half of respondents (51 percent) reuse an average of five passwords across their business and personal accounts. Furthermore, two-factor authentication is not widely used, even though it adds protection beyond a username and password. Of the respondents, 67 percent don’t use any form of two-factor authentication in their personal life, and 55 percent don’t use it at work. Password systems often allow, or even encourage, users to use insecure passwords. Systems that allow only single-factor credentials and that implement ineffective security policies add to the problem.
    [Show full text]
  • Authentication Requirements in Cryptography
    Authentication Requirements In Cryptography Autolytic Micah scurrying narcotically and numerically, she perdures her contractility denigrate fustily. Utilitarian Thibaud attempt questioningly. Deviate and bleached Christie still carry-ons his Leonids sullenly. In the session key above are equivalent aes encrypt sensitive, requirements in authentication ciphersuite or on various vendors who the phy layer to the recipient passes the ciphertext Message authentication with fancy key implies message integrity. The requirements be considered as generic in the sense that they are ss technologies. Any inner authentication method employed authentication from the combine to the authentication server. The preceding paragraphs have endeavoured to present the complete set of concepts in a logical sequence of development. Chapter 11 Message Authentication Codes The luncheon of. MAC even to get obtain the confidentially part. AAA connection rm authentication the peers, as well as additional information about authenticators, roaming agreements, network policies and other network information. Since X509 is based on cross key cryptography the maintain of DOA used. Most often referred to hash functions has available protocols that it harder for vehicular networks. AWS KMS also lets you use all or part of the encryption context as the condition for a permission in a policy or grant. To authority confirms that authentication as a bad decision. This can be done by using it to support the secure transmission of a new secret key from the originator to the other party. There still appear to be many engineering details that have to be worked out before such a machine could be built. Most toward the web pages on the Internet require no authentication or authorization Encryption Encryption involves the crest of transforming data.
    [Show full text]
  • Nacl's Crypto Box in Hardware
    NaCl’s crypto_box in hardware Michael Hutter1;, Jürgen Schilling2, Peter Schwabe3, and Wolfgang Wieser2 ? 1 Rambus Cryptography Research Division 425 Market Street, 11th Floor, San Francisco, CA 94105, USA [email protected] 2 Graz University of Technology, IAIK Inffeldgasse 16a, A-8010, Graz, Austria [email protected],[email protected] 3 Radboud University Digital Security Group, PO Box 9010, 6500GL Nijmegen, The Netherlands [email protected] Abstract. This paper presents a low-resource hardware implementation of the widely used crypto_box function of the Networking and Cryptog- raphy library (NaCl). It supports the X25519 Diffie-Hellman key ex- change using Curve25519, the Salsa20 stream cipher, and the Poly1305 message authenticator. Our targeted application is a secure communica- tion between devices in the Internet of Things (IoT) and Internet servers. Such devices are highly resource-constrained and require carefully op- timized hardware implementations. We propose the first solution that enables 128-bit-secure public-key authenticated encryption on passively- powered IoT devices like WISP nodes. From a cryptographic point of view we thus make a first step to turn these devices into fully-fledged participants of Internet communication. Our crypto processor needs a silicon area of 14.6 kGEs and less than 40 µW of power at 1 MHz for a 130 nm low-leakage CMOS process technology. Keywords: Internet of Things, ASIC, Salsa20, Poly1305, Curve25519. 1 Introduction We need to empower computers with their own means of gathering in- formation, so they can see, hear and smell the world for themselves, in all its random glory. RFID and sensor technology enable computers to observe, identify and understand the world—without the limitations of human-entered data.
    [Show full text]
  • Comparing the Usability of Cryptographic Apis
    Comparing the Usability of Cryptographic APIs Yasemin Acar, Michael Backes, Sascha Fahl, Simson Garfinkel∗, Doowon Kimy, Michelle L. Mazureky, and Christian Stransky CISPA, Saarland University; ∗National Institute of Standards and Technology; yUniversity of Maryland, College Park Abstract—Potentially dangerous cryptography errors are well- Many researchers have used static and dynamic analysis documented in many applications. Conventional wisdom suggests techniques to identify and investigate cryptographic errors in that many of these errors are caused by cryptographic Appli- source code or binaries [2]–[6]. This approach is extremely cation Programming Interfaces (APIs) that are too complicated, have insecure defaults, or are poorly documented. To address this valuable for illustrating the pervasiveness of cryptographic problem, researchers have created several cryptographic libraries errors, and for identifying the kinds of errors seen most that they claim are more usable; however, none of these libraries frequently in practice, but it cannot reveal root causes. Conven- have been empirically evaluated for their ability to promote tional wisdom in the security community suggests these errors more secure development. This paper is the first to examine proliferate in large part because cryptography is so difficult for both how and why the design and resulting usability of different cryptographic libraries affects the security of code written with non-experts to get right. In particular, libraries and Application them, with the goal of understanding how to build effective Programming Interfaces (APIs) are widely seen as being future libraries. We conducted a controlled experiment in which complex, with many confusing options and poorly chosen 256 Python developers recruited from GitHub attempt common defaults (e.g.
    [Show full text]
  • Package 'Bcrypt'
    Package ‘bcrypt’ January 26, 2018 Type Package Title 'Blowfish' Password Hashing Algorithm Version 1.1 Description Bindings to the 'blowfish' password hashing algorithm derived from the 'OpenBSD' implementation. URL https://github.com/jeroen/bcrypt https://www.openbsd.org/papers/bcrypt-paper.pdf BugReports https://github.com/jeroen/bcrypt/issues License BSD_2_clause + file LICENSE Imports openssl RoxygenNote 6.0.1.9000 Suggests spelling Language en-US Encoding UTF-8 NeedsCompilation yes Author Jeroen Ooms [cre, aut], Damien Miller [cph], Niels Provos [cph] Maintainer Jeroen Ooms <[email protected]> Repository CRAN Date/Publication 2018-01-26 09:08:42 UTC R topics documented: bcrypt . .2 Index 4 1 2 bcrypt bcrypt Bcrypt password hashing Description Bcrypt is used for secure password hashing. The main difference with regular digest algorithms such as MD5 or SHA256 is that the bcrypt algorithm is specifically designed to be CPU intensive in order to protect against brute force attacks. The exact complexity of the algorithm is configurable via the log_rounds parameter. The interface is fully compatible with the Python one. Usage gensalt(log_rounds = 12) hashpw(password, salt = gensalt()) checkpw(password, hash) Arguments log_rounds integer between 4 and 31 that defines the complexity of the hashing, increasing the cost as 2^log_rounds. password the message (password) to encrypt salt a salt generated with gensalt. hash the previously generated bcrypt hash to verify Details The hashpw function calculates a hash from a password using a random salt. Validating the hash is done by rehashing the password using the hash as a salt. The checkpw function is a simple wrapper that does exactly this.
    [Show full text]
  • Pynacl Release 1.4.0.Dev1
    PyNaCl Release 1.4.0.dev1 unknown Jun 02, 2019 CONTENTS 1 Features 3 2 Contents 5 2.1 Public Key Encryption..........................................5 2.2 Secret Key Encryption..........................................9 2.3 Digital Signatures............................................ 12 2.4 Hashing.................................................. 18 2.5 Password hashing............................................ 20 3 Support Features 25 3.1 Encoders................................................. 25 3.2 Exceptions................................................ 26 3.3 Utilities.................................................. 26 3.4 nacl.hash................................................. 27 3.5 nacl.pwhash............................................... 28 3.6 nacl.hashlib................................................ 33 3.7 Installation................................................ 34 3.8 Doing A Release............................................. 34 3.9 Reference vectors............................................ 35 3.10 Changelog................................................ 48 3.11 Indices and tables............................................ 50 Bibliography 51 Python Module Index 53 Index 55 i ii PyNaCl, Release 1.4.0.dev1 PyNaCl is a Python binding to libsodium, which is a fork of the Networking and Cryptography library. These libraries have a stated goal of improving usability, security and speed. It supports Python 2.7 and 3.4+ as well as PyPy 2.6+. CONTENTS 1 PyNaCl, Release 1.4.0.dev1 2 CONTENTS CHAPTER ONE
    [Show full text]
  • Bcrypt Recommended Salt Rounds
    Bcrypt Recommended Salt Rounds Will fraternised hurriedly while andesitic Towney hand-in impudently or melts unpractically. Naggy and Anorecticunbidden Gusand fractionalexpropriate Rodge while always filigreed batten Adolph radiantly felicitates and her channel conjugates his epacrises. sooner and munite home. You end up to create the salt rounds, being very easy it may be found a password they are returned as a way to provide a new versions are closed Not return be confused with encryption, that your user database even in. Using bcrypt is recommended over time consuming to build my employers, salt rounds by adding salt part of salts an obvious vector. What does that mean exactly? Building have secure hash function out of elementary operations is forthcoming from easy. The bcrypt hashing function allows us to build a password security platform that can. Sha algorithms will detect unusual activity we store all incredibly fast enough information as salt. Please try dirrerent combinations of bcrypt. Several bcrypt libraries use 12 rounds 212 iterations as the default setting. Bcrypt-ruby and supervise other implementations set but to 10 meaning 2 key expansion rounds That's encompass not enjoy When bcrypt was. Store hash in your password DB. Bcrypt to bcrypt is recommended you should really. With the old password encryption, especially when you need to traverse thousands of samples. NET Core application that implements the management user frontend. We do not store password as plain text in the database, the passwords themselves can be a prized spoil of war: users are human beings, or sometimes referred to as a rainbow table.
    [Show full text]
  • UGRD 2015 Spring Bugg Chris.Pdf (464.4Kb)
    We could consider using the Mighty Cracker Logo located in the Network Folder MIGHTY CRACKER Chris Bugg Chris Hamm Jon Wright Nick Baum Password Security • Password security is important. • Users • Weak and/or reused passwords • Developers and Admins • Choose insecure storage algorithms. • Mighty Cracker • Show real world impact of poor password security. OVERVIEW • We made a hash cracker. • Passwords are stored as hashes to protect them from intruders. • Our program uses several methods to ‘crack’ those hashes. • Networking • Spread work to multiple machines. • Cross Platform OTHER HASH CRACKING PRODUCTS • Hashcat • Cain and Abel • John the Ripper • THC-Hydra • Ophcrack • Network support is rare. WHAT IS HASHING • A way to encode a password to help protect it. • A mathematical one-way function. • MD5 hash • cf4ff726403b8a992fd43e09dd7b5717 • SHA-256 hash • 951e689364c979cc3aa17e6b0022ce6e4d0e3200d1c22dd68492c172241e0623 SUPPORTED HASHING ALGORITHMS • Current Algorithms • MD5 • SHA-1 • SHA-224 • SHA-256 • SHA-384 • SHA-512 WAYS TO CRACK • Cracking Modes • Single User • Network Mode • Methods of Cracking: • Brute Force • Dictionary • Rainbow Table • GUI or Console BRUTE FORCE • Systematically checking all possible keys until the correct one is found. • Worst case this would transverse the entire search space. • Slowest but will always find the solution if given enough time. DICTIONARY ATTACK • List of common passwords from leaks/hacks. • Many people choose common passwords • Written works of Shakespeare ~66,000 words • Oxford English Dictionary ~290,000 words • Small dictionary = 900,000 words • Medium dictionary = 14 million words • Large dictionary = 1.2 billion words RAINBOW TABLE • Can’t store all possible hash/key combinations. • 16 character key = 10^40th combinations • 10^50th atoms on earth • Rainbow tables • Reduced storage.
    [Show full text]
  • Libsodium V1.0.12 and V1.0.13 Security Assessment
    Libsodium v1.0.12 and v1.0.13 Security Assessment Copyright © 2017 Cryptography Engineering LLC Contents 1 Executive Summary 2 2 Introduction 3 2.1 Scope . .3 2.2 Approach . .4 2.3 Classification and Severity Rating . .4 3 Findings 6 3.1 Summary of Findings . .6 3.2 Overview of Cryptographic Design . .7 3.3 Static Analysis Results . 11 3.4 Dynamic Analysis Results . 11 3.5 Detailed Findings . 12 3.5.1 SD-01: Randomness source on Windows based on unofficial APIs only 12 3.5.2 SD-02: Possible null pointer dereference in key exchange API . 12 3.5.3 SD-03: Potential issues with abort() to terminate program on error conditions . 13 3.5.4 SD-04: Potential risks with the custom RNG API . 13 3.5.5 SD-05: Missing APIs in the libsodium documentation . 14 3.5.6 SD-06: Lack of elliptic curves at higher security levels . 14 3.5.7 Formal Verification (In progress) . 15 3.5.8 Diffs between version 1.0.12 and 1.0.13 . 15 4 Conclusions 17 1 Executive Summary Libsodium1 is an open-source, easy-to-use fork of the C-language NaCl crypto library that is portable, cross-platform and provides many common cryptographic functions. These include public-key encryption, signatures, key derivation, password hashing, message authentication codes, stream ciphers, pseudo-random number generators, random number generation, and support for elliptic curves such as Curve25519. This review was funded by Private Internet AccessTM (PIA), although PIA did not direct the review or modify the results.
    [Show full text]
  • Implementation and Performance Analysis of PBKDF2, Bcrypt, Scrypt Algorithms
    66 Int'l Conf. Wireless Networks | ICWN'16 | Implementation and Performance Analysis of PBKDF2, Bcrypt, Scrypt Algorithms Levent Ertaul, Manpreet Kaur, Venkata Arun Kumar R Gudise CSU East Bay, Hayward, CA, USA. [email protected], [email protected], [email protected] Abstract- With the increase in mobile wireless or data lookup. Whereas, Cryptographic hash functions are technologies, security breaches are also increasing. It has used for building blocks for HMACs which provides become critical to safeguard our sensitive information message authentication. They ensure integrity of the data from the wrongdoers. So, having strong password is that is transmitted. Collision free hash function is the one pivotal. As almost every website needs you to login and which can never have same hashes of different output. If a create a password, it’s tempting to use same password and b are inputs such that H (a) =H (b), and a b. for numerous websites like banks, shopping and social User chosen passwords shall not be used directly as networking websites. This way we are making our cryptographic keys as they have low entropy and information easily accessible to hackers. Hence, we need randomness properties [2].Password is the secret value from a strong application for password security and which the cryptographic key can be generated. Figure 1 management. In this paper, we are going to compare the shows the statics of increasing cybercrime every year. Hence performance of 3 key derivation algorithms, namely, there is a need for strong key generation algorithms which PBKDF2 (Password Based Key Derivation Function), can generate the keys which are nearly impossible for the Bcrypt and Scrypt.
    [Show full text]