This article provides a detailed look at the journey of integrating verified cryptographic infrastructure into Python, a popular programming language. The process involved 2.5 years of work, with the help of various contributors from the Python and verified cryptographic communities.

The Problem: A Recent CVE in SHA3

In November 2022, an issue was opened on Python’s GitHub repository, raising concerns about the implementation of SHA3, which was vulnerable to a recent CVE. The issue was to ensure that Python’s hash-related infrastructure was secured.

The Solution: Verified Cryptographic Library HACL*

The issue was addressed by introducing a verified cryptographic library called HACL*, which provided a secure alternative to the SHA3 implementation. HACL* was designed to be a generic and modular library that could be easily integrated into Python.

Key Features of HACL*

  • 15,000 lines of verified C code
  • Automated pulling of newer versions from the upstream HACL* repository
  • Implementation of new features for SHA3, including additional modes for the Blake2 family of algorithms
  • Strict abstraction patterns to deal with build system difficulties
  • Proper error management, including allocation failures
  • Instantiating HACL’s generic “streaming” functionality with the HMAC algorithm

A Primer on Streaming APIs

Many cryptographic algorithms are block algorithms, which assume input is provided block by block. However, this can lead to complex invariants and make it difficult to manipulate long-lived state.

Streaming APIs, on the other hand, allow clients to provide inputs of any length, and the library takes care of buffering the input. A streaming API typically allows extracting intermediary hashes without invalidating the state.

Challenges in Implementing Streaming APIs

  • Complexity of underlying block algorithms
  • Need to handle pre-inputs, allocation failures, and other edge cases
  • Difficulty in ensuring that the implementation is correct and secure

Fully Generic Verification

Fully generic verification involves capturing the properties of a block algorithm using dependent types. This allows for the creation of a generic streaming construction that can be applied to any block algorithm.

The first hitch is that there’s a significant delta between the abstract definition of block algorithms and the actual implementation.

Proposing a Solution

A possible solution is to use a well-known pattern, such as the “C abstract struct” pattern, to define an abstract type in C.

news

news is a contributor at AlgoHay. We are committed to providing well-researched, accurate, and valuable content to our readers.

← Previous Post

Breaking the Code: The Quantum Computing Threat to Bitcoin

Next Post →

Calibrating AI to Identify Heart Disease

Related Articles

About | Contact | Privacy Policy | Terms of Service | Disclaimer | Cookie Policy
© 2026 AlgoHay. All rights reserved.