aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWiktor Garbacz <wiktorg@google.com>2024-05-14 03:28:55 -0700
committerCopybara-Service <copybara-worker@google.com>2024-05-14 03:30:24 -0700
commit0d09353b70fad4ced2fc3d120b18d01ee01b2831 (patch)
treeb5e8ef20283ff461249e9046af628a26059cbc46
parent63d4600b2dadf18843fabb58ab636833ba0c1d54 (diff)
downloadtink-0d09353b70fad4ced2fc3d120b18d01ee01b2831.tar.gz
Use `ctype = STRING_PIECE` on all `key_value`s
PiperOrigin-RevId: 633521257 Change-Id: I2754393df8663b0d9cecdd0b797365c8c32bfbcf
-rw-r--r--proto/aes_cmac.proto2
-rw-r--r--proto/aes_cmac_prf.proto2
-rw-r--r--proto/aes_ctr.proto2
-rw-r--r--proto/aes_ctr_hmac_streaming.proto2
-rw-r--r--proto/aes_gcm.proto2
-rw-r--r--proto/aes_gcm_hkdf_streaming.proto2
-rw-r--r--proto/aes_gcm_siv.proto2
-rw-r--r--proto/aes_siv.proto2
-rw-r--r--proto/chacha20_poly1305.proto2
-rw-r--r--proto/ecdsa.proto2
-rw-r--r--proto/ecies_aead_hkdf.proto2
-rw-r--r--proto/ed25519.proto4
-rw-r--r--proto/experimental/pqcrypto/dilithium.proto4
-rw-r--r--proto/experimental/pqcrypto/falcon.proto4
-rw-r--r--proto/experimental/pqcrypto/slh_dsa.proto4
-rw-r--r--proto/experimental/pqcrypto/sphincs.proto4
-rw-r--r--proto/hkdf_prf.proto2
-rw-r--r--proto/hmac.proto2
-rw-r--r--proto/hmac_prf.proto2
-rw-r--r--proto/jwt_ecdsa.proto2
-rw-r--r--proto/jwt_hmac.proto2
-rw-r--r--proto/xchacha20_poly1305.proto2
-rw-r--r--tink/BUILD.bazel2
-rw-r--r--tink/CMakeLists.txt2
-rw-r--r--tink/config/BUILD.bazel1
-rw-r--r--tink/config/CMakeLists.txt1
-rw-r--r--tink/config/global_registry_test.cc3
-rw-r--r--tink/core/key_manager_impl_test.cc3
-rw-r--r--tink/core/key_type_manager_test.cc3
-rw-r--r--tink/core/keyset_handle_test.cc2
-rw-r--r--tink/daead/aes_siv_key_manager_test.cc8
-rw-r--r--tink/experimental/pqcrypto/signature/dilithium_sign_key_manager_test.cc2
-rw-r--r--tink/experimental/pqcrypto/signature/falcon_sign_key_manager_test.cc2
-rw-r--r--tink/experimental/pqcrypto/signature/sphincs_sign_key_manager_test.cc5
-rw-r--r--tink/experimental/pqcrypto/signature/sphincs_verify_key_manager.cc5
-rw-r--r--tink/hybrid/internal/hpke_private_key_manager_test.cc6
-rw-r--r--tink/internal/BUILD.bazel3
-rw-r--r--tink/internal/CMakeLists.txt3
-rw-r--r--tink/internal/configuration_impl_test.cc7
-rw-r--r--tink/internal/key_gen_configuration_impl_test.cc3
-rw-r--r--tink/internal/keyset_wrapper_store_test.cc5
-rw-r--r--tink/internal/registry_impl_test.cc4
-rw-r--r--tink/signature/ed25519_sign_key_manager_test.cc2
43 files changed, 73 insertions, 53 deletions
diff --git a/proto/aes_cmac.proto b/proto/aes_cmac.proto
index d1de8e3d9..b5dbd941e 100644
--- a/proto/aes_cmac.proto
+++ b/proto/aes_cmac.proto
@@ -29,7 +29,7 @@ message AesCmacParams {
// key_type: type.googleapis.com/google.crypto.tink.AesCmacKey
message AesCmacKey {
uint32 version = 1;
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
AesCmacParams params = 3;
}
diff --git a/proto/aes_cmac_prf.proto b/proto/aes_cmac_prf.proto
index dd8dcae1e..94fe509d4 100644
--- a/proto/aes_cmac_prf.proto
+++ b/proto/aes_cmac_prf.proto
@@ -25,7 +25,7 @@ option go_package = "github.com/tink-crypto/tink-go/v2/proto/aes_cmac_prf_go_pro
// key_type: type.googleapis.com/google.crypto.tink.AesCmacPrfKey
message AesCmacPrfKey {
uint32 version = 1;
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
}
message AesCmacPrfKeyFormat {
diff --git a/proto/aes_ctr.proto b/proto/aes_ctr.proto
index a873097c7..66c0ca1e5 100644
--- a/proto/aes_ctr.proto
+++ b/proto/aes_ctr.proto
@@ -35,5 +35,5 @@ message AesCtrKeyFormat {
message AesCtrKey {
uint32 version = 1;
AesCtrParams params = 2;
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
}
diff --git a/proto/aes_ctr_hmac_streaming.proto b/proto/aes_ctr_hmac_streaming.proto
index 599e267d6..7927bde81 100644
--- a/proto/aes_ctr_hmac_streaming.proto
+++ b/proto/aes_ctr_hmac_streaming.proto
@@ -42,5 +42,5 @@ message AesCtrHmacStreamingKeyFormat {
message AesCtrHmacStreamingKey {
uint32 version = 1;
AesCtrHmacStreamingParams params = 2;
- bytes key_value = 3; // the main key, aka. "ikm", input key material
+ bytes key_value = 3; // Placeholder for ctype. // the main key, aka. "ikm", input key material
}
diff --git a/proto/aes_gcm.proto b/proto/aes_gcm.proto
index 1908c4ae0..3724b0a13 100644
--- a/proto/aes_gcm.proto
+++ b/proto/aes_gcm.proto
@@ -63,5 +63,5 @@ message AesGcmKeyFormat {
message AesGcmKey {
uint32 version = 1;
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
}
diff --git a/proto/aes_gcm_hkdf_streaming.proto b/proto/aes_gcm_hkdf_streaming.proto
index a436abbe9..c5e40236b 100644
--- a/proto/aes_gcm_hkdf_streaming.proto
+++ b/proto/aes_gcm_hkdf_streaming.proto
@@ -42,5 +42,5 @@ message AesGcmHkdfStreamingKeyFormat {
message AesGcmHkdfStreamingKey {
uint32 version = 1;
AesGcmHkdfStreamingParams params = 2;
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
}
diff --git a/proto/aes_gcm_siv.proto b/proto/aes_gcm_siv.proto
index c663aee60..fee87d760 100644
--- a/proto/aes_gcm_siv.proto
+++ b/proto/aes_gcm_siv.proto
@@ -32,5 +32,5 @@ message AesGcmSivKeyFormat {
// key_type: type.googleapis.com/google.crypto.tink.AesGcmSivKey
message AesGcmSivKey {
uint32 version = 1;
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
}
diff --git a/proto/aes_siv.proto b/proto/aes_siv.proto
index 0f605eae7..2c5e013e3 100644
--- a/proto/aes_siv.proto
+++ b/proto/aes_siv.proto
@@ -40,5 +40,5 @@ message AesSivKeyFormat {
message AesSivKey {
uint32 version = 1;
// First half is AES-CTR key, second is AES-SIV.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
}
diff --git a/proto/chacha20_poly1305.proto b/proto/chacha20_poly1305.proto
index 86f8545c4..8f26821c5 100644
--- a/proto/chacha20_poly1305.proto
+++ b/proto/chacha20_poly1305.proto
@@ -29,5 +29,5 @@ message ChaCha20Poly1305KeyFormat {}
// at https://tools.ietf.org/html/rfc7539#section-2.8.
message ChaCha20Poly1305Key {
uint32 version = 1;
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
}
diff --git a/proto/ecdsa.proto b/proto/ecdsa.proto
index 89dfebb5e..e89783e8a 100644
--- a/proto/ecdsa.proto
+++ b/proto/ecdsa.proto
@@ -74,7 +74,7 @@ message EcdsaPrivateKey {
EcdsaPublicKey public_key = 2;
// Unsigned big integer in bigendian representation.
// Required.
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
}
message EcdsaKeyFormat {
diff --git a/proto/ecies_aead_hkdf.proto b/proto/ecies_aead_hkdf.proto
index 488b2f059..fa7eca5fd 100644
--- a/proto/ecies_aead_hkdf.proto
+++ b/proto/ecies_aead_hkdf.proto
@@ -105,7 +105,7 @@ message EciesAeadHkdfPrivateKey {
EciesAeadHkdfPublicKey public_key = 2;
// Required.
- bytes key_value = 3; // Big integer in bigendian representation.
+ bytes key_value = 3; // Placeholder for ctype. // Big integer in bigendian representation.
}
message EciesAeadHkdfKeyFormat {
diff --git a/proto/ed25519.proto b/proto/ed25519.proto
index 763db39f8..8d6234a92 100644
--- a/proto/ed25519.proto
+++ b/proto/ed25519.proto
@@ -36,7 +36,7 @@ message Ed25519PublicKey {
// The public key is 32 bytes, encoded according to
// https://tools.ietf.org/html/rfc8032#section-5.1.2.
// Required.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
}
// key_type: type.googleapis.com/google.crypto.tink.Ed25519PrivateKey
@@ -46,7 +46,7 @@ message Ed25519PrivateKey {
// The private key is 32 bytes of cryptographically secure random data.
// See https://tools.ietf.org/html/rfc8032#section-5.1.5.
// Required.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
// The corresponding public key.
Ed25519PublicKey public_key = 3;
}
diff --git a/proto/experimental/pqcrypto/dilithium.proto b/proto/experimental/pqcrypto/dilithium.proto
index fa4c05bb3..48e477b66 100644
--- a/proto/experimental/pqcrypto/dilithium.proto
+++ b/proto/experimental/pqcrypto/dilithium.proto
@@ -43,7 +43,7 @@ message DilithiumPublicKey {
// Required.
uint32 version = 1;
// Required.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
// Required
DilithiumParams params = 3;
}
@@ -53,7 +53,7 @@ message DilithiumPrivateKey {
// Required.
uint32 version = 1;
// Required.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
// The corresponding public key.
DilithiumPublicKey public_key = 3;
}
diff --git a/proto/experimental/pqcrypto/falcon.proto b/proto/experimental/pqcrypto/falcon.proto
index 13103bc1f..b71a56b1c 100644
--- a/proto/experimental/pqcrypto/falcon.proto
+++ b/proto/experimental/pqcrypto/falcon.proto
@@ -30,7 +30,7 @@ message FalconPublicKey {
// Required.
uint32 version = 1;
// Required.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
}
// key_type: type.googleapis.com/google.crypto.tink.FalconPrivateKey
@@ -38,7 +38,7 @@ message FalconPrivateKey {
// Required.
uint32 version = 1;
// Required.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
// The corresponding public key.
FalconPublicKey public_key = 3;
}
diff --git a/proto/experimental/pqcrypto/slh_dsa.proto b/proto/experimental/pqcrypto/slh_dsa.proto
index b3768c64c..120205efb 100644
--- a/proto/experimental/pqcrypto/slh_dsa.proto
+++ b/proto/experimental/pqcrypto/slh_dsa.proto
@@ -51,7 +51,7 @@ message SlhDsaPublicKey {
// Required.
uint32 version = 1;
// Required.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
// Required
SlhDsaParams params = 3;
}
@@ -61,7 +61,7 @@ message SlhDsaPrivateKey {
// Required.
uint32 version = 1;
// Required.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
// Required. The corresponding public key.
SlhDsaPublicKey public_key = 3;
}
diff --git a/proto/experimental/pqcrypto/sphincs.proto b/proto/experimental/pqcrypto/sphincs.proto
index 381451cdc..169ff4b61 100644
--- a/proto/experimental/pqcrypto/sphincs.proto
+++ b/proto/experimental/pqcrypto/sphincs.proto
@@ -59,7 +59,7 @@ message SphincsPublicKey {
// Required.
uint32 version = 1;
// Required.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
// Required
SphincsParams params = 3;
}
@@ -69,7 +69,7 @@ message SphincsPrivateKey {
// Required.
uint32 version = 1;
// Required.
- bytes key_value = 2;
+ bytes key_value = 2; // Placeholder for ctype.
// The corresponding public key.
SphincsPublicKey public_key = 3;
}
diff --git a/proto/hkdf_prf.proto b/proto/hkdf_prf.proto
index e2c4f4e00..3b98d06eb 100644
--- a/proto/hkdf_prf.proto
+++ b/proto/hkdf_prf.proto
@@ -38,7 +38,7 @@ message HkdfPrfParams {
message HkdfPrfKey {
uint32 version = 1;
HkdfPrfParams params = 2;
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
}
message HkdfPrfKeyFormat {
diff --git a/proto/hmac.proto b/proto/hmac.proto
index 8f0f9e509..bd268f099 100644
--- a/proto/hmac.proto
+++ b/proto/hmac.proto
@@ -33,7 +33,7 @@ message HmacParams {
message HmacKey {
uint32 version = 1;
HmacParams params = 2;
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
}
message HmacKeyFormat {
diff --git a/proto/hmac_prf.proto b/proto/hmac_prf.proto
index 533895128..159d3db57 100644
--- a/proto/hmac_prf.proto
+++ b/proto/hmac_prf.proto
@@ -32,7 +32,7 @@ message HmacPrfParams {
message HmacPrfKey {
uint32 version = 1;
HmacPrfParams params = 2;
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
}
message HmacPrfKeyFormat {
diff --git a/proto/jwt_ecdsa.proto b/proto/jwt_ecdsa.proto
index 25b6980fd..e8f1be24b 100644
--- a/proto/jwt_ecdsa.proto
+++ b/proto/jwt_ecdsa.proto
@@ -52,7 +52,7 @@ message JwtEcdsaPrivateKey {
uint32 version = 1;
JwtEcdsaPublicKey public_key = 2;
// Unsigned big integer in bigendian representation.
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
}
message JwtEcdsaKeyFormat {
diff --git a/proto/jwt_hmac.proto b/proto/jwt_hmac.proto
index 00530023c..c62932300 100644
--- a/proto/jwt_hmac.proto
+++ b/proto/jwt_hmac.proto
@@ -34,7 +34,7 @@ enum JwtHmacAlgorithm {
message JwtHmacKey {
uint32 version = 1;
JwtHmacAlgorithm algorithm = 2;
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
// Optional, custom kid header value to be used with "RAW" keys.
// "TINK" keys with this value set will be rejected.
diff --git a/proto/xchacha20_poly1305.proto b/proto/xchacha20_poly1305.proto
index 530e57383..d080b7790 100644
--- a/proto/xchacha20_poly1305.proto
+++ b/proto/xchacha20_poly1305.proto
@@ -29,5 +29,5 @@ message XChaCha20Poly1305KeyFormat {
// key_type: type.googleapis.com/google.crypto.tink.XChaCha20Poly1305Key
message XChaCha20Poly1305Key {
uint32 version = 1;
- bytes key_value = 3;
+ bytes key_value = 3; // Placeholder for ctype.
}
diff --git a/tink/BUILD.bazel b/tink/BUILD.bazel
index 185e31395..81613a264 100644
--- a/tink/BUILD.bazel
+++ b/tink/BUILD.bazel
@@ -1097,6 +1097,7 @@ cc_test(
"//tink/util:validation",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
+ "@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
],
)
@@ -1118,6 +1119,7 @@ cc_test(
"//tink/util:test_util",
"//tink/util:validation",
"@com_google_absl//absl/status",
+ "@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
],
)
diff --git a/tink/CMakeLists.txt b/tink/CMakeLists.txt
index 4c3565a7c..faa986529 100644
--- a/tink/CMakeLists.txt
+++ b/tink/CMakeLists.txt
@@ -1034,6 +1034,7 @@ tink_cc_test(
gmock
absl::memory
absl::status
+ absl::string_view
tink::subtle::subtle
tink::util::secret_data
tink::util::status
@@ -1052,6 +1053,7 @@ tink_cc_test(
tink::core::key_manager_impl
gmock
absl::status
+ absl::string_view
tink::subtle::subtle
tink::util::input_stream_util
tink::util::istream_input_stream
diff --git a/tink/config/BUILD.bazel b/tink/config/BUILD.bazel
index 037bda87a..447798cc5 100644
--- a/tink/config/BUILD.bazel
+++ b/tink/config/BUILD.bazel
@@ -233,6 +233,7 @@ cc_test(
"//tink/util:test_matchers",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
+ "@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
],
)
diff --git a/tink/config/CMakeLists.txt b/tink/config/CMakeLists.txt
index ae975255c..71cb7e31e 100644
--- a/tink/config/CMakeLists.txt
+++ b/tink/config/CMakeLists.txt
@@ -207,6 +207,7 @@ tink_cc_test(
gmock
absl::memory
absl::status
+ absl::string_view
tink::core::key_type_manager
tink::core::template_util
tink::core::input_stream
diff --git a/tink/config/global_registry_test.cc b/tink/config/global_registry_test.cc
index 38d94d79c..e483e062b 100644
--- a/tink/config/global_registry_test.cc
+++ b/tink/config/global_registry_test.cc
@@ -24,6 +24,7 @@
#include "gtest/gtest.h"
#include "absl/memory/memory.h"
#include "absl/status/status.h"
+#include "absl/strings/string_view.h"
#include "tink/core/key_type_manager.h"
#include "tink/core/template_util.h"
#include "tink/input_stream.h"
@@ -51,7 +52,7 @@ using ::google::crypto::tink::OutputPrefixType;
class FakePrimitive {
public:
- explicit FakePrimitive(std::string s) : s_(s) {}
+ explicit FakePrimitive(absl::string_view s) : s_(s) {}
std::string get() { return s_; }
private:
diff --git a/tink/core/key_manager_impl_test.cc b/tink/core/key_manager_impl_test.cc
index 7497e5737..32802cf1e 100644
--- a/tink/core/key_manager_impl_test.cc
+++ b/tink/core/key_manager_impl_test.cc
@@ -23,6 +23,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/status/status.h"
+#include "absl/strings/string_view.h"
#include "tink/aead.h"
#include "tink/subtle/aes_gcm_boringssl.h"
#include "tink/subtle/random.h"
@@ -57,7 +58,7 @@ using ::testing::SizeIs;
// insecure, as it does nothing except provide access to the key.
class AeadVariant {
public:
- explicit AeadVariant(std::string s) : s_(s) {}
+ explicit AeadVariant(absl::string_view s) : s_(s) {}
std::string get() { return s_; }
diff --git a/tink/core/key_type_manager_test.cc b/tink/core/key_type_manager_test.cc
index 40f888be1..508bbd3e6 100644
--- a/tink/core/key_type_manager_test.cc
+++ b/tink/core/key_type_manager_test.cc
@@ -24,6 +24,7 @@
#include "gtest/gtest.h"
#include "absl/memory/memory.h"
#include "absl/status/status.h"
+#include "absl/strings/string_view.h"
#include "tink/aead.h"
#include "tink/core/template_util.h"
#include "tink/subtle/aes_gcm_boringssl.h"
@@ -49,7 +50,7 @@ using ::testing::Eq;
// insecure, as it does nothing except provide access to the key.
class AeadVariant {
public:
- explicit AeadVariant(std::string s) : s_(s) {}
+ explicit AeadVariant(absl::string_view s) : s_(s) {}
std::string get() { return s_; }
diff --git a/tink/core/keyset_handle_test.cc b/tink/core/keyset_handle_test.cc
index e43c8b824..b4ba2c7de 100644
--- a/tink/core/keyset_handle_test.cc
+++ b/tink/core/keyset_handle_test.cc
@@ -1052,7 +1052,7 @@ TEST_F(KeysetHandleTest, GetPrimitiveWithConfigFips1402FailsWithNonFipsHandle) {
Keyset keyset;
AesGcmSivKey key_proto;
- *key_proto.mutable_key_value() = subtle::Random::GetRandomBytes(16);
+ key_proto.set_key_value(subtle::Random::GetRandomBytes(16));
test::AddTinkKey(AeadKeyTemplates::Aes256GcmSiv().type_url(), /*key_id=*/13,
key_proto, KeyStatusType::ENABLED, KeyData::SYMMETRIC,
&keyset);
diff --git a/tink/daead/aes_siv_key_manager_test.cc b/tink/daead/aes_siv_key_manager_test.cc
index fd44271f3..4a41e23fa 100644
--- a/tink/daead/aes_siv_key_manager_test.cc
+++ b/tink/daead/aes_siv_key_manager_test.cc
@@ -167,7 +167,7 @@ TEST(AesSivKeyManagerTest, DeriveKeyWrongVersion) {
TEST(AesSivKeyManagerTest, ValidateKey) {
AesSivKey key;
- *key.mutable_key_value() = std::string(64, 'a');
+ key.set_key_value(std::string(64, 'a'));
key.set_version(0);
EXPECT_THAT(AesSivKeyManager().ValidateKey(key), IsOk());
}
@@ -176,18 +176,18 @@ TEST(AesSivKeyManagerTest, ValidateKeyStringLength) {
AesSivKey key;
key.set_version(0);
for (int i = 0 ; i < 64; ++i) {
- *key.mutable_key_value() = std::string(i, 'a');
+ key.set_key_value(std::string(i, 'a'));
EXPECT_THAT(AesSivKeyManager().ValidateKey(key), Not(IsOk()));
}
for (int i = 65 ; i <= 200; ++i) {
- *key.mutable_key_value() = std::string(i, 'a');
+ key.set_key_value(std::string(i, 'a'));
EXPECT_THAT(AesSivKeyManager().ValidateKey(key), Not(IsOk()));
}
}
TEST(AesSivKeyManagerTest, ValidateKeyVersion) {
AesSivKey key;
- *key.mutable_key_value() = std::string(64, 'a');
+ key.set_key_value(std::string(64, 'a'));
key.set_version(1);
EXPECT_THAT(AesSivKeyManager().ValidateKey(key), Not(IsOk()));
}
diff --git a/tink/experimental/pqcrypto/signature/dilithium_sign_key_manager_test.cc b/tink/experimental/pqcrypto/signature/dilithium_sign_key_manager_test.cc
index 27764a1c4..2e94f60d0 100644
--- a/tink/experimental/pqcrypto/signature/dilithium_sign_key_manager_test.cc
+++ b/tink/experimental/pqcrypto/signature/dilithium_sign_key_manager_test.cc
@@ -161,7 +161,7 @@ TEST_P(DilithiumSignKeyManagerTest, CreateKeyAlwaysNew) {
StatusOr<DilithiumPrivateKey> private_key =
DilithiumSignKeyManager().CreateKey(*key_format);
ASSERT_THAT(private_key, IsOk());
- keys.insert(private_key->key_value());
+ keys.insert(std::string(private_key->key_value()));
}
EXPECT_THAT(keys, SizeIs(num_tests));
}
diff --git a/tink/experimental/pqcrypto/signature/falcon_sign_key_manager_test.cc b/tink/experimental/pqcrypto/signature/falcon_sign_key_manager_test.cc
index f9683ec84..8a8b22bed 100644
--- a/tink/experimental/pqcrypto/signature/falcon_sign_key_manager_test.cc
+++ b/tink/experimental/pqcrypto/signature/falcon_sign_key_manager_test.cc
@@ -137,7 +137,7 @@ TEST_P(FalconSignKeyManagerTest, CreateKeyAlwaysNew) {
StatusOr<FalconPrivateKey> private_key =
FalconSignKeyManager().CreateKey(*key_format);
ASSERT_THAT(private_key, IsOk());
- keys.insert(private_key->key_value());
+ keys.insert(std::string(private_key->key_value()));
}
EXPECT_THAT(keys, SizeIs(num_tests));
}
diff --git a/tink/experimental/pqcrypto/signature/sphincs_sign_key_manager_test.cc b/tink/experimental/pqcrypto/signature/sphincs_sign_key_manager_test.cc
index fdc6656e3..4aa0781e8 100644
--- a/tink/experimental/pqcrypto/signature/sphincs_sign_key_manager_test.cc
+++ b/tink/experimental/pqcrypto/signature/sphincs_sign_key_manager_test.cc
@@ -213,7 +213,7 @@ TEST_P(SphincsSignKeyManagerTest, CreateKeyAlwaysNew) {
StatusOr<SphincsPrivateKey> private_key =
SphincsSignKeyManager().CreateKey(*key_format);
ASSERT_THAT(private_key, IsOk());
- keys.insert(private_key->key_value());
+ keys.insert(std::string(private_key->key_value()));
}
EXPECT_THAT(keys, SizeIs(num_tests));
}
@@ -264,7 +264,8 @@ TEST_P(SphincsSignKeyManagerTest, CreateValid) {
.private_key_size = test_case.private_key_size};
SphincsPublicKeyPqclean sphincs_public_key_pqclean(
- private_key->public_key().key_value(), sphincs_params_pqclean);
+ std::string(private_key->public_key().key_value()),
+ sphincs_params_pqclean);
util::StatusOr<std::unique_ptr<PublicKeyVerify>> verifier =
subtle::SphincsVerify::New(sphincs_public_key_pqclean);
diff --git a/tink/experimental/pqcrypto/signature/sphincs_verify_key_manager.cc b/tink/experimental/pqcrypto/signature/sphincs_verify_key_manager.cc
index 0acf19caf..8e49b84c2 100644
--- a/tink/experimental/pqcrypto/signature/sphincs_verify_key_manager.cc
+++ b/tink/experimental/pqcrypto/signature/sphincs_verify_key_manager.cc
@@ -17,6 +17,7 @@
#include "tink/experimental/pqcrypto/signature/sphincs_verify_key_manager.h"
#include <memory>
+#include <string>
#include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
@@ -55,8 +56,8 @@ SphincsVerifyKeyManager::PublicKeyVerifyFactory::Create(
EnumsPqcrypto::ProtoToSubtle(public_key.params().sig_length_type()),
.private_key_size = public_key.params().key_size()};
- SphincsPublicKeyPqclean sphincs_public_key_pqclean(public_key.key_value(),
- sphincs_params_pqclean);
+ SphincsPublicKeyPqclean sphincs_public_key_pqclean(
+ std::string(public_key.key_value()), sphincs_params_pqclean);
return subtle::SphincsVerify::New(sphincs_public_key_pqclean);
}
diff --git a/tink/hybrid/internal/hpke_private_key_manager_test.cc b/tink/hybrid/internal/hpke_private_key_manager_test.cc
index 63a6656b3..afdefebd3 100644
--- a/tink/hybrid/internal/hpke_private_key_manager_test.cc
+++ b/tink/hybrid/internal/hpke_private_key_manager_test.cc
@@ -151,7 +151,7 @@ TEST(HpkePrivateKeyManagerTest, CreateP256KeySucceeds) {
util::StatusOr<HpkePrivateKey> key =
HpkePrivateKeyManager().CreateKey(key_format);
ASSERT_THAT(key, IsOk());
- private_keys.insert(key->private_key());
+ private_keys.insert(std::string(key->private_key()));
public_keys.insert(key->public_key().public_key());
}
EXPECT_THAT(private_keys.size(), Eq(number_of_keys));
@@ -184,7 +184,7 @@ TEST(HpkePrivateKeyManagerTest, CreateP384KeySucceeds) {
util::StatusOr<HpkePrivateKey> key =
HpkePrivateKeyManager().CreateKey(key_format);
ASSERT_THAT(key, IsOk());
- private_keys.insert(key->private_key());
+ private_keys.insert(std::string(key->private_key()));
public_keys.insert(key->public_key().public_key());
}
EXPECT_THAT(private_keys.size(), Eq(number_of_keys));
@@ -217,7 +217,7 @@ TEST(HpkePrivateKeyManagerTest, CreateP521KeySucceeds) {
util::StatusOr<HpkePrivateKey> key =
HpkePrivateKeyManager().CreateKey(key_format);
ASSERT_THAT(key, IsOk());
- private_keys.insert(key->private_key());
+ private_keys.insert(std::string(key->private_key()));
public_keys.insert(key->public_key().public_key());
}
EXPECT_THAT(private_keys.size(), Eq(number_of_keys));
diff --git a/tink/internal/BUILD.bazel b/tink/internal/BUILD.bazel
index 8bd8c3c91..9606f5fd7 100644
--- a/tink/internal/BUILD.bazel
+++ b/tink/internal/BUILD.bazel
@@ -1132,6 +1132,7 @@ cc_test(
"//tink/util:test_util",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
+ "@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
],
)
@@ -1231,6 +1232,7 @@ cc_test(
"//tink/util:test_util",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
+ "@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
],
)
@@ -1277,6 +1279,7 @@ cc_test(
"//tink/util:test_util",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
+ "@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
],
)
diff --git a/tink/internal/CMakeLists.txt b/tink/internal/CMakeLists.txt
index 642dffb79..cf4362d14 100644
--- a/tink/internal/CMakeLists.txt
+++ b/tink/internal/CMakeLists.txt
@@ -1062,6 +1062,7 @@ tink_cc_test(
gmock
absl::memory
absl::status
+ absl::string_view
tink::core::cleartext_keyset_handle
tink::core::configuration
tink::core::key_manager_impl
@@ -1167,6 +1168,7 @@ tink_cc_test(
gmock
absl::memory
absl::status
+ absl::string_view
tink::core::key_type_manager
tink::core::template_util
tink::core::input_stream
@@ -1207,6 +1209,7 @@ tink_cc_test(
gmock
absl::memory
absl::status
+ absl::string_view
tink::core::key_manager_impl
tink::core::key_type_manager
tink::core::private_key_type_manager
diff --git a/tink/internal/configuration_impl_test.cc b/tink/internal/configuration_impl_test.cc
index 6bc8d3063..686b44bdf 100644
--- a/tink/internal/configuration_impl_test.cc
+++ b/tink/internal/configuration_impl_test.cc
@@ -24,6 +24,7 @@
#include "gtest/gtest.h"
#include "absl/memory/memory.h"
#include "absl/status/status.h"
+#include "absl/strings/string_view.h"
#include "tink/cleartext_keyset_handle.h"
#include "tink/configuration.h"
#include "tink/core/key_manager_impl.h"
@@ -70,7 +71,7 @@ using ::google::crypto::tink::RsaSsaPssPublicKey;
class FakePrimitive {
public:
- explicit FakePrimitive(std::string s) : s_(s) {}
+ explicit FakePrimitive(absl::string_view s) : s_(s) {}
std::string get() { return s_; }
private:
@@ -79,7 +80,7 @@ class FakePrimitive {
class FakePrimitive2 {
public:
- explicit FakePrimitive2(std::string s) : s_(s) {}
+ explicit FakePrimitive2(absl::string_view s) : s_(s) {}
std::string get() { return s_ + "2"; }
private:
@@ -169,7 +170,7 @@ std::string AddAesGcmKeyToKeyset(Keyset& keyset, uint32_t key_id,
key_data.set_type_url("type.googleapis.com/google.crypto.tink.AesGcmKey");
test::AddKeyData(key_data, key_id, output_prefix_type, key_status_type,
&keyset);
- return key.key_value();
+ return std::string(key.key_value());
}
TEST(ConfigurationImplTest, AddPrimitiveWrapper) {
diff --git a/tink/internal/key_gen_configuration_impl_test.cc b/tink/internal/key_gen_configuration_impl_test.cc
index 6e52e7f88..e4e0996c5 100644
--- a/tink/internal/key_gen_configuration_impl_test.cc
+++ b/tink/internal/key_gen_configuration_impl_test.cc
@@ -24,6 +24,7 @@
#include "gtest/gtest.h"
#include "absl/memory/memory.h"
#include "absl/status/status.h"
+#include "absl/strings/string_view.h"
#include "tink/aead/aead_key_templates.h"
#include "tink/core/key_manager_impl.h"
#include "tink/core/key_type_manager.h"
@@ -62,7 +63,7 @@ using ::google::crypto::tink::RsaSsaPssPublicKey;
class FakePrimitive {
public:
- explicit FakePrimitive(std::string s) : s_(s) {}
+ explicit FakePrimitive(absl::string_view s) : s_(s) {}
std::string get() { return s_; }
private:
diff --git a/tink/internal/keyset_wrapper_store_test.cc b/tink/internal/keyset_wrapper_store_test.cc
index fc386649a..228e07511 100644
--- a/tink/internal/keyset_wrapper_store_test.cc
+++ b/tink/internal/keyset_wrapper_store_test.cc
@@ -26,6 +26,7 @@
#include "gtest/gtest.h"
#include "absl/memory/memory.h"
#include "absl/status/status.h"
+#include "absl/strings/string_view.h"
#include "tink/core/key_type_manager.h"
#include "tink/core/template_util.h"
#include "tink/input_stream.h"
@@ -61,7 +62,7 @@ using ::testing::Eq;
class FakePrimitive {
public:
- explicit FakePrimitive(std::string s) : s_(s) {}
+ explicit FakePrimitive(absl::string_view s) : s_(s) {}
std::string get() { return s_; }
private:
@@ -148,7 +149,7 @@ std::string AddAesGcmKeyToKeyset(Keyset& keyset, uint32_t key_id,
key_data.set_type_url("type.googleapis.com/google.crypto.tink.AesGcmKey");
test::AddKeyData(key_data, key_id, output_prefix_type, key_status_type,
&keyset);
- return key.key_value();
+ return std::string(key.key_value());
}
// Returns the function that relies on `registry` to transform `key_data` into
diff --git a/tink/internal/registry_impl_test.cc b/tink/internal/registry_impl_test.cc
index c41b631a6..b18ad573b 100644
--- a/tink/internal/registry_impl_test.cc
+++ b/tink/internal/registry_impl_test.cc
@@ -175,7 +175,7 @@ class TestAeadKeyManager : public KeyManager<Aead> {
// insecure, as it does nothing except provide access to the key.
class AeadVariant {
public:
- explicit AeadVariant(std::string s) : s_(s) {}
+ explicit AeadVariant(absl::string_view s) : s_(s) {}
std::string get() { return s_; }
@@ -847,7 +847,7 @@ std::string AddAesGcmKey(uint32_t key_id, OutputPrefixType output_prefix_type,
key_data.set_type_url("type.googleapis.com/google.crypto.tink.AesGcmKey");
test::AddKeyData(key_data, key_id, output_prefix_type, key_status_type,
&modified_keyset);
- return key.key_value();
+ return std::string(key.key_value());
}
// Tests that wrapping of a keyset works in the usual case.
diff --git a/tink/signature/ed25519_sign_key_manager_test.cc b/tink/signature/ed25519_sign_key_manager_test.cc
index 7590ee8f8..87c84c44a 100644
--- a/tink/signature/ed25519_sign_key_manager_test.cc
+++ b/tink/signature/ed25519_sign_key_manager_test.cc
@@ -95,7 +95,7 @@ TEST(Ed25519SignKeyManagerTest, CreateKeyAlwaysNew) {
StatusOr<Ed25519PrivateKey> key_or =
Ed25519SignKeyManager().CreateKey(Ed25519KeyFormat());
ASSERT_THAT(key_or, IsOk());
- keys.insert(key_or.value().key_value());
+ keys.insert(std::string(key_or.value().key_value()));
}
EXPECT_THAT(keys, SizeIs(num_tests));
}