diff options
| author | tb <> | 2025-05-03 08:39:33 +0000 |
|---|---|---|
| committer | tb <> | 2025-05-03 08:39:33 +0000 |
| commit | 9820048271f5326d5bd9d00d8ca5fd3e7cc98123 (patch) | |
| tree | 59e2a62ae3da13074a241ca2ede421de3755f9f1 /src/lib/libc | |
| parent | fcc4c7b50e2b86b55823dda5fe0622d8fe00bf31 (diff) | |
| download | openbsd-9820048271f5326d5bd9d00d8ca5fd3e7cc98123.tar.gz openbsd-9820048271f5326d5bd9d00d8ca5fd3e7cc98123.tar.bz2 openbsd-9820048271f5326d5bd9d00d8ca5fd3e7cc98123.zip | |
CTASSERT that internal pub/priv keys match the sizes exposed in mlkem.h
This will need reworking (especially deduplicating) anyway, but it doesn't
hurt now.
From Kenjiro Nakayama
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/mlkem/mlkem1024.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/mlkem/mlkem768.c | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/libcrypto/mlkem/mlkem1024.c b/src/lib/libcrypto/mlkem/mlkem1024.c index f6fccdf6a8..ce6f26e66c 100644 --- a/src/lib/libcrypto/mlkem/mlkem1024.c +++ b/src/lib/libcrypto/mlkem/mlkem1024.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: mlkem1024.c,v 1.6 2025/01/03 08:19:24 tb Exp $ */ | 1 | /* $OpenBSD: mlkem1024.c,v 1.7 2025/05/03 08:39:33 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2024, Google Inc. | 3 | * Copyright (c) 2024, Google Inc. |
| 4 | * Copyright (c) 2024, Bob Beck <beck@obtuse.com> | 4 | * Copyright (c) 2024, Bob Beck <beck@obtuse.com> |
| @@ -793,6 +793,8 @@ struct public_key { | |||
| 793 | matrix m; | 793 | matrix m; |
| 794 | }; | 794 | }; |
| 795 | 795 | ||
| 796 | CTASSERT(sizeof(struct MLKEM1024_public_key) == sizeof(struct public_key)); | ||
| 797 | |||
| 796 | static struct public_key * | 798 | static struct public_key * |
| 797 | public_key_1024_from_external(const struct MLKEM1024_public_key *external) | 799 | public_key_1024_from_external(const struct MLKEM1024_public_key *external) |
| 798 | { | 800 | { |
| @@ -805,6 +807,8 @@ struct private_key { | |||
| 805 | uint8_t fo_failure_secret[32]; | 807 | uint8_t fo_failure_secret[32]; |
| 806 | }; | 808 | }; |
| 807 | 809 | ||
| 810 | CTASSERT(sizeof(struct MLKEM1024_private_key) == sizeof(struct private_key)); | ||
| 811 | |||
| 808 | static struct private_key * | 812 | static struct private_key * |
| 809 | private_key_1024_from_external(const struct MLKEM1024_private_key *external) | 813 | private_key_1024_from_external(const struct MLKEM1024_private_key *external) |
| 810 | { | 814 | { |
diff --git a/src/lib/libcrypto/mlkem/mlkem768.c b/src/lib/libcrypto/mlkem/mlkem768.c index bacde0c0b7..73e293d542 100644 --- a/src/lib/libcrypto/mlkem/mlkem768.c +++ b/src/lib/libcrypto/mlkem/mlkem768.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: mlkem768.c,v 1.7 2025/01/03 08:19:24 tb Exp $ */ | 1 | /* $OpenBSD: mlkem768.c,v 1.8 2025/05/03 08:39:33 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2024, Google Inc. | 3 | * Copyright (c) 2024, Google Inc. |
| 4 | * Copyright (c) 2024, Bob Beck <beck@obtuse.com> | 4 | * Copyright (c) 2024, Bob Beck <beck@obtuse.com> |
| @@ -792,6 +792,8 @@ struct public_key { | |||
| 792 | matrix m; | 792 | matrix m; |
| 793 | }; | 793 | }; |
| 794 | 794 | ||
| 795 | CTASSERT(sizeof(struct MLKEM768_public_key) == sizeof(struct public_key)); | ||
| 796 | |||
| 795 | static struct public_key * | 797 | static struct public_key * |
| 796 | public_key_768_from_external(const struct MLKEM768_public_key *external) | 798 | public_key_768_from_external(const struct MLKEM768_public_key *external) |
| 797 | { | 799 | { |
| @@ -804,6 +806,8 @@ struct private_key { | |||
| 804 | uint8_t fo_failure_secret[32]; | 806 | uint8_t fo_failure_secret[32]; |
| 805 | }; | 807 | }; |
| 806 | 808 | ||
| 809 | CTASSERT(sizeof(struct MLKEM768_private_key) == sizeof(struct private_key)); | ||
| 810 | |||
| 807 | static struct private_key * | 811 | static struct private_key * |
| 808 | private_key_768_from_external(const struct MLKEM768_private_key *external) | 812 | private_key_768_from_external(const struct MLKEM768_private_key *external) |
| 809 | { | 813 | { |
