Add Hybrid Public Key Encryption (HPKE) API Support#1061
Open
sylph01 wants to merge 45 commits into
Open
Conversation
from now on this needs OpenSSL 3.2 to compile
works only with hpke.h that exposes OSSL_HPKE_CTX
The current longest possible public key size is 133 bytes, according to RFC 9180 section 7.1
- HPKE::Context.new that takes mode, role, and suite - HPKE::Context now keeps track of which KEM/KDF/AEAD it uses under instance variable - HPKE.keygen_with_suite
In this patch I also moved the `attr_reader` definitions of kem/kdf/aead_ids into C code
I am very iffy about this. Is there a safer way to handle this allocation?
The last version was not working.... - Sender and Receiver contexts get different classes - Sender gets only sender APIs, Receiver gets only receiver APIs - Sender and Receiver need Suite to initialize - Removed old Context initialization API
- Remove debug functions - 2 space indentation -> 4 space indentation
It's obvious for people who would edit this code...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch introduces Hybrid Public Key Encryption (HPKE; RFC 9180) through OpenSSL's HPKE APIs ( https://docs.openssl.org/3.5/man3/OSSL_HPKE_CTX_new/ ), added in OpenSSL 3.2.0.
Usage
APIs
OpenSSL::HPKE::Suitenew: Instantiate cipher suite with KEM, KDF, and AEAD identifiers listed in RFC 9180new_with_names: Instantiate cipher suite with pre-defined names. Uses the list of KEMs, KDFs, AEADs listed in RFC 9180.OpenSSL::HPKEkeygen: GenerateOpenSSL::PKeyprivate key with the specified KEM, KDF, and AEAD ID.OSSL_HPKE_keygen()API.keygen_with_suite: GenerateOpenSSL::PKeyprivate key with the specified cipher suiteThese are more like utility functions so if they look extraneous they can be removed in favor of using
OpenSSL::PKeyto generate corresponding keys.OpenSSL::HPKE::Context::SenderandOpenSSL::HPKE::Context::Receivernew: Instantiate HPKE Context.:basemode only; I wanted to let the maintainers see this pull request before adding:auth,:psk, and:auth_pskmodesOpenSSL::HPKE::Context::Senderencap: Encapsulates key into the specified public key. Takes receiver's public key andinfo(application context information)seal: Using the encapsulated key, seal message into ciphertext. Takesaad(additional authenticated data) and ciphertext itself.OpenSSL::HPKE::Context::Receiverdecap: Decapsulates the key using the private key. Takes the encapsulation, private key, andinfo(application context information).open: Using the decapsulated key, decrypt the ciphertext. Takesaadand ciphertext.Availability