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 is a contributor at AlgoHay. We are committed to providing well-researched, accurate, and valuable content to our readers.
You May Also Like
Efficient Algorithms for Problem Solving
Efficient Algorithms for Problem Solving In today's digital age, algorithms have become the backbone of modern technology, driving everything from...
Algorithm Analysis Asymptotic Notation
Understanding Algorithm Efficiency Through Asymptotic Notations In the world of computing, the speed and scalability of algorithms determine whether a...
The Science of Speed: Mastering Algorithm Efficiency in Modern Computing
The Science of Speed: Mastering Algorithm Efficiency in Modern Computing In an era where milliseconds can determine success or failure,...
Prepping for Q-Day: A Guide to Quantum Readiness
The Threat of Q-Day Q-Day refers to the hypothetical day when quantum computers become powerful enough to break current cryptographic...
Breaking the Code: The Quantum Computing Threat to Bitcoin
Calibrating AI to Identify Heart Disease
