Skip to content

Add support for mlkem768x25519 hybrid key exchange#137

Open
loganaden wants to merge 5 commits intoopeniked:masterfrom
cyberstormdotmu:mlkem768x25519
Open

Add support for mlkem768x25519 hybrid key exchange#137
loganaden wants to merge 5 commits intoopeniked:masterfrom
cyberstormdotmu:mlkem768x25519

Conversation

@loganaden
Copy link

which resists to Quantum computers.

which resists to Quantum computers.

Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
Signed-off-by: Jaykishan Mutkawoa <jay@cyberstorm.mu>
Signed-off-by: Kavish Nadan <kn@cyberstorm.mu>
Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
Signed-off-by: Jaykishan Mutkawoa <jay@cyberstorm.mu>
Signed-off-by: Kavish Nadan <kn@cyberstorm.mu>
Copy link
Member

@tobhe tobhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! Most of it already looks pretty good. I left a bunch of questions in-line.

cp += crypto_kem_mlkem768_PUBLICKEYBYTES;
}
crypto_scalarmult_curve25519(shared, curve25519->secret, cp);
/* result is hash of concatenation of KEM key and DH shared secret */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the case of ML-KEM we want to include the public keys in the hash too in order to achieve something close to MAL-BIND-K-PK security as defined in https://eprint.iacr.org/2023/1933.pdf.

https://durumcrustulum.com/2024/02/24/how-to-hold-kems/ provides a good summary.

Copy link
Contributor

@mfriedl mfriedl Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like

        if (kemke->initiator) {
                /* we generate public key */
                kempub = kemke->public;
  ....
        } else {
                /* peer sends public key */
                kempub = cp;
...
        if ((ctx = EVP_MD_CTX_new()) == NULL ||
            EVP_DigestInit_ex(ctx, EVP_sha256(), NULL) != 1 ||
            EVP_DigestUpdate(ctx, kempub, ...) != 1 ||

and Tobias Heider.

Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
Signed-off-by: Jaykishan Mutkawoa <jay@cyberstorm.mu>
Signed-off-by: Kavish Nadan <kn@cyberstorm.mu>
@loganaden
Copy link
Author

Thank you for the PR! Most of it already looks pretty good. I left a bunch of questions in-line.

Most of the minor issues have been fixed. We are carefully looking at the last part and will push an update
accordingly.

Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
Signed-off-by: Jaykishan Mutkawoa <jay@cyberstorm.mu>
Signed-off-by: Kavish Nadan <kn@cyberstorm.mu>
@loganaden
Copy link
Author

@tobhe @mfriedl can you allow automatic CI run only for this PR ? it will be easier to correct CI issues.

Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
Signed-off-by: Jaykishan Mutkawoa <jay@cyberstorm.mu>
Signed-off-by: Kavish Nadan <kn@cyberstorm.mu>
#define KRML_NOINLINE __attribute__((noinline, unused))
#define KRML_HOST_EPRINTF(...)
#define KRML_HOST_EXIT(x) fatal_f("internal error")
#define KRML_HOST_EXIT(x) exit(-1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fatalx()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mfriedl will change this. I am going to update the PR soon with one more bugfix.

@mfriedl
Copy link
Contributor

mfriedl commented Mar 31, 2025

fwiw, i've added pr #138 which binds the secret to the KEM-pubkey. it also uses the kem code directly w/o emulating the libcrypto API.

@loganaden
Copy link
Author

thanks @mfriedl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants