Sandwich: An Open-Source Modern Cryptography Library

by James Howe. Posted on Aug 8, 2023
“a still life painting of a sandwich on a table in the style of Paul Cézanne.

“a still life painting of a sandwich on a table in the style of Paul Cézanne.

Sandwich: An Open-Source Modern Cryptography Library

At SandboxAQ, many of our products are centered around the core belief that crypto-agility is the future of modern cryptography management. To help the community achieve this goal, developers need a single cryptography framework, for any leading language, that, at the same time, makes their applications crypto-agile. In this blogpost, we’ll describe how our new open source library accomplishes this goal.

Today we are releasing Sandwich. Sandwich is a framework we’ve developed that is a meta-library: with a multi-language, easy to use API at the front-end, which connects to trusted and well-established cryptography libraries at the back-end, without any manual configurations from the user, enabling a simple way to switch between protocols or libraries; this is a key tool to achieve crypto-agility.

Introduction

Modern cryptography management and crypto-agility are becoming increasingly essential for businesses of all sizes. Crypto-agility is the ability to support rapid switching and adaptations of cryptographic primitives and algorithms without making significant changes to the system’s infrastructure, and without exposure to unacceptable business continuity risks. Examples of this include the switching away from an algorithm with a known vulnerability or switching to an implementation with a higher security level.

These features enable developers to have more visibility and control of the cryptography they are using and therefore achieve more agility when deciding what cryptography they use and where they want to use it. Being crypto-agile also means organizations ensure a rapid response to cryptographic threats. This has also been a big driver for the NIST NCCoE project for migrating to Post-Quantum Cryptography.

Sandwich provides a simple, unified, and hard to misuse API for developers to use cryptographic protocols of their choice in their applications. Sandwich supports multiple languages (C/C++, Rust, Python, Go) and multiple cryptography libraries (OpenSSL and BoringSSL) and in particular supports libOQS meaning Sandwich easily enables post-quantum cryptography.

As a result, the developers in your organization, regardless of how they build their solutions, can easily adopt it.

The Problem

Implementing cryptography is hard. It takes teams of developers significant amounts of time and effort to design, implement, and test. And for individuals and small teams, this is a tough goal to attain. For any groups of developers, integrating or implementing cryptography badly opens up possibilities for bugs, errors, and even exploits and, moreover, current solutions to these issues on the marketplace are hard to integrate and can be expensive. This will only be exacerbated by the need to transition to the new upcoming Post-Quantum Cryptography (PQC) standards.

How Can Sandwich Help?

The aim of Sandwich is to remove these barriers to entry. We achieve this with three major design goals:

  1. to be simple to use, with a simple unified API,
  2. to support multiple languages, and
  3. to be useful, by supporting popular and trusted cryptography libraries.

Our first design goal was achieved by making Sandwich with a simple, unified API, which means using its supported cryptography libraries is straightforward. It’s also simple to switch between the libraries and/or the protocols you want to use.

Our second design goal, for our language support, was achieved by providing support for C/C++, Rust, Python, and Go, meaning Sandwich can be integrated into a wide variety of different projects.

Essentially, this means you can realize your project using popular cryptography libraries in languages you prefer to work with.

Moreover, development teams can use the languages they prefer and still be able to debug each other’s code. With the Sandwich configurations, users working in, e.g., Python, who are experiencing issues, can send their generic Sandwich configuration to a different developer who is using Sandwich in, e.g., Rust, who can use this configuration to recreate their issues and help debug their code. The error support provided in Sandwich is consistent across the languages we support, where the error handling API exposes as much detail as possible. Currently, Sandwich supports Linux and MacOS.

Our third design goal is achieved by supporting two of the biggest and most popular cryptography libraries used today, OpenSSL and BoringSSL. They provide essential encryption and services for secure communications to millions of users for websites, devices, and applications. In addition to these, we integrate a popular post-quantum cryptography library, libOQS, meaning that OpenSSL and BoringSSL can now be used to experiment with post-quantum cryptography schemes such as Kyber and Dilithium. This backend is written in Rust, adding to the overall trust and confidence of using Sandwich, via Rust’s features such as memory safety.

The overall architecture of Sandwich.

The overall architecture of Sandwich.

How Sandwich Works

One of our main goals for Sandwich is to abstract away many of the choices developers face when they add cryptography to their projects, enabling future centralized management and monitoring, and empowering organizations with the data they need to effectively be agile and manage risk.

In terms of how Sandwich works, first the developer decides which protocol they want to use (e.g., TLS 1.3) as well as its implementation (e.g., OpenSSL+libOQS), which is then composed as a Sandwich object (in this case, a secure tunnel).

The protocols and implementations that are available at runtime are dependent on the choices that were made when compiling the particular sandwich library. In effect, developers will be able to compose their own sandwich, for choices and options they would like to have at runtime, giving the user the ability to change configurations without having to re-compile their code.

Compared to the way we currently use cryptography, which is more ad-hoc, this is a much simpler process to creating a cryptographic object (e.g., creating a secure tunnel) and works towards enabling crypto-agility for the open source community.

Our Future Vision For Sandwich

Our current version of Sandwich supports two major cryptographic libraries, which allow use of protocols such as TLS, and adds integration to libOQS, meaning these protocols can now run with post-quantum security.

In the long run, we aim to continue to develop Sandwich. One of our aims is to provide sandwiches with one or many stacked layers (i.e., providing access to cryptography at different abstraction levels). At a high-level, this allows a developer to access smaller sandwiches (like paninis) to access fundamental cryptographic primitives, or larger sandwiches (like mega-stacked burgers) to access functionalities like VPNs, Authentication, or Key Management Services (KMS).

Conclusion

To summarize, Sandwich helps developers modernize their cryptography and drive to crypto-agility. Sandwich can enable organizations to lay the groundwork that will allow them to get measurement and agility across their cryptography usage and gives them the tools they need to engage with their developers. The net result of this is quicker development, more agility, and compliance with best practices and with an extra bonus of being ready for PQC adoption.

As a part of Sandwich’s continuous develop, we will keep adding features and maintaining APIs. In the future, we will be adding more functionality to Sandwich, in particular for key-management, and our vision is to aid and enable agility for modern cryptography management for the open-source community.

We welcome feedback, bug reports, feature requests, and contributions from the community. You can find the Sandwich documentation at https://sandbox-quantum.github.io/sandwich/, and stay tuned for updates via the GitHub repository.