Fix Anonymous Tokens tests in Chrome net_unittests.
PiperOrigin-RevId: 520636474
diff --git a/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/at_crypto_utils_test.cc b/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/at_crypto_utils_test.cc
index e50e490..1b7c477 100644
--- a/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/at_crypto_utils_test.cc
+++ b/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/at_crypto_utils_test.cc
@@ -37,7 +37,7 @@
std::string new_e;
};
-TEST(CryptoUtilsTest, BignumToStringAndBack) {
+TEST(AnonymousTokensCryptoUtilsTest, BignumToStringAndBack) {
ANON_TOKENS_ASSERT_OK_AND_ASSIGN(BnCtxPtr ctx, GetAndStartBigNumCtx());
// Create a new BIGNUM using the context and set it
@@ -58,7 +58,7 @@
EXPECT_EQ(BN_cmp(bn_1.get(), bn_2.get()), 0);
}
-TEST(CryptoUtilsTest, PowerOfTwoAndRsaSqrtTwo) {
+TEST(AnonymousTokensCryptoUtilsTest, PowerOfTwoAndRsaSqrtTwo) {
// Compute 2^(10-1/2).
ANON_TOKENS_ASSERT_OK_AND_ASSIGN(bssl::UniquePtr<BIGNUM> sqrt2,
GetRsaSqrtTwo(10));
@@ -70,7 +70,7 @@
EXPECT_LT(BN_cmp(sqrt2.get(), large_pow2.get()), 0);
}
-TEST(CryptoUtilsTest, ComputeHashAcceptsNullStringView) {
+TEST(AnonymousTokensCryptoUtilsTest, ComputeHashAcceptsNullStringView) {
absl::StatusOr<std::string> null_hash =
ComputeHash(absl::string_view(nullptr, 0), *EVP_sha512());
absl::StatusOr<std::string> empty_hash = ComputeHash("", *EVP_sha512());
@@ -85,7 +85,7 @@
EXPECT_EQ(*null_hash, *empty_str_hash);
}
-TEST(CryptoUtilsTest, ComputeCarmichaelLcm) {
+TEST(AnonymousTokensCryptoUtilsTest, ComputeCarmichaelLcm) {
ANON_TOKENS_ASSERT_OK_AND_ASSIGN(BnCtxPtr ctx, GetAndStartBigNumCtx());
// Suppose that N = 1019 * 1187.
@@ -154,7 +154,7 @@
INSTANTIATE_TEST_SUITE_P(ComputeHashTests, ComputeHashTest,
testing::ValuesIn(GetComputeHashTestParams()));
-TEST(CryptoUtilsInternalTest, PublicMetadataHashWithHKDF) {
+TEST(PublicMetadataCryptoUtilsInternalTest, PublicMetadataHashWithHKDF) {
ANON_TOKENS_ASSERT_OK_AND_ASSIGN(BnCtxPtr ctx, GetAndStartBigNumCtx());
ANON_TOKENS_ASSERT_OK_AND_ASSIGN(bssl::UniquePtr<BIGNUM> max_value,
NewBigNum());
@@ -182,7 +182,7 @@
EXPECT_LT(BN_cmp(output2.get(), max_value.get()), 0);
}
-TEST(CryptoUtilsTest, PublicExponentHashDifferentModulus) {
+TEST(PublicMetadataCryptoUtilsTest, PublicExponentHashDifferentModulus) {
ANON_TOKENS_ASSERT_OK_AND_ASSIGN(auto key_pair_1, GetStrongRsaKeys2048());
ANON_TOKENS_ASSERT_OK_AND_ASSIGN(auto key_pair_2,
GetAnotherStrongRsaKeys2048());
@@ -241,7 +241,8 @@
return test_vectors;
}
-TEST(CryptoUtilsTest, IetfNewPublicExponentWithPublicMetadataTests) {
+TEST(PublicMetadataCryptoUtilsTest,
+ IetfNewPublicExponentWithPublicMetadataTests) {
const auto test_vectors =
GetIetfNewPublicExponentWithPublicMetadataTestVectors();
for (const IetfNewPublicExponentWithPublicMetadataTestVector& test_vector :
diff --git a/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/rsa_blind_signer.h b/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/rsa_blind_signer.h
index a6c0e32..60fa565 100644
--- a/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/rsa_blind_signer.h
+++ b/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/rsa_blind_signer.h
@@ -23,6 +23,7 @@
#include "quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/blind_signer.h"
#include "quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/crypto_utils.h"
#include "quiche/blind_sign_auth/anonymous_tokens/proto/anonymous_tokens.pb.h"
+#include "quiche/common/platform/api/quiche_export.h"
namespace private_membership {
namespace anonymous_tokens {
@@ -31,7 +32,7 @@
// Signature Scheme) encoding is defined at
// https://tools.ietf.org/html/rfc8017#section-8.1). This implementation uses
// Boring SSL for the underlying cryptographic operations.
-class RsaBlindSigner : public BlindSigner {
+class QUICHE_EXPORT RsaBlindSigner : public BlindSigner {
public:
~RsaBlindSigner() override = default;
RsaBlindSigner(const RsaBlindSigner&) = delete;
diff --git a/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/rsa_ssa_pss_verifier_test.cc b/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/rsa_ssa_pss_verifier_test.cc
index 32cdffb..1d19310 100644
--- a/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/rsa_ssa_pss_verifier_test.cc
+++ b/quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/rsa_ssa_pss_verifier_test.cc
@@ -67,7 +67,7 @@
EXPECT_THAT(
verifier->Verify(wrong_sig, test_vec.message),
- testing::status::StatusIs(absl::StatusCode::kInvalidArgument,
+ quiche::test::StatusIs(absl::StatusCode::kInvalidArgument,
testing::HasSubstr("verification failed")));
}
@@ -86,7 +86,7 @@
EXPECT_THAT(
verifier->Verify(test_vec.signature, test_vec.message),
- testing::status::StatusIs(absl::StatusCode::kInvalidArgument,
+ quiche::test::StatusIs(absl::StatusCode::kInvalidArgument,
testing::HasSubstr("verification failed")));
}
diff --git a/quiche/blind_sign_auth/anonymous_tokens/cpp/testing/utils.cc b/quiche/blind_sign_auth/anonymous_tokens/cpp/testing/utils.cc
index 87ecc77..8f8afaf 100644
--- a/quiche/blind_sign_auth/anonymous_tokens/cpp/testing/utils.cc
+++ b/quiche/blind_sign_auth/anonymous_tokens/cpp/testing/utils.cc
@@ -19,6 +19,7 @@
#include <fstream>
#include <memory>
#include <random>
+#include <sstream>
#include <string>
#include <utility>
#include <vector>
@@ -32,6 +33,8 @@
#include "quiche/blind_sign_auth/anonymous_tokens/cpp/crypto/crypto_utils.h"
#include "quiche/blind_sign_auth/anonymous_tokens/cpp/shared/status_utils.h"
#include "quiche/blind_sign_auth/anonymous_tokens/proto/anonymous_tokens.pb.h"
+#include "quiche/common/platform/api/quiche_file_utils.h"
+#include "quiche/common/platform/api/quiche_test.h"
#include "openssl/rsa.h"
namespace private_membership {
@@ -346,35 +349,31 @@
}
absl::StatusOr<std::pair<RSAPublicKey, RSAPrivateKey>> GetStrongRsaKeys2048() {
- ANON_TOKENS_ASSIGN_OR_RETURN(
- auto key_pair,
- ParseRsaKeysFromFile("quiche/blind_sign_auth/anonymous_tokens/testing/data/"
- "strong_rsa_modulus2048_example.binarypb"));
+ std::string path = absl::StrCat(quiche::test::QuicheGetCommonSourcePath(),
+ "/anonymous_tokens/testing/data/strong_rsa_modulus2048_example.binarypb");
+ ANON_TOKENS_ASSIGN_OR_RETURN(auto key_pair, ParseRsaKeysFromFile(path));
return std::make_pair(std::move(key_pair.first), std::move(key_pair.second));
}
absl::StatusOr<std::pair<RSAPublicKey, RSAPrivateKey>>
GetAnotherStrongRsaKeys2048() {
- ANON_TOKENS_ASSIGN_OR_RETURN(
- auto key_pair,
- ParseRsaKeysFromFile("quiche/blind_sign_auth/anonymous_tokens/testing/data/"
- "strong_rsa_modulus2048_example_2.binarypb"));
+ std::string path = absl::StrCat(quiche::test::QuicheGetCommonSourcePath(),
+ "/anonymous_tokens/testing/data/strong_rsa_modulus2048_example_2.binarypb");
+ ANON_TOKENS_ASSIGN_OR_RETURN(auto key_pair, ParseRsaKeysFromFile(path));
return std::make_pair(std::move(key_pair.first), std::move(key_pair.second));
}
absl::StatusOr<std::pair<RSAPublicKey, RSAPrivateKey>> GetStrongRsaKeys3072() {
- ANON_TOKENS_ASSIGN_OR_RETURN(
- auto key_pair,
- ParseRsaKeysFromFile("quiche/blind_sign_auth/anonymous_tokens/testing/data/"
- "strong_rsa_modulus3072_example.binarypb"));
+ std::string path = absl::StrCat(quiche::test::QuicheGetCommonSourcePath(),
+ "/anonymous_tokens/testing/data/strong_rsa_modulus3072_example.binarypb");
+ ANON_TOKENS_ASSIGN_OR_RETURN(auto key_pair, ParseRsaKeysFromFile(path));
return std::make_pair(std::move(key_pair.first), std::move(key_pair.second));
}
absl::StatusOr<std::pair<RSAPublicKey, RSAPrivateKey>> GetStrongRsaKeys4096() {
- ANON_TOKENS_ASSIGN_OR_RETURN(
- auto key_pair,
- ParseRsaKeysFromFile("quiche/blind_sign_auth/anonymous_tokens/testing/data/"
- "strong_rsa_modulus4096_example.binarypb"));
+ std::string path = absl::StrCat(quiche::test::QuicheGetCommonSourcePath(),
+ "/anonymous_tokens/testing/data/strong_rsa_modulus4096_example.binarypb");
+ ANON_TOKENS_ASSIGN_OR_RETURN(auto key_pair, ParseRsaKeysFromFile(path));
return std::make_pair(std::move(key_pair.first), std::move(key_pair.second));
}
diff --git a/quiche/blind_sign_auth/anonymous_tokens/testing/data/strong_rsa_modulus2048_example.binarypb b/quiche/common/anonymous_tokens/testing/data/strong_rsa_modulus2048_example.binarypb
similarity index 100%
rename from quiche/blind_sign_auth/anonymous_tokens/testing/data/strong_rsa_modulus2048_example.binarypb
rename to quiche/common/anonymous_tokens/testing/data/strong_rsa_modulus2048_example.binarypb
Binary files differ
diff --git a/quiche/blind_sign_auth/anonymous_tokens/testing/data/strong_rsa_modulus2048_example_2.binarypb b/quiche/common/anonymous_tokens/testing/data/strong_rsa_modulus2048_example_2.binarypb
similarity index 100%
rename from quiche/blind_sign_auth/anonymous_tokens/testing/data/strong_rsa_modulus2048_example_2.binarypb
rename to quiche/common/anonymous_tokens/testing/data/strong_rsa_modulus2048_example_2.binarypb
Binary files differ
diff --git a/quiche/blind_sign_auth/anonymous_tokens/testing/data/strong_rsa_modulus3072_example.binarypb b/quiche/common/anonymous_tokens/testing/data/strong_rsa_modulus3072_example.binarypb
similarity index 100%
rename from quiche/blind_sign_auth/anonymous_tokens/testing/data/strong_rsa_modulus3072_example.binarypb
rename to quiche/common/anonymous_tokens/testing/data/strong_rsa_modulus3072_example.binarypb
Binary files differ
diff --git a/quiche/blind_sign_auth/anonymous_tokens/testing/data/strong_rsa_modulus4096_example.binarypb b/quiche/common/anonymous_tokens/testing/data/strong_rsa_modulus4096_example.binarypb
similarity index 100%
rename from quiche/blind_sign_auth/anonymous_tokens/testing/data/strong_rsa_modulus4096_example.binarypb
rename to quiche/common/anonymous_tokens/testing/data/strong_rsa_modulus4096_example.binarypb
Binary files differ