update master-with-bazel from master branch

This commit is contained in:
BoringSSL Robot
2024-03-09 00:15:52 +00:00
14 changed files with 611 additions and 5101 deletions
-3
View File
@@ -172,7 +172,6 @@ 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",
@@ -232,7 +231,6 @@ 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",
@@ -370,7 +368,6 @@ 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,7 +12,6 @@ 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",
@@ -153,7 +152,6 @@ 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",
@@ -283,7 +281,6 @@ 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
@@ -339,7 +339,6 @@ 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
+611 -930
View File
File diff suppressed because one or more lines are too long
-5
View File
@@ -82,7 +82,6 @@
"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",
@@ -406,7 +405,6 @@
"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,7 +463,6 @@
"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",
@@ -578,7 +575,6 @@
"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",
@@ -664,7 +660,6 @@
"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
@@ -145,7 +145,6 @@ add_library(
dh_extra/params.c
dh_extra/dh_asn1.c
digest_extra/digest_extra.c
dilithium/dilithium.c
dsa/dsa.c
dsa/dsa_asn1.c
ecdh_extra/ecdh_extra.c
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
-52
View File
@@ -1,52 +0,0 @@
/* 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
OPENSSL_EXPORT void 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|.
OPENSSL_EXPORT void 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
@@ -1,114 +0,0 @@
/* 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
// 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.
OPENSSL_EXPORT void 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|.
OPENSSL_EXPORT void 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);
#if defined(__cplusplus)
} // extern C
#endif
#endif // OPENSSL_HEADER_DILITHIUM_H
-2
View File
@@ -27,7 +27,6 @@ set(
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
@@ -118,7 +117,6 @@ set(
crypto/cipher_extra/test/nist_cavp/tdes_cbc.txt
crypto/cipher_extra/test/nist_cavp/tdes_ecb.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
-92
View File
@@ -38,7 +38,6 @@
#include <openssl/ecdsa.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/experimental/dilithium.h>
#include <openssl/experimental/kyber.h>
#include <openssl/experimental/spx.h>
#include <openssl/hrss.h>
@@ -1129,96 +1128,6 @@ 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;
uint8_t encoded_public_key[DILITHIUM_PUBLIC_KEY_BYTES];
DILITHIUM_private_key priv;
if (!TimeFunctionParallel(&results, [&]() -> bool {
DILITHIUM_generate_key(encoded_public_key, &priv);
return true;
})) {
fprintf(stderr, "Failed to time DILITHIUM_generate_key.\n");
return false;
}
results.Print("Dilithium key generation");
uint8_t encoded_private_key[DILITHIUM_PRIVATE_KEY_BYTES];
CBB cbb;
CBB_init_fixed(&cbb, encoded_private_key, sizeof(encoded_private_key));
DILITHIUM_marshal_private_key(&cbb, &priv);
if (!TimeFunctionParallel(&results, [&]() -> bool {
CBS cbs;
CBS_init(&cbs, encoded_private_key, sizeof(encoded_private_key));
DILITHIUM_parse_private_key(&priv, &cbs);
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);
uint8_t out_encoded_signature[DILITHIUM_SIGNATURE_BYTES];
if (!TimeFunctionParallel(&results, [&]() -> bool {
DILITHIUM_sign(out_encoded_signature, &priv, (const uint8_t *)message,
message_len);
return true;
})) {
fprintf(stderr, "Failed to time DILITHIUM_sign.\n");
return false;
}
results.Print("Dilithium sign (randomized)");
DILITHIUM_public_key pub;
if (!TimeFunctionParallel(&results, [&]() -> bool {
CBS cbs;
CBS_init(&cbs, encoded_public_key, sizeof(encoded_public_key));
DILITHIUM_parse_public_key(&pub, &cbs);
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 {
DILITHIUM_verify(&pub, out_encoded_signature, (const uint8_t *)message,
message_len);
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 {
DILITHIUM_verify(&pub, out_encoded_signature, (const uint8_t *)message,
message_len);
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;
@@ -1753,7 +1662,6 @@ 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,7 +62,6 @@
},{
"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"
]