update master-with-bazel from master branch

This commit is contained in:
BoringSSL Robot
2024-05-08 22:09:23 +00:00
15 changed files with 4299 additions and 0 deletions
+3
View File
@@ -172,6 +172,7 @@ crypto_headers = [
"src/include/openssl/evp.h",
"src/include/openssl/evp_errors.h",
"src/include/openssl/ex_data.h",
"src/include/openssl/experimental/dilithium.h",
"src/include/openssl/experimental/kyber.h",
"src/include/openssl/experimental/spx.h",
"src/include/openssl/hkdf.h",
@@ -231,6 +232,7 @@ crypto_internal_headers = [
"src/crypto/curve25519/curve25519_tables.h",
"src/crypto/curve25519/internal.h",
"src/crypto/des/internal.h",
"src/crypto/dilithium/internal.h",
"src/crypto/dsa/internal.h",
"src/crypto/ec_extra/internal.h",
"src/crypto/err/internal.h",
@@ -367,6 +369,7 @@ crypto_sources = [
"src/crypto/dh_extra/dh_asn1.c",
"src/crypto/dh_extra/params.c",
"src/crypto/digest_extra/digest_extra.c",
"src/crypto/dilithium/dilithium.c",
"src/crypto/dsa/dsa.c",
"src/crypto/dsa/dsa_asn1.c",
"src/crypto/ec_extra/ec_asn1.c",
+3
View File
@@ -12,6 +12,7 @@ test_support_sources = [
"src/crypto/curve25519/curve25519_tables.h",
"src/crypto/curve25519/internal.h",
"src/crypto/des/internal.h",
"src/crypto/dilithium/internal.h",
"src/crypto/dsa/internal.h",
"src/crypto/ec_extra/internal.h",
"src/crypto/err/internal.h",
@@ -154,6 +155,7 @@ crypto_test_sources = [
"src/crypto/curve25519/x25519_test.cc",
"src/crypto/dh_extra/dh_test.cc",
"src/crypto/digest_extra/digest_test.cc",
"src/crypto/dilithium/dilithium_test.cc",
"src/crypto/dsa/dsa_test.cc",
"src/crypto/ecdh_extra/ecdh_test.cc",
"src/crypto/err/err_test.cc",
@@ -282,6 +284,7 @@ crypto_test_data = [
"src/crypto/cipher_extra/test/nist_cavp/tdes_ecb.txt",
"src/crypto/cipher_extra/test/xchacha20_poly1305_tests.txt",
"src/crypto/curve25519/ed25519_tests.txt",
"src/crypto/dilithium/dilithium_tests.txt",
"src/crypto/ecdh_extra/ecdh_tests.txt",
"src/crypto/evp/evp_tests.txt",
"src/crypto/evp/scrypt_tests.txt",
+1
View File
@@ -338,6 +338,7 @@ add_library(
src/crypto/dh_extra/dh_asn1.c
src/crypto/dh_extra/params.c
src/crypto/digest_extra/digest_extra.c
src/crypto/dilithium/dilithium.c
src/crypto/dsa/dsa.c
src/crypto/dsa/dsa_asn1.c
src/crypto/ec_extra/ec_asn1.c
+5
View File
@@ -81,6 +81,7 @@
"src/crypto/dh_extra/dh_asn1.c",
"src/crypto/dh_extra/params.c",
"src/crypto/digest_extra/digest_extra.c",
"src/crypto/dilithium/dilithium.c",
"src/crypto/dsa/dsa.c",
"src/crypto/dsa/dsa_asn1.c",
"src/crypto/ec_extra/ec_asn1.c",
@@ -407,6 +408,7 @@
"src/include/openssl/evp.h",
"src/include/openssl/evp_errors.h",
"src/include/openssl/ex_data.h",
"src/include/openssl/experimental/dilithium.h",
"src/include/openssl/experimental/kyber.h",
"src/include/openssl/experimental/spx.h",
"src/include/openssl/hkdf.h",
@@ -465,6 +467,7 @@
"src/crypto/curve25519/curve25519_tables.h",
"src/crypto/curve25519/internal.h",
"src/crypto/des/internal.h",
"src/crypto/dilithium/internal.h",
"src/crypto/dsa/internal.h",
"src/crypto/ec_extra/internal.h",
"src/crypto/err/internal.h",
@@ -576,6 +579,7 @@
"src/crypto/curve25519/x25519_test.cc",
"src/crypto/dh_extra/dh_test.cc",
"src/crypto/digest_extra/digest_test.cc",
"src/crypto/dilithium/dilithium_test.cc",
"src/crypto/dsa/dsa_test.cc",
"src/crypto/ecdh_extra/ecdh_test.cc",
"src/crypto/err/err_test.cc",
@@ -660,6 +664,7 @@
"src/crypto/cipher_extra/test/nist_cavp/tdes_ecb.txt",
"src/crypto/cipher_extra/test/xchacha20_poly1305_tests.txt",
"src/crypto/curve25519/ed25519_tests.txt",
"src/crypto/dilithium/dilithium_tests.txt",
"src/crypto/ecdh_extra/ecdh_tests.txt",
"src/crypto/evp/evp_tests.txt",
"src/crypto/evp/scrypt_tests.txt",
+5
View File
@@ -229,6 +229,7 @@
"crypto/dh_extra/params.c",
"crypto/dh_extra/dh_asn1.c",
"crypto/digest_extra/digest_extra.c",
"crypto/dilithium/dilithium.c",
"crypto/dsa/dsa.c",
"crypto/dsa/dsa_asn1.c",
"crypto/ecdh_extra/ecdh_extra.c",
@@ -424,6 +425,7 @@
"include/openssl/evp.h",
"include/openssl/evp_errors.h",
"include/openssl/ex_data.h",
"include/openssl/experimental/dilithium.h",
"include/openssl/experimental/kyber.h",
"include/openssl/experimental/spx.h",
"include/openssl/hkdf.h",
@@ -482,6 +484,7 @@
"crypto/curve25519/curve25519_tables.h",
"crypto/curve25519/internal.h",
"crypto/des/internal.h",
"crypto/dilithium/internal.h",
"crypto/dsa/internal.h",
"crypto/ec_extra/internal.h",
"crypto/err/internal.h",
@@ -799,6 +802,7 @@
"crypto/ecdh_extra/ecdh_test.cc",
"crypto/dh_extra/dh_test.cc",
"crypto/digest_extra/digest_test.cc",
"crypto/dilithium/dilithium_test.cc",
"crypto/dsa/dsa_test.cc",
"crypto/err/err_test.cc",
"crypto/evp/evp_extra_test.cc",
@@ -853,6 +857,7 @@
"crypto/cipher_extra/test/*.txt",
"crypto/cipher_extra/test/nist_cavp/*.txt",
"crypto/curve25519/ed25519_tests.txt",
"crypto/dilithium/dilithium_tests.txt",
"crypto/ecdh_extra/ecdh_tests.txt",
"crypto/evp/evp_tests.txt",
"crypto/evp/scrypt_tests.txt",
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+58
View File
@@ -0,0 +1,58 @@
/* Copyright (c) 2023, Google LLC
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#ifndef OPENSSL_HEADER_CRYPTO_DILITHIUM_INTERNAL_H
#define OPENSSL_HEADER_CRYPTO_DILITHIUM_INTERNAL_H
#include <openssl/base.h>
#include <openssl/experimental/dilithium.h>
#if defined(__cplusplus)
extern "C" {
#endif
// DILITHIUM_GENERATE_KEY_ENTROPY is the number of bytes of uniformly random
// entropy necessary to generate a key pair.
#define DILITHIUM_GENERATE_KEY_ENTROPY 32
// DILITHIUM_SIGNATURE_RANDOMIZER_BYTES is the number of bytes of uniformly
// random entropy necessary to generate a signature in randomized mode.
#define DILITHIUM_SIGNATURE_RANDOMIZER_BYTES 32
// DILITHIUM_generate_key_external_entropy generates a public/private key pair
// using the given seed, writes the encoded public key to
// |out_encoded_public_key| and sets |out_private_key| to the private key,
// returning 1 on success and 0 on failure. Returns 1 on success and 0 on
// failure.
OPENSSL_EXPORT int DILITHIUM_generate_key_external_entropy(
uint8_t out_encoded_public_key[DILITHIUM_PUBLIC_KEY_BYTES],
struct DILITHIUM_private_key *out_private_key,
const uint8_t entropy[DILITHIUM_GENERATE_KEY_ENTROPY]);
// DILITHIUM_sign_deterministic generates a signature for the message |msg| of
// length |msg_len| using |private_key| following the deterministic algorithm,
// and writes the encoded signature to |out_encoded_signature|. Returns 1 on
// success and 0 on failure.
OPENSSL_EXPORT int DILITHIUM_sign_deterministic(
uint8_t out_encoded_signature[DILITHIUM_SIGNATURE_BYTES],
const struct DILITHIUM_private_key *private_key, const uint8_t *msg,
size_t msg_len);
#if defined(__cplusplus)
} // extern C
#endif
#endif // OPENSSL_HEADER_CRYPTO_DILITHIUM_INTERNAL_H
+5
View File
@@ -330,6 +330,7 @@ crypto_sources = [
"crypto/dh_extra/dh_asn1.c",
"crypto/dh_extra/params.c",
"crypto/digest_extra/digest_extra.c",
"crypto/dilithium/dilithium.c",
"crypto/dsa/dsa.c",
"crypto/dsa/dsa_asn1.c",
"crypto/ec_extra/ec_asn1.c",
@@ -527,6 +528,7 @@ crypto_headers = [
"include/openssl/evp.h",
"include/openssl/evp_errors.h",
"include/openssl/ex_data.h",
"include/openssl/experimental/dilithium.h",
"include/openssl/experimental/kyber.h",
"include/openssl/experimental/spx.h",
"include/openssl/hkdf.h",
@@ -586,6 +588,7 @@ crypto_internal_headers = [
"crypto/curve25519/curve25519_tables.h",
"crypto/curve25519/internal.h",
"crypto/des/internal.h",
"crypto/dilithium/internal.h",
"crypto/dsa/internal.h",
"crypto/ec_extra/internal.h",
"crypto/err/internal.h",
@@ -696,6 +699,7 @@ crypto_test_sources = [
"crypto/curve25519/x25519_test.cc",
"crypto/dh_extra/dh_test.cc",
"crypto/digest_extra/digest_test.cc",
"crypto/dilithium/dilithium_test.cc",
"crypto/dsa/dsa_test.cc",
"crypto/ecdh_extra/ecdh_test.cc",
"crypto/err/err_test.cc",
@@ -781,6 +785,7 @@ crypto_test_data = [
"crypto/cipher_extra/test/nist_cavp/tdes_ecb.txt",
"crypto/cipher_extra/test/xchacha20_poly1305_tests.txt",
"crypto/curve25519/ed25519_tests.txt",
"crypto/dilithium/dilithium_tests.txt",
"crypto/ecdh_extra/ecdh_tests.txt",
"crypto/evp/evp_tests.txt",
"crypto/evp/scrypt_tests.txt",
+5
View File
@@ -344,6 +344,7 @@ set(
crypto/dh_extra/dh_asn1.c
crypto/dh_extra/params.c
crypto/digest_extra/digest_extra.c
crypto/dilithium/dilithium.c
crypto/dsa/dsa.c
crypto/dsa/dsa_asn1.c
crypto/ec_extra/ec_asn1.c
@@ -543,6 +544,7 @@ set(
include/openssl/evp.h
include/openssl/evp_errors.h
include/openssl/ex_data.h
include/openssl/experimental/dilithium.h
include/openssl/experimental/kyber.h
include/openssl/experimental/spx.h
include/openssl/hkdf.h
@@ -604,6 +606,7 @@ set(
crypto/curve25519/curve25519_tables.h
crypto/curve25519/internal.h
crypto/des/internal.h
crypto/dilithium/internal.h
crypto/dsa/internal.h
crypto/ec_extra/internal.h
crypto/err/internal.h
@@ -720,6 +723,7 @@ set(
crypto/curve25519/x25519_test.cc
crypto/dh_extra/dh_test.cc
crypto/digest_extra/digest_test.cc
crypto/dilithium/dilithium_test.cc
crypto/dsa/dsa_test.cc
crypto/ecdh_extra/ecdh_test.cc
crypto/err/err_test.cc
@@ -807,6 +811,7 @@ set(
crypto/cipher_extra/test/nist_cavp/tdes_ecb.txt
crypto/cipher_extra/test/xchacha20_poly1305_tests.txt
crypto/curve25519/ed25519_tests.txt
crypto/dilithium/dilithium_tests.txt
crypto/ecdh_extra/ecdh_tests.txt
crypto/evp/evp_tests.txt
crypto/evp/scrypt_tests.txt
+5
View File
@@ -314,6 +314,7 @@
"crypto/dh_extra/dh_asn1.c",
"crypto/dh_extra/params.c",
"crypto/digest_extra/digest_extra.c",
"crypto/dilithium/dilithium.c",
"crypto/dsa/dsa.c",
"crypto/dsa/dsa_asn1.c",
"crypto/ec_extra/ec_asn1.c",
@@ -510,6 +511,7 @@
"include/openssl/evp.h",
"include/openssl/evp_errors.h",
"include/openssl/ex_data.h",
"include/openssl/experimental/dilithium.h",
"include/openssl/experimental/kyber.h",
"include/openssl/experimental/spx.h",
"include/openssl/hkdf.h",
@@ -568,6 +570,7 @@
"crypto/curve25519/curve25519_tables.h",
"crypto/curve25519/internal.h",
"crypto/des/internal.h",
"crypto/dilithium/internal.h",
"crypto/dsa/internal.h",
"crypto/ec_extra/internal.h",
"crypto/err/internal.h",
@@ -677,6 +680,7 @@
"crypto/curve25519/x25519_test.cc",
"crypto/dh_extra/dh_test.cc",
"crypto/digest_extra/digest_test.cc",
"crypto/dilithium/dilithium_test.cc",
"crypto/dsa/dsa_test.cc",
"crypto/ecdh_extra/ecdh_test.cc",
"crypto/err/err_test.cc",
@@ -761,6 +765,7 @@
"crypto/cipher_extra/test/nist_cavp/tdes_ecb.txt",
"crypto/cipher_extra/test/xchacha20_poly1305_tests.txt",
"crypto/curve25519/ed25519_tests.txt",
"crypto/dilithium/dilithium_tests.txt",
"crypto/ecdh_extra/ecdh_tests.txt",
"crypto/evp/evp_tests.txt",
"crypto/evp/scrypt_tests.txt",
@@ -0,0 +1,125 @@
/* Copyright (c) 2023, Google LLC
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#ifndef OPENSSL_HEADER_DILITHIUM_H
#define OPENSSL_HEADER_DILITHIUM_H
#include <openssl/base.h>
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(OPENSSL_UNSTABLE_EXPERIMENTAL_DILITHIUM)
// This header implements experimental, draft versions of not-yet-standardized
// primitives. When the standard is complete, these functions will be removed
// and replaced with the final, incompatible standard version. They are
// available now for short-lived experiments, but must not be deployed anywhere
// durable, such as a long-lived key store. To use these functions define
// OPENSSL_UNSTABLE_EXPERIMENTAL_DILITHIUM.
// Dilithium3.
// DILITHIUM_private_key contains a Dilithium3 private key. The contents of this
// object should never leave the address space since the format is unstable.
struct DILITHIUM_private_key {
union {
uint8_t bytes[32 + 32 + 64 + 256 * 4 * (5 + 6 + 6)];
uint32_t alignment;
} opaque;
};
// DILITHIUM_public_key contains a Dilithium3 public key. The contents of this
// object should never leave the address space since the format is unstable.
struct DILITHIUM_public_key {
union {
uint8_t bytes[32 + 64 + 256 * 4 * 6];
uint32_t alignment;
} opaque;
};
// DILITHIUM_PRIVATE_KEY_BYTES is the number of bytes in an encoded Dilithium3
// private key.
#define DILITHIUM_PRIVATE_KEY_BYTES 4032
// DILITHIUM_PUBLIC_KEY_BYTES is the number of bytes in an encoded Dilithium3
// public key.
#define DILITHIUM_PUBLIC_KEY_BYTES 1952
// DILITHIUM_SIGNATURE_BYTES is the number of bytes in an encoded Dilithium3
// signature.
#define DILITHIUM_SIGNATURE_BYTES 3309
// DILITHIUM_generate_key generates a random public/private key pair, writes the
// encoded public key to |out_encoded_public_key| and sets |out_private_key| to
// the private key. Returns 1 on success and 0 on failure.
OPENSSL_EXPORT int DILITHIUM_generate_key(
uint8_t out_encoded_public_key[DILITHIUM_PUBLIC_KEY_BYTES],
struct DILITHIUM_private_key *out_private_key);
// DILITHIUM_sign generates a signature for the message |msg| of length
// |msg_len| using |private_key| following the randomized algorithm, and writes
// the encoded signature to |out_encoded_signature|. Returns 1 on success and 0
// on failure.
OPENSSL_EXPORT int DILITHIUM_sign(
uint8_t out_encoded_signature[DILITHIUM_SIGNATURE_BYTES],
const struct DILITHIUM_private_key *private_key, const uint8_t *msg,
size_t msg_len);
// DILITHIUM_verify verifies that |encoded_signature| constitutes a valid
// signature for the message |msg| of length |msg_len| using |public_key|.
OPENSSL_EXPORT int DILITHIUM_verify(
const struct DILITHIUM_public_key *public_key,
const uint8_t encoded_signature[DILITHIUM_SIGNATURE_BYTES],
const uint8_t *msg, size_t msg_len);
// Serialisation of keys.
// DILITHIUM_marshal_public_key serializes |public_key| to |out| in the standard
// format for Dilithium public keys. It returns one on success or zero on
// allocation error.
OPENSSL_EXPORT int DILITHIUM_marshal_public_key(
CBB *out, const struct DILITHIUM_public_key *public_key);
// DILITHIUM_parse_public_key parses a public key, in the format generated by
// |DILITHIUM_marshal_public_key|, from |in| and writes the result to
// |out_public_key|. It returns one on success or zero on parse error or if
// there are trailing bytes in |in|.
OPENSSL_EXPORT int DILITHIUM_parse_public_key(
struct DILITHIUM_public_key *public_key, CBS *in);
// DILITHIUM_marshal_private_key serializes |private_key| to |out| in the
// standard format for Dilithium private keys. It returns one on success or zero
// on allocation error.
OPENSSL_EXPORT int DILITHIUM_marshal_private_key(
CBB *out, const struct DILITHIUM_private_key *private_key);
// DILITHIUM_parse_private_key parses a private key, in the format generated by
// |DILITHIUM_marshal_private_key|, from |in| and writes the result to
// |out_private_key|. It returns one on success or zero on parse error or if
// there are trailing bytes in |in|.
OPENSSL_EXPORT int DILITHIUM_parse_private_key(
struct DILITHIUM_private_key *private_key, CBS *in);
#endif // OPENSSL_UNSTABLE_EXPERIMENTAL_DILITHIUM
#if defined(__cplusplus)
} // extern C
#endif
#endif // OPENSSL_HEADER_DILITHIUM_H
+114
View File
@@ -40,6 +40,8 @@
#include <openssl/ecdsa.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#define OPENSSL_UNSTABLE_EXPERIMENTAL_DILITHIUM
#include <openssl/experimental/dilithium.h>
#define OPENSSL_UNSTABLE_EXPERIMENTAL_SPX
#include <openssl/experimental/kyber.h>
#include <openssl/experimental/spx.h>
@@ -1131,6 +1133,117 @@ static bool SpeedKyber(const std::string &selected) {
return true;
}
static bool SpeedDilithium(const std::string &selected) {
if (!selected.empty() && selected != "Dilithium") {
return true;
}
TimeResults results;
auto encoded_public_key =
std::make_unique<uint8_t[]>(DILITHIUM_PUBLIC_KEY_BYTES);
auto priv = std::make_unique<DILITHIUM_private_key>();
if (!TimeFunctionParallel(&results, [&]() -> bool {
if (!DILITHIUM_generate_key(encoded_public_key.get(), priv.get())) {
fprintf(stderr, "Failure in DILITHIUM_generate_key.\n");
return false;
}
return true;
})) {
fprintf(stderr, "Failed to time DILITHIUM_generate_key.\n");
return false;
}
results.Print("Dilithium key generation");
auto encoded_private_key =
std::make_unique<uint8_t[]>(DILITHIUM_PRIVATE_KEY_BYTES);
CBB cbb;
CBB_init_fixed(&cbb, encoded_private_key.get(), DILITHIUM_PRIVATE_KEY_BYTES);
DILITHIUM_marshal_private_key(&cbb, priv.get());
if (!TimeFunctionParallel(&results, [&]() -> bool {
CBS cbs;
CBS_init(&cbs, encoded_private_key.get(), DILITHIUM_PRIVATE_KEY_BYTES);
if (!DILITHIUM_parse_private_key(priv.get(), &cbs)) {
fprintf(stderr, "Failure in DILITHIUM_parse_private_key.\n");
return false;
}
return true;
})) {
fprintf(stderr, "Failed to time DILITHIUM_parse_private_key.\n");
return false;
}
results.Print("Dilithium parse (valid) private key");
const char *message = "Hello world";
size_t message_len = strlen(message);
auto out_encoded_signature =
std::make_unique<uint8_t[]>(DILITHIUM_SIGNATURE_BYTES);
if (!TimeFunctionParallel(&results, [&]() -> bool {
if (!DILITHIUM_sign(out_encoded_signature.get(), priv.get(),
(const uint8_t *)message, message_len)) {
fprintf(stderr, "Failure in DILITHIUM_sign.\n");
return false;
}
return true;
})) {
fprintf(stderr, "Failed to time DILITHIUM_sign.\n");
return false;
}
results.Print("Dilithium sign (randomized)");
auto pub = std::make_unique<DILITHIUM_public_key>();
if (!TimeFunctionParallel(&results, [&]() -> bool {
CBS cbs;
CBS_init(&cbs, encoded_public_key.get(), DILITHIUM_PUBLIC_KEY_BYTES);
if (!DILITHIUM_parse_public_key(pub.get(), &cbs)) {
fprintf(stderr, "Failure in DILITHIUM_parse_public_key.\n");
return false;
}
return true;
})) {
fprintf(stderr, "Failed to time DILITHIUM_parse_public_key.\n");
return false;
}
results.Print("Dilithium parse (valid) public key");
if (!TimeFunctionParallel(&results, [&]() -> bool {
if (!DILITHIUM_verify(pub.get(), out_encoded_signature.get(),
(const uint8_t *)message, message_len)) {
fprintf(stderr, "Failed to verify Dilithium signature.\n");
return false;
}
return true;
})) {
fprintf(stderr, "Failed to time DILITHIUM_verify.\n");
return false;
}
results.Print("Dilithium verify (valid signature)");
out_encoded_signature[42] ^= 0x42;
if (!TimeFunctionParallel(&results, [&]() -> bool {
if (DILITHIUM_verify(pub.get(), out_encoded_signature.get(),
(const uint8_t *)message, message_len)) {
fprintf(stderr, "Dilithium signature unexpectedly verified.\n");
return false;
}
return true;
})) {
fprintf(stderr, "Failed to time DILITHIUM_verify.\n");
return false;
}
results.Print("Dilithium verify (invalid signature)");
return true;
}
static bool SpeedSpx(const std::string &selected) {
if (!selected.empty() && selected.find("spx") == std::string::npos) {
return true;
@@ -1665,6 +1778,7 @@ bool Speed(const std::vector<std::string> &args) {
!SpeedRSAKeyGen(selected) || //
!SpeedHRSS(selected) || //
!SpeedKyber(selected) || //
!SpeedDilithium(selected) || //
!SpeedSpx(selected) || //
!SpeedHashToCurve(selected) || //
!SpeedTrustToken("TrustToken-Exp1-Batch1", TRUST_TOKEN_experiment_v1(), 1,
+1
View File
@@ -62,6 +62,7 @@
},{
"Name": "Experimental primitives. Will be removed and replaced when standardized!",
"Headers": [
"include/openssl/experimental/dilithium.h",
"include/openssl/experimental/kyber.h",
"include/openssl/experimental/spx.h"
]