mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Move crypto-related symbols from ::crypto:: to ::nearby::crypto:: to deconflict
them with chromium ::crypto symbols of the same names. PiperOrigin-RevId: 684566882
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
#include <openssl/base.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
constexpr size_t kEd25519SignatureSize = 64;
|
||||
constexpr size_t kEd25519PrivateKeySize = 32;
|
||||
@@ -181,4 +181,4 @@ absl::Status Ed25519Verifier::Verify(absl::string_view data,
|
||||
: absl::InternalError("Signature is invalid.");
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <openssl/digest.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
#ifdef OPENSSL_IS_BORINGSSL
|
||||
using CryptoKeyUniquePtr = ::bssl::UniquePtr<EVP_PKEY>;
|
||||
@@ -73,6 +73,6 @@ class CRYPTO_EXPORT Ed25519Verifier {
|
||||
CryptoKeyUniquePtr public_key_;
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_ED25519_H_
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
namespace {
|
||||
|
||||
using ::absl::StatusCode;
|
||||
@@ -211,4 +211,4 @@ TEST(Ed25519SignerVerifierTest, NewKeypairFromRandomSeedRoundtrip) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "internal/crypto_cros/openssl_util.h"
|
||||
#include <openssl/aead.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
Aead::Aead(AeadAlgorithm algorithm) {
|
||||
EnsureOpenSSLInit();
|
||||
@@ -186,4 +186,4 @@ bool Aead::Open(absl::Span<const uint8_t> plaintext,
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
#include <openssl/base.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// This class exposes the AES-128-CTR-HMAC-SHA256 and AES_256_GCM AEAD. Note
|
||||
// that there are two versions of most methods: an historical version based
|
||||
@@ -89,6 +89,6 @@ class CRYPTO_EXPORT Aead {
|
||||
const EVP_AEAD* aead_;
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_AEAD_H_
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace {
|
||||
|
||||
const crypto::Aead::AeadAlgorithm kAllAlgorithms[]{
|
||||
@@ -98,3 +99,4 @@ TEST_P(AeadTest, SealOpenWrongKey) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace nearby
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <openssl/mem.h>
|
||||
#include <openssl/pkcs8.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
ECPrivateKey::~ECPrivateKey() = default;
|
||||
|
||||
@@ -186,4 +186,4 @@ bool ECPrivateKey::ExportRawPublicKey(std::string* output) const {
|
||||
|
||||
ECPrivateKey::ECPrivateKey() = default;
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
#include <openssl/base.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// Encapsulates an elliptic curve (EC) private key. Can be used to generate new
|
||||
// keys, export keys to other formats, or to extract a public key.
|
||||
@@ -91,6 +91,6 @@ class CRYPTO_EXPORT ECPrivateKey {
|
||||
bssl::UniquePtr<EVP_PKEY> key_;
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_EC_PRIVATE_KEY_H_
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace {
|
||||
|
||||
void ExpectKeysEqual(const crypto::ECPrivateKey* keypair1,
|
||||
@@ -331,3 +332,5 @@ TEST(ECPrivateKeyUnitTest, LoadOldOpenSSLKeyTest) {
|
||||
|
||||
EXPECT_TRUE(keypair_openssl);
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "internal/crypto_cros/ec_signature_creator_impl.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// static
|
||||
std::unique_ptr<ECSignatureCreator> ECSignatureCreator::Create(
|
||||
@@ -26,4 +26,4 @@ std::unique_ptr<ECSignatureCreator> ECSignatureCreator::Create(
|
||||
return std::make_unique<ECSignatureCreatorImpl>(key);
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "absl/types/span.h"
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
class ECPrivateKey;
|
||||
class ECSignatureCreator;
|
||||
@@ -60,6 +60,6 @@ class CRYPTO_EXPORT ECSignatureCreator {
|
||||
std::vector<uint8_t>* out_raw_sig) = 0;
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_EC_SIGNATURE_CREATOR_H_
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
ECSignatureCreatorImpl::ECSignatureCreatorImpl(ECPrivateKey* key) : key_(key) {
|
||||
EnsureOpenSSLInit();
|
||||
@@ -80,4 +80,4 @@ bool ECSignatureCreatorImpl::DecodeSignature(
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "absl/types/span.h"
|
||||
#include "internal/crypto_cros/ec_signature_creator.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
class ECSignatureCreatorImpl : public ECSignatureCreator {
|
||||
public:
|
||||
@@ -43,6 +43,6 @@ class ECSignatureCreatorImpl : public ECSignatureCreator {
|
||||
ECPrivateKey* key_;
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_EC_SIGNATURE_CREATOR_IMPL_H_
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "internal/crypto_cros/nearby_base.h"
|
||||
#include "internal/crypto_cros/signature_verifier.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
TEST(ECSignatureCreatorTest, BasicTest) {
|
||||
// Do a verify round trip.
|
||||
std::unique_ptr<crypto::ECPrivateKey> key_original(
|
||||
@@ -59,3 +61,5 @@ TEST(ECSignatureCreatorTest, BasicTest) {
|
||||
verifier.VerifyUpdate(nearbybase::as_bytes(absl::MakeSpan(data)));
|
||||
ASSERT_TRUE(verifier.VerifyFinal());
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -225,4 +225,4 @@ absl::optional<size_t> Encryptor::CryptCTR(bool do_encrypt,
|
||||
return input.size();
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "absl/types/span.h"
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
class SymmetricKey;
|
||||
|
||||
@@ -105,6 +105,6 @@ class CRYPTO_EXPORT Encryptor {
|
||||
std::vector<uint8_t> iv_;
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_ENCRYPTOR_H_
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "internal/crypto_cros/nearby_base.h"
|
||||
#include "internal/crypto_cros/symmetric_key.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
TEST(EncryptorTest, EncryptDecrypt) {
|
||||
std::unique_ptr<crypto::SymmetricKey> key(
|
||||
crypto::SymmetricKey::DeriveKeyFromPasswordUsingPbkdf2(
|
||||
@@ -570,3 +572,5 @@ TEST(EncryptorTest, CipherTextNotMultipleOfBlockSize) {
|
||||
EXPECT_FALSE(
|
||||
encryptor.Decrypt(absl::string_view(ciphertext.get(), 1), &plaintext));
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "internal/crypto_cros/hmac.h"
|
||||
#include <openssl/digest.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
std::string HkdfSha256(absl::string_view secret, absl::string_view salt,
|
||||
absl::string_view info, size_t derived_key_size) {
|
||||
@@ -62,4 +62,4 @@ std::vector<uint8_t> HkdfSha256(absl::Span<const uint8_t> secret,
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "absl/types/span.h"
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
CRYPTO_EXPORT
|
||||
std::string HkdfSha256(absl::string_view secret, absl::string_view salt,
|
||||
@@ -36,6 +36,6 @@ std::vector<uint8_t> HkdfSha256(absl::Span<const uint8_t> secret,
|
||||
absl::Span<const uint8_t> info,
|
||||
size_t derived_key_size);
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_HKDF_H_
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "internal/crypto_cros/secure_util.h"
|
||||
#include "internal/crypto_cros/symmetric_key.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
HMAC::HMAC(HashAlgorithm hash_alg) : hash_alg_(hash_alg), initialized_(false) {
|
||||
// Only SHA-1 and SHA-256 hash algorithms are supported now.
|
||||
@@ -118,4 +118,4 @@ bool HMAC::VerifyTruncated(absl::Span<const uint8_t> data,
|
||||
return SecureMemEqual(digest.data(), computed_digest, digest.size());
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
#include "internal/crypto_cros/nearby_base.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// Simplify the interface and reduce includes by abstracting out the internals.
|
||||
class SymmetricKey;
|
||||
@@ -120,6 +120,6 @@ class CRYPTO_EXPORT HMAC {
|
||||
std::vector<unsigned char> key_;
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_HMAC_H_
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/span.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
static const size_t kSHA1DigestSize = 20;
|
||||
static const size_t kSHA256DigestSize = 32;
|
||||
|
||||
@@ -376,3 +378,5 @@ TEST(HMACTest, Bytes) {
|
||||
EXPECT_FALSE(hmac.VerifyTruncated(
|
||||
data, absl::MakeSpan(calculated_hmac, kSHA256DigestSize / 2)));
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
void EnsureOpenSSLInit() {
|
||||
// CRYPTO_library_init may be safely called concurrently.
|
||||
@@ -41,4 +41,4 @@ void ClearOpenSSLERRStack() {
|
||||
ERR_clear_error();
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// Provides a buffer of at least MIN_SIZE bytes, for use when calling OpenSSL's
|
||||
// SHA256, HMAC, etc functions, adapting the buffer sizing rules to meet those
|
||||
@@ -98,6 +98,6 @@ class OpenSSLErrStackTracer {
|
||||
~OpenSSLErrStackTracer() { ClearOpenSSLERRStack(); }
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_OPENSSL_UTIL_H_
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <openssl/mem.h>
|
||||
#include <openssl/rsa.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// static
|
||||
std::unique_ptr<RSAPrivateKey> RSAPrivateKey::Create(uint16_t num_bits) {
|
||||
@@ -126,4 +126,4 @@ bool RSAPrivateKey::ExportPublicKey(std::vector<uint8_t>* output) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
#include <openssl/base.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// Encapsulates an RSA private key. Can be used to generate new keys, export
|
||||
// keys to other formats, or to extract a public key.
|
||||
@@ -69,6 +69,6 @@ class CRYPTO_EXPORT RSAPrivateKey {
|
||||
bssl::UniquePtr<EVP_PKEY> key_;
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_RSA_PRIVATE_KEY_H_
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace {
|
||||
|
||||
const uint8_t kTestPrivateKeyInfo[] = {
|
||||
@@ -384,3 +385,5 @@ TEST(RSAPrivateKeyUnitTest, CreateFromKeyTest) {
|
||||
ASSERT_EQ(privkey, privkey_copy);
|
||||
ASSERT_EQ(pubkey, pubkey_copy);
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <openssl/mem.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -73,4 +73,4 @@ std::unique_ptr<SecureHash> SecureHash::Create(Algorithm algorithm) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// A wrapper to calculate secure hashes incrementally, allowing to
|
||||
// be used when the full input is not known in advance. The end result will the
|
||||
@@ -52,6 +52,6 @@ class CRYPTO_EXPORT SecureHash {
|
||||
SecureHash() {}
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_SECURE_HASH_H_
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "internal/crypto_cros/sha2.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
TEST(SecureHashTest, TestUpdate) {
|
||||
// Example B.3 from FIPS 180-2: long message.
|
||||
std::string input3(500000, 'a'); // 'a' repeated half a million times
|
||||
@@ -115,3 +117,5 @@ TEST(SecureHashTest, Equality) {
|
||||
// The hash should be the same.
|
||||
EXPECT_EQ(0, memcmp(output1, output2, crypto::kSHA256Length));
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
#include <openssl/mem.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
bool SecureMemEqual(const void* s1, const void* s2, size_t n) {
|
||||
return CRYPTO_memcmp(s1, s2, n) == 0;
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// Performs a constant-time comparison of two strings, returning true if the
|
||||
// strings are equal.
|
||||
@@ -33,6 +33,6 @@ namespace crypto {
|
||||
// http://groups.google.com/group/keyczar-discuss/browse_thread/thread/5571eca0948b2a13
|
||||
CRYPTO_EXPORT bool SecureMemEqual(const void* s1, const void* s2, size_t n);
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_SECURE_UTIL_H_
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "internal/crypto_cros/secure_hash.h"
|
||||
#include <openssl/sha.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
std::array<uint8_t, kSHA256Length> SHA256Hash(absl::Span<const uint8_t> input) {
|
||||
std::array<uint8_t, kSHA256Length> digest;
|
||||
@@ -44,4 +44,4 @@ std::string SHA256HashString(absl::string_view str) {
|
||||
return output;
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "absl/types/span.h"
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// These functions perform SHA-256 operations.
|
||||
//
|
||||
@@ -47,6 +47,6 @@ CRYPTO_EXPORT std::string SHA256HashString(absl::string_view str);
|
||||
CRYPTO_EXPORT void SHA256HashString(absl::string_view str, void* output,
|
||||
size_t len);
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_SHA2_H_
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
TEST(Sha256Test, Test1) {
|
||||
// Example B.1 from FIPS 180-2: one-block message.
|
||||
std::string input1 = "abc";
|
||||
@@ -96,3 +98,5 @@ TEST(Sha256Test, Test3) {
|
||||
for (size_t i = 0; i < sizeof(output_truncated3); i++)
|
||||
EXPECT_EQ(expected3[i], static_cast<int>(output_truncated3[i]));
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rsa.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
struct SignatureVerifier::VerifyContext {
|
||||
bssl::ScopedEVP_MD_CTX ctx;
|
||||
@@ -119,4 +119,4 @@ void SignatureVerifier::Reset() {
|
||||
signature_.clear();
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "absl/types/span.h"
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// The SignatureVerifier class verifies a signature using a bare public key
|
||||
// (as opposed to a certificate).
|
||||
@@ -76,6 +76,6 @@ class CRYPTO_EXPORT SignatureVerifier {
|
||||
std::unique_ptr<VerifyContext> verify_context_;
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_SIGNATURE_VERIFIER_H_
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/types/span.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
TEST(SignatureVerifierTest, BasicTest) {
|
||||
// The input data in this test comes from real certificates.
|
||||
//
|
||||
@@ -422,3 +424,5 @@ TEST(SignatureVerifierTest, VerifyRSAPSS) {
|
||||
verifier.VerifyUpdate(kPSSMessage);
|
||||
EXPECT_FALSE(verifier.VerifyFinal());
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -144,4 +144,4 @@ std::unique_ptr<SymmetricKey> SymmetricKey::Import(Algorithm algorithm,
|
||||
|
||||
SymmetricKey::SymmetricKey() = default;
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "internal/crypto_cros/crypto_export.h"
|
||||
|
||||
namespace crypto {
|
||||
namespace nearby::crypto {
|
||||
|
||||
// Wraps a platform-specific symmetric key and allows it to be held in a
|
||||
// scoped_ptr.
|
||||
@@ -84,6 +84,6 @@ class CRYPTO_EXPORT SymmetricKey {
|
||||
std::string key_;
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
} // namespace nearby::crypto
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_CRYPTO_SYMMETRIC_KEY_H_
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "absl/strings/ascii.h"
|
||||
#include "internal/crypto_cros/nearby_base.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
TEST(SymmetricKeyTest, GenerateRandomKey) {
|
||||
std::unique_ptr<crypto::SymmetricKey> key(
|
||||
crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, 256));
|
||||
@@ -260,3 +262,5 @@ INSTANTIATE_TEST_SUITE_P(All, SymmetricKeyDeriveKeyFromPasswordUsingPbkdf2Test,
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, SymmetricKeyDeriveKeyFromPasswordUsingScryptTest,
|
||||
testing::ValuesIn(kTestVectorsScrypt));
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
@@ -31,15 +31,9 @@
|
||||
#include "absl/types/variant.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/count_down_latch.h"
|
||||
#ifdef NEARBY_CHROMIUM
|
||||
#include "crypto/aead.h"
|
||||
#include "crypto/ec_private_key.h"
|
||||
#include "crypto/hkdf.h"
|
||||
#else
|
||||
#include "internal/crypto_cros/aead.h"
|
||||
#include "internal/crypto_cros/ec_private_key.h"
|
||||
#include "internal/crypto_cros/hkdf.h"
|
||||
#endif
|
||||
#include "internal/platform/base64_utils.h"
|
||||
#include "internal/platform/crypto.h"
|
||||
#include "internal/platform/future.h"
|
||||
@@ -86,7 +80,7 @@ absl::Duration RandomDuration(absl::Duration max_duration) {
|
||||
}
|
||||
|
||||
std::string CustomizeBytesSize(absl::string_view bytes, size_t len) {
|
||||
return ::crypto::HkdfSha256(
|
||||
return crypto::HkdfSha256(
|
||||
/*ikm=*/std::string(bytes), // NOLINT
|
||||
/*salt=*/std::string(CredentialManagerImpl::kAuthenticityKeyByteSize, 0),
|
||||
/*info=*/"", /*derived_key_size=*/len);
|
||||
|
||||
Reference in New Issue
Block a user