diff --git a/fastpair/handshake/BUILD b/fastpair/crypto/BUILD similarity index 77% rename from fastpair/handshake/BUILD rename to fastpair/crypto/BUILD index 7878752a..9dd2c09d 100644 --- a/fastpair/handshake/BUILD +++ b/fastpair/crypto/BUILD @@ -1,21 +1,5 @@ -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -licenses(["notice"]) - cc_library( - name = "handshake", + name = "crypto", srcs = [ "fast_pair_decryption.cc", "fast_pair_encryption.cc", @@ -34,6 +18,7 @@ cc_library( ], deps = [ "//fastpair/common", + "//internal/base:bluetooth_address", "//internal/platform:base", "//internal/platform:logging", "@boringssl//:crypto", @@ -50,7 +35,7 @@ cc_test( ], shard_count = 1, deps = [ - ":handshake", + ":crypto", "//internal/platform/implementation/g3", # build_cleaner: keep "@com_github_protobuf_matchers//protobuf-matchers", "@com_google_googletest//:gtest_main", @@ -65,7 +50,7 @@ cc_test( ], shard_count = 1, deps = [ - ":handshake", + ":crypto", "//internal/platform/implementation/g3", # build_cleaner: keep "@com_github_protobuf_matchers//protobuf-matchers", "@com_google_googletest//:gtest_main", @@ -80,7 +65,7 @@ cc_test( ], shard_count = 1, deps = [ - ":handshake", + ":crypto", "//internal/platform/implementation/g3", # build_cleaner: keep "@com_github_protobuf_matchers//protobuf-matchers", "@com_google_googletest//:gtest_main", @@ -95,7 +80,7 @@ cc_test( ], shard_count = 1, deps = [ - ":handshake", + ":crypto", "//fastpair/common", "//internal/platform/implementation/g3", # build_cleaner: keep "@com_github_protobuf_matchers//protobuf-matchers", @@ -112,7 +97,7 @@ cc_test( ], shard_count = 1, deps = [ - ":handshake", + ":crypto", "//internal/platform/implementation/g3", # build_cleaner: keep "@com_github_protobuf_matchers//protobuf-matchers", "@com_google_googletest//:gtest_main", diff --git a/fastpair/handshake/decrypted_passkey.h b/fastpair/crypto/decrypted_passkey.h similarity index 83% rename from fastpair/handshake/decrypted_passkey.h rename to fastpair/crypto/decrypted_passkey.h index 1f35cebd..166270bc 100644 --- a/fastpair/handshake/decrypted_passkey.h +++ b/fastpair/crypto/decrypted_passkey.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_DECRYPTED_PASSKEY_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_DECRYPTED_PASSKEY_H_ +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_DECRYPTED_PASSKEY_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_DECRYPTED_PASSKEY_H_ #include #include @@ -21,7 +21,7 @@ #include #include "fastpair/common/constant.h" -#include "fastpair/handshake/fast_pair_message_type.h" +#include "fastpair/crypto/fast_pair_message_type.h" namespace nearby { namespace fastpair { @@ -42,4 +42,4 @@ struct DecryptedPasskey { } // namespace fastpair } // namespace nearby -#endif // THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_DECRYPTED_PASSKEY_H_ +#endif // THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_DECRYPTED_PASSKEY_H_ diff --git a/fastpair/handshake/decrypted_passkey_test.cc b/fastpair/crypto/decrypted_passkey_test.cc similarity index 96% rename from fastpair/handshake/decrypted_passkey_test.cc rename to fastpair/crypto/decrypted_passkey_test.cc index afa66526..df6c98db 100644 --- a/fastpair/handshake/decrypted_passkey_test.cc +++ b/fastpair/crypto/decrypted_passkey_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/handshake/decrypted_passkey.h" +#include "fastpair/crypto/decrypted_passkey.h" #include diff --git a/fastpair/handshake/decrypted_response.h b/fastpair/crypto/decrypted_response.h similarity index 84% rename from fastpair/handshake/decrypted_response.h rename to fastpair/crypto/decrypted_response.h index 0f0549c6..eef4bacc 100644 --- a/fastpair/handshake/decrypted_response.h +++ b/fastpair/crypto/decrypted_response.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_DECRYPTED_RESPONSE_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_DECRYPTED_RESPONSE_H_ +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_DECRYPTED_RESPONSE_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_DECRYPTED_RESPONSE_H_ #include #include @@ -21,7 +21,7 @@ #include #include "fastpair/common/constant.h" -#include "fastpair/handshake/fast_pair_message_type.h" +#include "fastpair/crypto/fast_pair_message_type.h" namespace nearby { namespace fastpair { @@ -44,4 +44,4 @@ struct DecryptedResponse { } // namespace fastpair } // namespace nearby -#endif // THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_DECRYPTED_RESPONSE_H_ +#endif // THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_DECRYPTED_RESPONSE_H_ diff --git a/fastpair/handshake/decrypted_response_test.cc b/fastpair/crypto/decrypted_response_test.cc similarity index 96% rename from fastpair/handshake/decrypted_response_test.cc rename to fastpair/crypto/decrypted_response_test.cc index 6e32ec2a..d0a9f661 100644 --- a/fastpair/handshake/decrypted_response_test.cc +++ b/fastpair/crypto/decrypted_response_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/handshake/decrypted_response.h" +#include "fastpair/crypto/decrypted_response.h" #include diff --git a/fastpair/handshake/fast_pair_decryption.cc b/fastpair/crypto/fast_pair_decryption.cc similarity index 94% rename from fastpair/handshake/fast_pair_decryption.cc rename to fastpair/crypto/fast_pair_decryption.cc index e16d7021..08b3be21 100644 --- a/fastpair/handshake/fast_pair_decryption.cc +++ b/fastpair/crypto/fast_pair_decryption.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/handshake/fast_pair_decryption.h" +#include "fastpair/crypto/fast_pair_decryption.h" #include #include @@ -27,8 +27,8 @@ #include "absl/types/optional.h" #include "fastpair/common/constant.h" -#include "fastpair/handshake/decrypted_passkey.h" -#include "fastpair/handshake/decrypted_response.h" +#include "fastpair/crypto/decrypted_passkey.h" +#include "fastpair/crypto/decrypted_response.h" #include namespace nearby { @@ -43,8 +43,8 @@ std::array FastPairDecryption::DecryptBytes( CHECK(aes_key_was_set == 0) << "Invalid AES key size."; std::array decrypted_bytes; // Encrypted_bytes is less than 16 bytes and can be guaranteed to be a - // single block, so we encrypt/decrypt it using AES ECB mode - // (Approved by: b/73360609) + // single block, so we encrypt/decrypt it using AES ECB mode (Approved by: + // b/73360609) AES_decrypt(encrypted_bytes.data(), decrypted_bytes.data(), &aes_key); return decrypted_bytes; } diff --git a/fastpair/handshake/fast_pair_decryption.h b/fastpair/crypto/fast_pair_decryption.h similarity index 86% rename from fastpair/handshake/fast_pair_decryption.h rename to fastpair/crypto/fast_pair_decryption.h index 72e2a60f..ef3e0779 100644 --- a/fastpair/handshake/fast_pair_decryption.h +++ b/fastpair/crypto/fast_pair_decryption.h @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_DECRYPTION_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_DECRYPTION_H_ +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_DECRYPTION_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_DECRYPTION_H_ #include #include #include "absl/types/optional.h" -#include "fastpair/handshake/decrypted_passkey.h" -#include "fastpair/handshake/decrypted_response.h" +#include "fastpair/crypto/decrypted_passkey.h" +#include "fastpair/crypto/decrypted_response.h" namespace nearby { namespace fastpair { diff --git a/fastpair/handshake/fast_pair_decryption_test.cc b/fastpair/crypto/fast_pair_decryption_test.cc similarity index 97% rename from fastpair/handshake/fast_pair_decryption_test.cc rename to fastpair/crypto/fast_pair_decryption_test.cc index ad4ab9a6..234c6d26 100644 --- a/fastpair/handshake/fast_pair_decryption_test.cc +++ b/fastpair/crypto/fast_pair_decryption_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/handshake/fast_pair_decryption.h" +#include "fastpair/crypto/fast_pair_decryption.h" #include #include @@ -20,7 +20,7 @@ #include #include "gtest/gtest.h" -#include "fastpair/handshake/fast_pair_encryption.h" +#include "fastpair/crypto/fast_pair_encryption.h" namespace nearby { namespace fastpair { diff --git a/fastpair/handshake/fast_pair_encryption.cc b/fastpair/crypto/fast_pair_encryption.cc similarity index 97% rename from fastpair/handshake/fast_pair_encryption.cc rename to fastpair/crypto/fast_pair_encryption.cc index bf4e987a..dd8e6d70 100644 --- a/fastpair/handshake/fast_pair_encryption.cc +++ b/fastpair/crypto/fast_pair_encryption.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/handshake/fast_pair_encryption.h" +#include "fastpair/crypto/fast_pair_encryption.h" #include #include @@ -29,8 +29,8 @@ #include "absl/types/optional.h" #include "fastpair/common/constant.h" -#include "fastpair/handshake/fast_pair_key_pair.h" -#include "fastpair/handshake/fast_pair_message_type.h" +#include "fastpair/crypto/fast_pair_key_pair.h" +#include "fastpair/crypto/fast_pair_message_type.h" #include "internal/platform/logging.h" #include #include diff --git a/fastpair/handshake/fast_pair_encryption.h b/fastpair/crypto/fast_pair_encryption.h similarity index 83% rename from fastpair/handshake/fast_pair_encryption.h rename to fastpair/crypto/fast_pair_encryption.h index c51981d7..35a3ecb7 100644 --- a/fastpair/handshake/fast_pair_encryption.h +++ b/fastpair/crypto/fast_pair_encryption.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_ENCRYPTION_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_ENCRYPTION_H_ +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_ENCRYPTION_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_ENCRYPTION_H_ #include @@ -23,7 +23,7 @@ #include "absl/types/optional.h" #include "fastpair/common/constant.h" -#include "fastpair/handshake/fast_pair_key_pair.h" +#include "fastpair/crypto/fast_pair_key_pair.h" namespace nearby { namespace fastpair { @@ -43,4 +43,4 @@ class FastPairEncryption { } // namespace fastpair } // namespace nearby -#endif // THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_ENCRYPTION_H_ +#endif // THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_ENCRYPTION_H_ diff --git a/fastpair/handshake/fast_pair_encryption_test.cc b/fastpair/crypto/fast_pair_encryption_test.cc similarity index 98% rename from fastpair/handshake/fast_pair_encryption_test.cc rename to fastpair/crypto/fast_pair_encryption_test.cc index 5690d9d4..57222b9b 100644 --- a/fastpair/handshake/fast_pair_encryption_test.cc +++ b/fastpair/crypto/fast_pair_encryption_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/handshake/fast_pair_encryption.h" +#include "fastpair/crypto/fast_pair_encryption.h" #include #include diff --git a/fastpair/handshake/fast_pair_key_pair.h b/fastpair/crypto/fast_pair_key_pair.h similarity index 86% rename from fastpair/handshake/fast_pair_key_pair.h rename to fastpair/crypto/fast_pair_key_pair.h index d64e30ae..0ea026fe 100644 --- a/fastpair/handshake/fast_pair_key_pair.h +++ b/fastpair/crypto/fast_pair_key_pair.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_KEY_PAIR_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_KEY_PAIR_H_ +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_KEY_PAIR_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_KEY_PAIR_H_ #include #include @@ -43,4 +43,4 @@ struct KeyPair { } // namespace fastpair } // namespace nearby -#endif // THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_KEY_PAIR_H_ +#endif // THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_KEY_PAIR_H_ diff --git a/fastpair/handshake/fast_pair_key_pair_test.cc b/fastpair/crypto/fast_pair_key_pair_test.cc similarity index 97% rename from fastpair/handshake/fast_pair_key_pair_test.cc rename to fastpair/crypto/fast_pair_key_pair_test.cc index c35821bc..7e76b210 100644 --- a/fastpair/handshake/fast_pair_key_pair_test.cc +++ b/fastpair/crypto/fast_pair_key_pair_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/handshake/fast_pair_key_pair.h" +#include "fastpair/crypto/fast_pair_key_pair.h" #include diff --git a/fastpair/handshake/fast_pair_message_type.h b/fastpair/crypto/fast_pair_message_type.h similarity index 82% rename from fastpair/handshake/fast_pair_message_type.h rename to fastpair/crypto/fast_pair_message_type.h index 0c6ff49f..087f280a 100644 --- a/fastpair/handshake/fast_pair_message_type.h +++ b/fastpair/crypto/fast_pair_message_type.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_MESSAGE_TYPE_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_MESSAGE_TYPE_H_ +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_MESSAGE_TYPE_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_MESSAGE_TYPE_H_ namespace nearby { namespace fastpair { @@ -35,4 +35,4 @@ enum class FastPairMessageType { } // namespace fastpair } // namespace nearby -#endif // THIRD_PARTY_NEARBY_FASTPAIR_HANDSHAKE_FAST_PAIR_MESSAGE_TYPE_H_ +#endif // THIRD_PARTY_NEARBY_FASTPAIR_CRYPTO_FAST_PAIR_MESSAGE_TYPE_H_