Your Engines: Dynamically Loadable Contemporary Crypto
Total Page:16
File Type:pdf, Size:1020Kb
Start your ENGINEs: dynamically loadable contemporary crypto Nicola Tuveri Billy Bob Brumley Tampere University, Tampere, Finland Tampere University, Tampere, Finland Abstract—Software ever-increasingly relies on building blocks with respect to this paper, the NaCl [1] project—and its implemented by security libraries, which provide access to fork libsodium2—are especially relevant, as they aim at evolving standards, protocols, and cryptographic primitives. providing practical and efficient strong confidentiality and These libraries are often subject to complex development models and long decision-making processes, which limit the ability of integrity with a special emphasis on the simplicity of the contributors to participate in the development process, hinder provided programming interface. Unfortunately, after years, the deployment of scientific results and pose challenges for OS we notice that, even if gathering momentum and being adopted maintainers. In this paper, focusing on OpenSSL as a de-facto in various new projects, this approach fails in meeting the standard, we analyze these limits, their impact on the security needs of mainstream projects. of modern systems, and their significance for researchers. We propose the OpenSSL ENGINE API as a tool in a framework Another related development sprouting off this research is to overcome these limits, describing how it fits in the OpenSSL HACL*3 [2], a verified cryptographic library that implements architecture, its features, and a technical review of its internals. the NaCl API: it provides mathematical guarantees on memory We evaluate our methodology by instantiating libsuola, a new safety, timing side-channel safety and functional correctness ENGINE providing support for emerging cryptographic standards (with respect to the published primitive specification), while such as X25519 and Ed25519 for currently deployed versions of OpenSSL, performing benchmarks to demonstrate the viability producing portable C code that is as fast as state-of-the-art C and benefits. The results confirm that the ENGINE API offers (1) implementations. an ideal architecture to address wide-ranging security concerns; Alongside the development of NaCl, research efforts were (2) a valuable tool to enhance future research by easing testing also spent on the related SUPERCOP benchmarking suite and facilitating the dissemination of novel results in real-world systems; and (3) a means to bridge the gaps between research as part of the eBACS project [3] for the benchmarking of results and currently deployed systems. cryptographic systems: many researchers from industry and academia submitted new cryptographic primitives or alterna- I. INTRODUCTION tive implementations for benchmarking. Included submissions Following current common best practices for the develop- are benchmarked across different architectures and toolchains ment of secure systems, most applications rely on crypto- and undergo several automated tests. But still, most of these graphic primitives for which widely accepted standards have programming and scientific efforts fail to reach widespread been published after extensive studies to ensure that breaking adoption through mainstream libraries. We defer to Section II them is believed computationally infeasible. As the available for an in-depth analysis of the limits of the OpenSSL project computation power increases and new attacks and algorithms from the point of view of researchers that might help ex- to improve the performance of theoretic attacks are developed, plaining this gap. In here, to further substantiate the existence these standards are periodically revised to raise the security and relevance of this gap, we focus on the implementation of level of the recommended primitives. emerging cryptographic standards based on Curve25519 [4, 5]. Considering the complexity of protocols and algorithms X25519, the Diffie-Hellman cryptosystem, originally released and the number of potential pitfalls concerning details at in 2005, promises, due to the properties of the underlying every level of abstraction, the software implementation of curve design, simpler and faster implementations, with en- such evolving standards is a daunting and complex task and hanced resistance to side-channel attacks. Ed25519, formally application developers are strongly advised not to implement introduced in 2011, is a digital signature system based on their own crypto but to rely on existing well-established the twisted Edwards equivalent of Curve25519. It delivers fast cryptographic libraries, among which OpenSSL1 is the most digital signature generation and verification, short signatures, widely adopted. Still, in addition to the complexity of their and enhanced resistance to side-channel attacks. programming interfaces, bugs and defects in these libraries These cryptosystems have since gathered momentum, gain- are often the cause of cryptographic failures in the security ing official support in OpenSSH in 2014, in BoringSSL in layer of modern information systems. 2015, in the Google Chrome Internet browser TLS/QUIC Previous research focused on the development of new cryp- protocol support in April 2016, and finally becoming part tographic software libraries as a solution to these problems: 2https://libsodium.org/ 1https://www.openssl.org 3https://github.com/mitls/hacl-star of IETF RFC 7748 [6] (X25519) in January 2016 and RFC Outline: Section II presents further claims motivating our 8032 [7] (Ed25519) in January 2017, and becoming officially contribution. Section III contains an analysis of the OpenSSL recommended for implementations of TLS 1.3 (RFC 8446 [8]) architecture and the ENGINE API. Section IV presents lib- and earlier versions (RFC 8422 [9]) since August 2018. suola, an ENGINE we developed to demonstrate how to use OpenSSL officially added support for X25519 in August the ENGINE API as a framework to offer alternative or miss- 2016, with release 1.1.0, while Ed25519 support landed only ing implementations in OpenSSL. In Section V we present and very recently in a release version, after a long development evaluate experimental results comparing the default implemen- cycle, with the release of 1.1.1 on September 11, 2018. tation of X25519 and Ed25519 (or the lack thereof) against While implementation details are examined in Section III-D, the implementations provided through our custom ENGINE here we highlight that the original implementation chosen and analyze the limits of our proposed methodology and how by the OpenSSL development team favored portability over it addresses the concerns exposed in Section II. Section VI optimization, and as a result using these cryptosystems in presents a brief analysis of related work, focusing on the applications built on top of OpenSSL, do not always yield mechanisms deployed by other security libraries, frameworks the expected performance in comparison with other elliptic and operating systems to allow the transparent adoption of curve (EC) implementations (e.g., NIST P-256). alternative cryptographic implementations. We conclude in This does not seem to be a consequence of a lack of trusted Section VII. optimized implementations for the most widespread architec- tures supported by OpenSSL, as the mentioned SUPERCOP II. MOTIVATION project includes several implementations tested on different As mentioned in Section I, this work is partially motivated architectures and alternative libraries like libsodium and by the rigidity of currently deployed, ubiquitous cryptography BoringSSL ship optimized implementations for popular ar- software libraries. This rigidity impacts real-world security chitectures. It rather shows that new research, even after at least via two avenues, which this section summarizes: it the time required for gaining trust and widespread adoption amplifies software assurance issues due to the small circle in other mainstream projects and standards, still requires a of contributors, and furthermore restricts the practical ability long additional time to be included in OpenSSL, affecting of OS vendors to provide predictable and steady support researchers, developers and users. throughout the product life cycle. Our contribution: To address these limits, in this work: While our intent is not to belittle the efforts of the OpenSSL (1) we present an analysis of the OpenSSL ENGINE API project, to motivate our contributions, here we briefly highlight and its benefits for bridging gaps between cryptographic re- some limits of the project from the point of view of researchers search and practical real-world implementations of cryptosys- that might explain the gap highlighted in the introduction: tems—the analysis in itself is novel, as available resources ap- (1) lack of unified quality reference documentation on the pear to be outdated; (2) we develop an ENGINE to demonstrate overall software architecture of the library, on API design how to use the ENGINE API as a framework to transparently choices, and frequently on the details of public and inter- integrate alternative implementations or new functionality in nal functions and data structures; (2) complex ad-hoc build OpenSSL, making them available to existing applications; system; (3) strong constraints on the choice of programming (3) we evaluate experimental results, by benchmarking our languages (C and custom “augmented” ASM syntax) and libsuola ENGINE, demonstrating the viability and the coding style; (4) being a complex and huge project ongoing benefits of the proposed solution across different versions of very