Repository navigation
Add ML-KEM composite KEM - #5686
falko-strenzke wants to merge 15 commits into
Conversation
d6aaad5 to
8a7a5f7
Compare
In principle blinding during encryption might be useful, and possibly that's why the argument is there. TBH I don't recall. It does seem to be the case that currently no implementation uses it, and since the encryption operation itself is provided an RNG any necessary blinding setup could just be deferred to the first invocation. Likely this argument could be removed entirely. I would suggest rather than modifying the KEM interface in this way, take advantage of the fact that RSA's create_encryption_op ignores the RNG object anyway, pass a |
Absolutely makes sense, I applied that idea. |
|
There are still CI failures apparently stemming from current master branch. |
reneme
left a comment
There was a problem hiding this comment.
Not a full review. Just some up-front comments.
reneme
left a comment
There was a problem hiding this comment.
Sorry for the fairly shallow high-level comments again. I hope I'll have more time to do a proper review in the next few days.
|
@falko-strenzke On a general note: We should look into consolidating support for this IETF draft with the existing facilities in the Following this idea, your MLKEM-Composite implementation should derive from The usage of generic adapters (for RSA and for ECDH) allow the composition to be implemented exclusively based on KEMs, without explicit handling of specific traditional algorithms. Also, such an implementation could be easily extensible to other KEMs in the future (e.g. FrodoKEM or HQC). The existing I would suggest a design like so:
I could take over the relevant work in the mentioned base classes and the TLS hybrid implementation. |
|
@falko-strenzke Therefore, it would be really nice if the interface of the composite ML-KEM private key would allow the processing of such "custom" private keys. I could imagine adding an additional constructor like: MLKEM_Composite_PrivateKey(MLKEM_Composite_Param::id_t id, std::unique_ptr<Botan::PrivateKey> mlkem_privkey, std::unique_ptr<Botan::PrivateKey> traditional_privkey);The information, currently obtained via dynamic casting the private key pointers, must be derived from the MLKEM_Composite_Param in this case. What do you think? |
|
@falko-strenzke See #5715 please. I'm currently working on a quick'n'dirty retrofit of your work on this branch onto the changes in #5715 to see if it provides the required flexibility to accommodate this implementation of the LAMPS draft. I'll share it with you once I have something working. |
|
@falko-strenzke I took the liberty and refactored your patch (mostly This also addresses plenty of the suggestions I added above. But most notably, it gets rid of almost all low-level algorithm-specific handling by reusing existing concepts. I'd appreciate if you could have a read-through my refactorings and pull them into this PR. |
@reneme As I wrote in #5715, I am not entirely convinced of the multi-algorithm framework that you rebased the implementation onto. As a plus, it reduces the code size in |
Well, with @reneme 's new proposal, I think that would or should be taken care of by the hybridization framework. @reneme Is that already the case? |
Pretty much. There are two central things to that:
The second point might need some work. The first point should be taken care of already. |
|
For the RSA composites, there seems to be the same issue as mentioned for #5451 that the RSA key sizes are not bound to the modulus size specified by the composite OID. I might be wrong here, please check! |
6928fcd to
07a7949
Compare
You are correct as far as I can see, but I first want to adopt @reneme 's refactoring before addressing it. |
I just made a diff of our branches. After seeing many unrelated differences, I rebased on master (where I rather should have rebased onto #5715, as I saw afterwards), and still have many unrelated differences. Coud you @reneme rebase your branch on current master (4695b4a is what this PR is based on now), too , so that we have a clean diff? |
e0bf430 to
60297e3
Compare
Yes, but not https://github.com/reneme/botan/tree/falko/mlkem-composite as far as I could see.. But no problem, I now adopted the changes from that branch and should now have addressed all your review comments. Maybe you want to look over it again. |
7fc3565 to
34b5f97
Compare
Now done. We have the same key size and EC group checks as for ML-DSA composites. |
Before, the implementation allowed for hybridization of an arbitrary number of algorithms (n>=2). This introduced unnecessary complexity given that is pretty unlikely that we'll see general-purpose hybridization of more than two algorithms. Additionally, this lifts the KeyExchange-to-KeyEncapsulation adapter from the concrete TLS 1.3 hybridization implementation into the base class so that it may be reused by other concrete hybridization implementations. Most notably by draft-ietf-lamps-pq-composite-kem.
Before, the Hybrid_KEM_PublicKey contained an unfortunate default c'tor that would be silently called in the most-derived class to initialize the class in a diamond-shape virtual inhertance relationship. This resulted in unexpected internal states of the public key portion of the object. Instead, by removing the default c'tor, we now force a more verbose but easier to understand workaround on the user.
This lets user explicitly unwrap the wrapped KEX-key as necessary.
For TLS 1.3 it is currently just an implementation detail. But for the Composite ML-KEM implementation it will have to become accessible via the public API.
The old name 'hybrid_public_key.h' was too generic and might become ambiguouos in the future.
use module sha3 Co-authored-by: René Meusel <github@renemeusel.de>
d5fa46b to
fc24b08
Compare
| ecies | ||
| dh | ||
| ecdh | ||
| mlkem-composite |
There was a problem hiding this comment.
Do we know that Composite-ML KEM will be recommended with the upcoming TR? Because, as you correctly state in the cryptodoc (sehlen-bsi/botan-docs#296), Composite ML-KEM is not fully TR compatible.
@sehlen-bsi Any insights?

Integration of ML-KEM composites according to draft-ietf-lamps-pq-composite-kem
Already solved issues
The following problem arises in the context of the MLKEM-composite implementation.It is based on the inconsistency between these two functions defined in
pk_keys.h:The problem is that the implementation ofcreate_kem_encryption_opinMLKEM_Composite_PublicKeyrequires an RNG to internally callcreate_encryption_op()for RSA.Thus inside the constructor of the
MLKEM_Composite_Encapsulation_Operation, an RNG is needed to instantiate the traditional encryption operation.It is not apparent to me whycreate_encryption_op()should require an RNG in the first place – and I didn't investigate. But generally, contrary to a decryption OP, it should not require randomization in setting up precomputations due to a side channel countermeasure.The only reasonable solution that I came to is to add an optional RNG argument to the interface:This also requires a new function in the FFI interface. I am quite certain that this exact approach to the problem will not find acceptance. It's purpose is to make things work for now and provide a basis for the discussion of the proper solution.The only alternative I could think of would be to let the constructor ofMLKEM_Composite_Encapsulation_Operationto store the encoded public key in the instance and create the RSA encryption operation during every KEM encapsulation. This would be a both a strain on memory and performance, thus I discarded this idea.