mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Fix github build
PiperOrigin-RevId: 465689821
This commit is contained in:
committed by
Copybara-Service
parent
9b12bdde8d
commit
4c70daf66f
+13
-1
@@ -375,7 +375,6 @@ let package = Package(
|
||||
"connections/clients/windows",
|
||||
"connections/samples",
|
||||
"docs",
|
||||
"internal/crypto",
|
||||
"internal/platform/implementation/g3",
|
||||
"internal/platform/implementation/ios/Tests",
|
||||
"internal/platform/implementation/ios/Mediums/Ble/Sockets/Tests",
|
||||
@@ -395,6 +394,8 @@ let package = Package(
|
||||
"connections/implementation/BUILD",
|
||||
"connections/implementation/fuzzers",
|
||||
"connections/BUILD",
|
||||
"internal/crypto/BUILD",
|
||||
"internal/crypto/BUILD.gn",
|
||||
"internal/proto/analytics/BUILD",
|
||||
"internal/platform/implementation/shared/BUILD",
|
||||
"internal/platform/implementation/ios/Mediums/BUILD",
|
||||
@@ -455,6 +456,17 @@ let package = Package(
|
||||
"connections/core_test.cc",
|
||||
"connections/status_test.cc",
|
||||
"connections/payload_test.cc",
|
||||
"internal/crypto/aead_unittest.cc",
|
||||
"internal/crypto/ec_private_key_unittest.cc",
|
||||
"internal/crypto/ec_signature_creator_unittest.cc",
|
||||
"internal/crypto/encryptor_unittest.cc",
|
||||
"internal/crypto/hmac_unittest.cc",
|
||||
"internal/crypto/random_unittest.cc",
|
||||
"internal/crypto/rsa_private_key_unittest.cc",
|
||||
"internal/crypto/secure_hash_unittest.cc",
|
||||
"internal/crypto/sha2_unittest.cc",
|
||||
"internal/crypto/signature_verifier_unittest.cc",
|
||||
"internal/crypto/symmetric_key_unittest.cc",
|
||||
"internal/proto/analytics/connections_log_test.cc",
|
||||
"internal/platform/feature_flags_test.cc",
|
||||
"internal/platform/cancelable_alarm_test.cc",
|
||||
|
||||
@@ -97,7 +97,7 @@ bool Aead::Seal(absl::string_view plaintext, absl::string_view nonce,
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<std::vector<uint8_t>> Aead::Open(
|
||||
absl::optional<std::vector<uint8_t>> Aead::Open(
|
||||
absl::Span<const uint8_t> ciphertext, absl::Span<const uint8_t> nonce,
|
||||
absl::Span<const uint8_t> additional_data) const {
|
||||
const size_t max_output_length = ciphertext.size();
|
||||
@@ -107,7 +107,7 @@ std::optional<std::vector<uint8_t>> Aead::Open(
|
||||
size_t output_length;
|
||||
if (!Open(ciphertext, nonce, additional_data, ret.data(), &output_length,
|
||||
max_output_length)) {
|
||||
return std::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
ret.resize(output_length);
|
||||
|
||||
@@ -64,7 +64,7 @@ class CRYPTO_EXPORT Aead {
|
||||
bool Seal(absl::string_view plaintext, absl::string_view nonce,
|
||||
absl::string_view additional_data, std::string* ciphertext) const;
|
||||
|
||||
std::optional<std::vector<uint8_t>> Open(
|
||||
absl::optional<std::vector<uint8_t>> Open(
|
||||
absl::Span<const uint8_t> ciphertext, absl::Span<const uint8_t> nonce,
|
||||
absl::Span<const uint8_t> additional_data) const;
|
||||
|
||||
@@ -86,7 +86,7 @@ class CRYPTO_EXPORT Aead {
|
||||
absl::Span<const uint8_t> additional_data, uint8_t* out,
|
||||
size_t* output_length, size_t max_output_length) const;
|
||||
|
||||
std::optional<absl::Span<const uint8_t>> key_;
|
||||
absl::optional<absl::Span<const uint8_t>> key_;
|
||||
const evp_aead_st* aead_;
|
||||
};
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ TEST_P(AeadTest, SealOpenSpan) {
|
||||
aead.Seal(kPlaintext, nonce, kAdditionalData);
|
||||
EXPECT_LT(sizeof(kPlaintext), ciphertext.size());
|
||||
|
||||
std::optional<std::vector<uint8_t>> decrypted =
|
||||
absl::optional<std::vector<uint8_t>> decrypted =
|
||||
aead.Open(ciphertext, nonce, kAdditionalData);
|
||||
ASSERT_TRUE(decrypted);
|
||||
ASSERT_EQ(decrypted->size(), sizeof(kPlaintext));
|
||||
|
||||
@@ -119,7 +119,7 @@ bool Encryptor::CryptString(bool do_encrypt, absl::string_view input,
|
||||
uint8_t* out_ptr =
|
||||
reinterpret_cast<uint8_t*>(nearbybase::WriteInto(&result, out_size + 1));
|
||||
|
||||
std::optional<size_t> len =
|
||||
absl::optional<size_t> len =
|
||||
(mode_ == CTR)
|
||||
? CryptCTR(do_encrypt, nearbybase::as_bytes(absl::MakeSpan(input)),
|
||||
absl::MakeSpan(out_ptr, out_size))
|
||||
@@ -135,7 +135,7 @@ bool Encryptor::CryptString(bool do_encrypt, absl::string_view input,
|
||||
bool Encryptor::CryptBytes(bool do_encrypt, absl::Span<const uint8_t> input,
|
||||
std::vector<uint8_t>* output) {
|
||||
std::vector<uint8_t> result(MaxOutput(do_encrypt, input.size()));
|
||||
std::optional<size_t> len =
|
||||
absl::optional<size_t> len =
|
||||
(mode_ == CTR) ? CryptCTR(do_encrypt, input, absl::MakeSpan(result))
|
||||
: Crypt(do_encrypt, input, absl::MakeSpan(result));
|
||||
if (!len) return false;
|
||||
@@ -151,7 +151,7 @@ size_t Encryptor::MaxOutput(bool do_encrypt, size_t length) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<size_t> Encryptor::Crypt(bool do_encrypt,
|
||||
absl::optional<size_t> Encryptor::Crypt(bool do_encrypt,
|
||||
absl::Span<const uint8_t> input,
|
||||
absl::Span<uint8_t> output) {
|
||||
DCHECK(key_); // Must call Init() before En/De-crypt.
|
||||
@@ -168,7 +168,7 @@ std::optional<size_t> Encryptor::Crypt(bool do_encrypt,
|
||||
if (!EVP_CipherInit_ex(ctx.get(), cipher, nullptr,
|
||||
reinterpret_cast<const uint8_t*>(key.data()),
|
||||
iv_.data(), do_encrypt)) {
|
||||
return std::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
// Encrypting needs a block size of space to allow for any padding.
|
||||
@@ -176,31 +176,31 @@ std::optional<size_t> Encryptor::Crypt(bool do_encrypt,
|
||||
int out_len;
|
||||
if (!EVP_CipherUpdate(ctx.get(), output.data(), &out_len, input.data(),
|
||||
input.size()))
|
||||
return std::nullopt;
|
||||
return absl::nullopt;
|
||||
|
||||
// Write out the final block plus padding (if any) to the end of the data
|
||||
// just written.
|
||||
int tail_len;
|
||||
if (!EVP_CipherFinal_ex(ctx.get(), output.data() + out_len, &tail_len))
|
||||
return std::nullopt;
|
||||
return absl::nullopt;
|
||||
|
||||
out_len += tail_len;
|
||||
DCHECK_LE(out_len, static_cast<int>(output.size()));
|
||||
return out_len;
|
||||
}
|
||||
|
||||
std::optional<size_t> Encryptor::CryptCTR(bool do_encrypt,
|
||||
absl::optional<size_t> Encryptor::CryptCTR(bool do_encrypt,
|
||||
absl::Span<const uint8_t> input,
|
||||
absl::Span<uint8_t> output) {
|
||||
if (iv_.size() != AES_BLOCK_SIZE) {
|
||||
NEARBY_LOGS(ERROR) << "Counter value not set in CTR mode.";
|
||||
return std::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
AES_KEY aes_key;
|
||||
if (AES_set_encrypt_key(reinterpret_cast<const uint8_t*>(key_->key().data()),
|
||||
key_->key().size() * 8, &aes_key) != 0) {
|
||||
return std::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
uint8_t ecount_buf[AES_BLOCK_SIZE] = {0};
|
||||
|
||||
@@ -94,9 +94,9 @@ class CRYPTO_EXPORT Encryptor {
|
||||
// On success, these helper functions return the number of bytes written to
|
||||
// |output|.
|
||||
size_t MaxOutput(bool do_encrypt, size_t length);
|
||||
std::optional<size_t> Crypt(bool do_encrypt, absl::Span<const uint8_t> input,
|
||||
absl::optional<size_t> Crypt(bool do_encrypt, absl::Span<const uint8_t> input,
|
||||
absl::Span<uint8_t> output);
|
||||
std::optional<size_t> CryptCTR(bool do_encrypt,
|
||||
absl::optional<size_t> CryptCTR(bool do_encrypt,
|
||||
absl::Span<const uint8_t> input,
|
||||
absl::Span<uint8_t> output);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ void SHA256HashString(absl::string_view str, void* output, size_t len) {
|
||||
|
||||
std::string SHA256HashString(absl::string_view str) {
|
||||
std::string output(kSHA256Length, 0);
|
||||
SHA256HashString(str, output.data(), output.size());
|
||||
SHA256HashString(str, &*output.begin(), output.size());
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,15 @@
|
||||
#define CHECK(condition) static_cast<void>(0), condition ? (void) 0 : abort()
|
||||
#define DCHECK(condition) static_cast<void>(0), (void) 0
|
||||
#define CHECK_GT(a, b) static_cast<void>(0), a > b ? (void) 0 : abort()
|
||||
#define DCHECK_GT(a, b) static_cast<void>(0), a > b ? (void) 0 : abort()
|
||||
#define CHECK_LE(a, b) static_cast<void>(0), a <= b ? (void) 0 : abort()
|
||||
#define DCHECK_LE(a, b) static_cast<void>(0), a <= b ? (void) 0 : abort()
|
||||
#define CHECK_NE(a, b) static_cast<void>(0), a != b ? (void) 0 : abort()
|
||||
#define DCHECK_NE(a, b) static_cast<void>(0), a != b ? (void) 0 : abort()
|
||||
#define CHECK_EQ(a, b) static_cast<void>(0), a == b ? (void) 0 : abort()
|
||||
#define DCHECK_EQ(a, b) static_cast<void>(0), a == b ? (void) 0 : abort()
|
||||
#define CHECK_GE(a, b) static_cast<void>(0), a >= b ? (void) 0 : abort()
|
||||
#define DCHECK_GE(a, b) static_cast<void>(0), a >= b ? (void) 0 : abort()
|
||||
#else
|
||||
#include "glog/logging.h"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user