aboutsummaryrefslogtreecommitdiff
path: root/cc/experimental
diff options
context:
space:
mode:
authorlizatretyakova <lizatretyakova@google.com>2021-11-01 05:48:32 -0700
committerCopybara-Service <copybara-worker@google.com>2021-11-01 05:49:36 -0700
commit456657f9e5d5ed4193358e2772553f846e57150d (patch)
tree11ffa8aa645697ba0424952f21e2bd10d7c6601c /cc/experimental
parent010a2962dcce23be6b70ddf6141150e9e8680089 (diff)
downloadtink-456657f9e5d5ed4193358e2772553f846e57150d.tar.gz
Replace the deprecated crypto::tink::util::error::INTERNAL usages with its absl version absl::StatusCode::kInternal in third_party/tink/cc.
This CL is a part of Tink migration to using absl::Status{,Or} and absl::StatusCode. PiperOrigin-RevId: 406805638
Diffstat (limited to 'cc/experimental')
-rw-r--r--cc/experimental/pqcrypto/cecpq2/hybrid/BUILD.bazel1
-rw-r--r--cc/experimental/pqcrypto/cecpq2/hybrid/cecpq2_aead_hkdf_dem_helper.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_sign.cc14
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_sign_test.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_verify.cc12
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_verify_test.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/falcon_sign.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/falcon_sign_test.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/falcon_subtle_utils.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/falcon_verify.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/falcon_verify_test.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/sphincs_sign.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/sphincs_sign_test.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/sphincs_subtle_utils.cc3
-rw-r--r--cc/experimental/pqcrypto/signature/subtle/sphincs_verify_test.cc3
15 files changed, 42 insertions, 21 deletions
diff --git a/cc/experimental/pqcrypto/cecpq2/hybrid/BUILD.bazel b/cc/experimental/pqcrypto/cecpq2/hybrid/BUILD.bazel
index dfe6762cb..68e06e2f5 100644
--- a/cc/experimental/pqcrypto/cecpq2/hybrid/BUILD.bazel
+++ b/cc/experimental/pqcrypto/cecpq2/hybrid/BUILD.bazel
@@ -40,6 +40,7 @@ cc_library(
srcs = ["cecpq2_aead_hkdf_dem_helper.cc"],
hdrs = ["cecpq2_aead_hkdf_dem_helper.h"],
deps = [
+ "@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@tink_cc//:aead",
"@tink_cc//:deterministic_aead",
diff --git a/cc/experimental/pqcrypto/cecpq2/hybrid/cecpq2_aead_hkdf_dem_helper.cc b/cc/experimental/pqcrypto/cecpq2/hybrid/cecpq2_aead_hkdf_dem_helper.cc
index 11950dd0c..fdb574812 100644
--- a/cc/experimental/pqcrypto/cecpq2/hybrid/cecpq2_aead_hkdf_dem_helper.cc
+++ b/cc/experimental/pqcrypto/cecpq2/hybrid/cecpq2_aead_hkdf_dem_helper.cc
@@ -19,6 +19,7 @@
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/status/status.h"
#include "tink/aead.h"
#include "tink/deterministic_aead.h"
#include "tink/registry.h"
@@ -49,7 +50,7 @@ class Cecpq2AeadHkdfDemHelperImpl : public Cecpq2AeadHkdfDemHelper {
std::unique_ptr<crypto::tink::subtle::AeadOrDaead>>
GetAeadOrDaead(const util::SecretData& seed) const override {
if (seed.size() < 32) {
- return util::Status(util::error::INTERNAL,
+ return util::Status(absl::StatusCode::kInternal,
"Seed length is smaller than 32 bytes "
"and thus not post-quantum secure.");
}
diff --git a/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_sign.cc b/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_sign.cc
index 713bcb6b2..80753c95a 100644
--- a/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_sign.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_sign.cc
@@ -24,6 +24,7 @@
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "tink/experimental/pqcrypto/signature/subtle/dilithium_key.h"
@@ -97,7 +98,8 @@ util::StatusOr<std::string> DilithiumAvx2Sign::Sign(
break;
}
default: {
- return util::Status(util::error::INTERNAL, "Invalid seed expansion.");
+ return util::Status(absl::StatusCode::kInternal,
+ "Invalid seed expansion.");
}
}
break;
@@ -123,7 +125,8 @@ util::StatusOr<std::string> DilithiumAvx2Sign::Sign(
break;
}
default: {
- return util::Status(util::error::INTERNAL, "Invalid seed expansion.");
+ return util::Status(absl::StatusCode::kInternal,
+ "Invalid seed expansion.");
}
}
break;
@@ -149,17 +152,18 @@ util::StatusOr<std::string> DilithiumAvx2Sign::Sign(
break;
}
default: {
- return util::Status(util::error::INTERNAL, "Invalid seed expansion.");
+ return util::Status(absl::StatusCode::kInternal,
+ "Invalid seed expansion.");
}
}
break;
}
default:
- return util::Status(util::error::INTERNAL, "Invalid keysize.");
+ return util::Status(absl::StatusCode::kInternal, "Invalid keysize.");
}
if (result != 0) {
- return util::Status(util::error::INTERNAL, "Signing failed.");
+ return util::Status(absl::StatusCode::kInternal, "Signing failed.");
}
return signature;
diff --git a/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_sign_test.cc b/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_sign_test.cc
index 03a50bf6b..42f2b4d44 100644
--- a/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_sign_test.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_sign_test.cc
@@ -22,6 +22,7 @@
#include "gmock/gmock.h"
#include "testing/base/public/googletest.h"
#include "gtest/gtest.h"
+#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "tink/config/tink_fips.h"
#include "tink/experimental/pqcrypto/signature/subtle/dilithium_key.h"
@@ -174,7 +175,7 @@ TEST_P(DilithiumAvx2SignTest, FipsMode) {
// Create a new signer.
EXPECT_THAT(DilithiumAvx2Sign::New(key_pair->first).status(),
- StatusIs(util::error::INTERNAL));
+ StatusIs(absl::StatusCode::kInternal));
}
INSTANTIATE_TEST_SUITE_P(
diff --git a/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_verify.cc b/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_verify.cc
index 493052b30..23e4bf2a1 100644
--- a/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_verify.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_verify.cc
@@ -23,6 +23,7 @@
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "tink/experimental/pqcrypto/signature/subtle/dilithium_key.h"
@@ -93,7 +94,8 @@ util::Status DilithiumAvx2Verify::Verify(absl::string_view signature,
break;
}
default: {
- return util::Status(util::error::INTERNAL, "Invalid seed expansion.");
+ return util::Status(absl::StatusCode::kInternal,
+ "Invalid seed expansion.");
}
}
break;
@@ -119,7 +121,8 @@ util::Status DilithiumAvx2Verify::Verify(absl::string_view signature,
break;
}
default: {
- return util::Status(util::error::INTERNAL, "Invalid seed expansion.");
+ return util::Status(absl::StatusCode::kInternal,
+ "Invalid seed expansion.");
}
}
break;
@@ -145,13 +148,14 @@ util::Status DilithiumAvx2Verify::Verify(absl::string_view signature,
break;
}
default: {
- return util::Status(util::error::INTERNAL, "Invalid seed expansion.");
+ return util::Status(absl::StatusCode::kInternal,
+ "Invalid seed expansion.");
}
}
break;
}
default:
- return util::Status(util::error::INTERNAL, "Invalid keysize.");
+ return util::Status(absl::StatusCode::kInternal, "Invalid keysize.");
}
if (result != 0) {
diff --git a/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_verify_test.cc b/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_verify_test.cc
index 2e9cae07a..978355a51 100644
--- a/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_verify_test.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/dilithium_avx2_verify_test.cc
@@ -22,6 +22,7 @@
#include "gmock/gmock.h"
#include "testing/base/public/googletest.h"
#include "gtest/gtest.h"
+#include "absl/status/status.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h"
#include "tink/config/tink_fips.h"
@@ -249,7 +250,7 @@ TEST_P(DilithiumAvx2VerifyTest, FipsMode) {
ASSERT_THAT(key_pair.status(), IsOk());
EXPECT_THAT(DilithiumAvx2Verify::New(key_pair->second).status(),
- StatusIs(util::error::INTERNAL));
+ StatusIs(absl::StatusCode::kInternal));
}
struct TestVector {
diff --git a/cc/experimental/pqcrypto/signature/subtle/falcon_sign.cc b/cc/experimental/pqcrypto/signature/subtle/falcon_sign.cc
index d873946e2..87aa05379 100644
--- a/cc/experimental/pqcrypto/signature/subtle/falcon_sign.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/falcon_sign.cc
@@ -20,6 +20,7 @@
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "tink/experimental/pqcrypto/signature/subtle/falcon_subtle_utils.h"
#include "tink/util/secret_data.h"
@@ -77,7 +78,7 @@ util::StatusOr<std::string> FalconSign::Sign(absl::string_view data) const {
}
if (result != 0) {
- return util::Status(util::error::INTERNAL, "Signing failed.");
+ return util::Status(absl::StatusCode::kInternal, "Signing failed.");
}
signature.resize(sig_length);
diff --git a/cc/experimental/pqcrypto/signature/subtle/falcon_sign_test.cc b/cc/experimental/pqcrypto/signature/subtle/falcon_sign_test.cc
index d120a745a..61094a38f 100644
--- a/cc/experimental/pqcrypto/signature/subtle/falcon_sign_test.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/falcon_sign_test.cc
@@ -21,6 +21,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "tink/config/tink_fips.h"
#include "tink/util/status.h"
@@ -124,7 +125,7 @@ TEST_P(FalconSignTest, FipsMode) {
// Create a new signer.
EXPECT_THAT(FalconSign::New(key_pair->GetPrivateKey()).status(),
- test::StatusIs(util::error::INTERNAL));
+ test::StatusIs(absl::StatusCode::kInternal));
}
INSTANTIATE_TEST_SUITE_P(
diff --git a/cc/experimental/pqcrypto/signature/subtle/falcon_subtle_utils.cc b/cc/experimental/pqcrypto/signature/subtle/falcon_subtle_utils.cc
index 24555ef11..16fa60bb5 100644
--- a/cc/experimental/pqcrypto/signature/subtle/falcon_subtle_utils.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/falcon_subtle_utils.cc
@@ -20,6 +20,7 @@
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "tink/experimental/pqcrypto/signature/subtle/sphincs_helper_pqclean.h"
#include "tink/util/secret_data.h"
@@ -101,7 +102,7 @@ crypto::tink::util::StatusOr<FalconKeyPair> GenerateFalconKeyPair(
FalconPublicKeyPqclean::NewPublicKey(public_key);
if (!falcon_private_key.ok() || !falcon_public_key.ok()) {
- return util::Status(util::error::INTERNAL, "Key generation failed.");
+ return util::Status(absl::StatusCode::kInternal, "Key generation failed.");
}
FalconKeyPair key_pair(*falcon_private_key, *falcon_public_key);
diff --git a/cc/experimental/pqcrypto/signature/subtle/falcon_verify.cc b/cc/experimental/pqcrypto/signature/subtle/falcon_verify.cc
index f50aeb6bc..41367b47f 100644
--- a/cc/experimental/pqcrypto/signature/subtle/falcon_verify.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/falcon_verify.cc
@@ -20,6 +20,7 @@
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "tink/experimental/pqcrypto/signature/subtle/falcon_subtle_utils.h"
#include "tink/util/secret_data.h"
@@ -69,7 +70,7 @@ util::Status FalconVerify::Verify(absl::string_view signature,
}
if (result != 0) {
- return util::Status(util::error::INTERNAL, "Signature is not valid.");
+ return util::Status(absl::StatusCode::kInternal, "Signature is not valid.");
}
return util::Status::OK;
diff --git a/cc/experimental/pqcrypto/signature/subtle/falcon_verify_test.cc b/cc/experimental/pqcrypto/signature/subtle/falcon_verify_test.cc
index ddf1d5794..361100eaa 100644
--- a/cc/experimental/pqcrypto/signature/subtle/falcon_verify_test.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/falcon_verify_test.cc
@@ -21,6 +21,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#include "absl/status/status.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h"
#include "tink/config/tink_fips.h"
@@ -200,7 +201,7 @@ TEST_P(FalconVerifyTest, FipsMode) {
// Create a new signer.
EXPECT_THAT(FalconVerify::New(key_pair->GetPublicKey()).status(),
- StatusIs(util::error::INTERNAL));
+ StatusIs(absl::StatusCode::kInternal));
}
INSTANTIATE_TEST_SUITE_P(
diff --git a/cc/experimental/pqcrypto/signature/subtle/sphincs_sign.cc b/cc/experimental/pqcrypto/signature/subtle/sphincs_sign.cc
index 9aa46c167..ee8257d77 100644
--- a/cc/experimental/pqcrypto/signature/subtle/sphincs_sign.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/sphincs_sign.cc
@@ -20,6 +20,7 @@
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "tink/experimental/pqcrypto/signature/subtle/sphincs_helper_pqclean.h"
#include "tink/experimental/pqcrypto/signature/subtle/sphincs_subtle_utils.h"
@@ -67,7 +68,7 @@ util::StatusOr<std::string> SphincsSign::Sign(absl::string_view data) const {
reinterpret_cast<uint8_t *>(signature.data()), &sig_length,
reinterpret_cast<const uint8_t *>(data.data()), data.size(),
reinterpret_cast<const uint8_t *>(key_.GetKey().data())) != 0)) {
- return util::Status(util::error::INTERNAL, "Signing failed.");
+ return util::Status(absl::StatusCode::kInternal, "Signing failed.");
}
return signature;
diff --git a/cc/experimental/pqcrypto/signature/subtle/sphincs_sign_test.cc b/cc/experimental/pqcrypto/signature/subtle/sphincs_sign_test.cc
index c338de236..9126545b7 100644
--- a/cc/experimental/pqcrypto/signature/subtle/sphincs_sign_test.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/sphincs_sign_test.cc
@@ -21,6 +21,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "tink/config/tink_fips.h"
#include "tink/experimental/pqcrypto/signature/subtle/sphincs_helper_pqclean.h"
@@ -190,7 +191,7 @@ TEST_P(SphincsSignTest, FipsMode) {
// Create a new signer.
EXPECT_THAT(SphincsSign::New(key_pair->GetPrivateKey()).status(),
- StatusIs(util::error::INTERNAL));
+ StatusIs(absl::StatusCode::kInternal));
}
INSTANTIATE_TEST_SUITE_P(
diff --git a/cc/experimental/pqcrypto/signature/subtle/sphincs_subtle_utils.cc b/cc/experimental/pqcrypto/signature/subtle/sphincs_subtle_utils.cc
index ca6ab6b73..2460a4d71 100644
--- a/cc/experimental/pqcrypto/signature/subtle/sphincs_subtle_utils.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/sphincs_subtle_utils.cc
@@ -20,6 +20,7 @@
#include <utility>
#include "absl/memory/memory.h"
+#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "tink/experimental/pqcrypto/signature/subtle/sphincs_helper_pqclean.h"
#include "tink/util/secret_data.h"
@@ -56,7 +57,7 @@ crypto::tink::util::StatusOr<SphincsKeyPair> GenerateSphincsKeyPair(
if (0 != sphincs_helper_pqclean.Keygen(
reinterpret_cast<uint8_t *>(public_key.data()),
reinterpret_cast<uint8_t *>(private_key.data()))) {
- return util::Status(util::error::INTERNAL, "Key generation failed.");
+ return util::Status(absl::StatusCode::kInternal, "Key generation failed.");
}
util::SecretData private_key_data =
diff --git a/cc/experimental/pqcrypto/signature/subtle/sphincs_verify_test.cc b/cc/experimental/pqcrypto/signature/subtle/sphincs_verify_test.cc
index 660a2a5d8..d19d3e1e9 100644
--- a/cc/experimental/pqcrypto/signature/subtle/sphincs_verify_test.cc
+++ b/cc/experimental/pqcrypto/signature/subtle/sphincs_verify_test.cc
@@ -21,6 +21,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "tink/config/tink_fips.h"
#include "tink/experimental/pqcrypto/signature/subtle/sphincs_helper_pqclean.h"
@@ -267,7 +268,7 @@ TEST_P(SphincsVerifyTest, FipsMode) {
// Create a new signer.
EXPECT_THAT(SphincsVerify::New(key_pair->GetPublicKey()).status(),
- StatusIs(util::error::INTERNAL));
+ StatusIs(absl::StatusCode::kInternal));
}
// TODO(ioannanedelcu): Add test with testvectors.