Rename "smp" to "security"
SMP is just name of protocol used for one aspect of security management.
Rename the namespace in order to avoid any further confusions.
Test: compliation
Bug: 142341141
Change-Id: Id505fa3cd4b653c8486db2bca5f82233e731ec51
diff --git a/gd/Android.bp b/gd/Android.bp
index 67394ed..e0ed618 100644
--- a/gd/Android.bp
+++ b/gd/Android.bp
@@ -310,12 +310,12 @@
srcs: [
"hci/hci_packets.pdl",
"l2cap/l2cap_packets.pdl",
- "smp/smp_packets.pdl",
+ "security/smp_packets.pdl",
],
out: [
"hci/hci_packets.h",
"l2cap/l2cap_packets.h",
- "smp/smp_packets.h",
+ "security/smp_packets.h",
],
}
diff --git a/gd/smp/Android.bp b/gd/security/Android.bp
similarity index 100%
rename from gd/smp/Android.bp
rename to gd/security/Android.bp
diff --git a/gd/smp/ecc/multipoint_test.cc b/gd/security/ecc/multipoint_test.cc
similarity index 96%
rename from gd/smp/ecc/multipoint_test.cc
rename to gd/security/ecc/multipoint_test.cc
index ebed658..95e43d4 100644
--- a/gd/smp/ecc/multipoint_test.cc
+++ b/gd/security/ecc/multipoint_test.cc
@@ -18,10 +18,10 @@
#include <gtest/gtest.h>
-#include "smp/ecc/p_256_ecc_pp.h"
+#include "security/ecc/p_256_ecc_pp.h"
namespace bluetooth {
-namespace smp {
+namespace security {
namespace ecc {
// Test ECC point validation
@@ -108,5 +108,5 @@
}
} // namespace ecc
-} // namespace smp
+} // namespace security
} // namespace bluetooth
diff --git a/gd/smp/ecc/multprecision.cc b/gd/security/ecc/multprecision.cc
similarity index 98%
rename from gd/smp/ecc/multprecision.cc
rename to gd/security/ecc/multprecision.cc
index 38b6f3f..c2583ed 100644
--- a/gd/smp/ecc/multprecision.cc
+++ b/gd/security/ecc/multprecision.cc
@@ -22,11 +22,11 @@
*
******************************************************************************/
-#include "smp/ecc/multprecision.h"
+#include "security/ecc/multprecision.h"
#include <string.h>
namespace bluetooth {
-namespace smp {
+namespace security {
namespace ecc {
#define DWORD_BITS 32
@@ -500,5 +500,5 @@
}
} // namespace ecc
-} // namespace smp
+} // namespace security
} // namespace bluetooth
\ No newline at end of file
diff --git a/gd/smp/ecc/multprecision.h b/gd/security/ecc/multprecision.h
similarity index 97%
rename from gd/smp/ecc/multprecision.h
rename to gd/security/ecc/multprecision.h
index 01bb9ad..ad149cd 100644
--- a/gd/smp/ecc/multprecision.h
+++ b/gd/security/ecc/multprecision.h
@@ -26,7 +26,7 @@
#include <cstdint>
namespace bluetooth {
-namespace smp {
+namespace security {
namespace ecc {
#define KEY_LENGTH_DWORDS_P256 8
@@ -52,5 +52,5 @@
void multiprecision_fast_mod_P256(uint32_t* c, const uint32_t* a, const uint32_t* modp);
} // namespace ecc
-} // namespace smp
+} // namespace security
} // namespace bluetooth
\ No newline at end of file
diff --git a/gd/smp/ecc/p_256_ecc_pp.cc b/gd/security/ecc/p_256_ecc_pp.cc
similarity index 98%
rename from gd/smp/ecc/p_256_ecc_pp.cc
rename to gd/security/ecc/p_256_ecc_pp.cc
index e5d76c8..ecb805c 100644
--- a/gd/smp/ecc/p_256_ecc_pp.cc
+++ b/gd/security/ecc/p_256_ecc_pp.cc
@@ -22,14 +22,14 @@
* Cryptography for private public key
*
******************************************************************************/
-#include "smp/ecc/p_256_ecc_pp.h"
+#include "security/ecc/p_256_ecc_pp.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "smp/ecc/multprecision.h"
+#include "security/ecc/multprecision.h"
namespace bluetooth {
-namespace smp {
+namespace security {
namespace ecc {
const uint32_t* modp = curve_p256.p;
@@ -260,5 +260,5 @@
}
} // namespace ecc
-} // namespace smp
+} // namespace security
} // namespace bluetooth
\ No newline at end of file
diff --git a/gd/smp/ecc/p_256_ecc_pp.h b/gd/security/ecc/p_256_ecc_pp.h
similarity index 96%
rename from gd/smp/ecc/p_256_ecc_pp.h
rename to gd/security/ecc/p_256_ecc_pp.h
index d46b6b3..93af7ee 100644
--- a/gd/smp/ecc/p_256_ecc_pp.h
+++ b/gd/security/ecc/p_256_ecc_pp.h
@@ -25,10 +25,10 @@
#pragma once
-#include "smp/ecc/multprecision.h"
+#include "security/ecc/multprecision.h"
namespace bluetooth {
-namespace smp {
+namespace security {
namespace ecc {
struct Point {
@@ -71,5 +71,5 @@
#define ECC_PointMult(q, p, n) ECC_PointMult_Bin_NAF(q, p, n)
} // namespace ecc
-} // namespace smp
+} // namespace security
} // namespace bluetooth
diff --git a/gd/smp/ecdh_keys.cc b/gd/security/ecdh_keys.cc
similarity index 95%
rename from gd/smp/ecdh_keys.cc
rename to gd/security/ecdh_keys.cc
index fc1e335..fa3d794 100644
--- a/gd/smp/ecdh_keys.cc
+++ b/gd/security/ecdh_keys.cc
@@ -16,7 +16,7 @@
*
******************************************************************************/
-#include "smp/ecdh_keys.h"
+#include "security/ecdh_keys.h"
/**********************************************************************************************************************
TODO: We should have random number management in separate file, and we
@@ -25,7 +25,7 @@
#include <chrono>
#include <cstdlib>
-#include "smp/ecc/p_256_ecc_pp.h"
+#include "security/ecc/p_256_ecc_pp.h"
namespace {
template <size_t SIZE>
@@ -41,7 +41,7 @@
/*********************************************************************************************************************/
namespace bluetooth {
-namespace smp {
+namespace security {
std::pair<std::array<uint8_t, 32>, EcdhPublicKey> GenerateECDHKeyPair() {
std::array<uint8_t, 32> private_key = GenerateRandom<32>();
@@ -78,5 +78,5 @@
return dhkey;
}
-} // namespace smp
+} // namespace security
} // namespace bluetooth
diff --git a/gd/smp/ecdh_keys.h b/gd/security/ecdh_keys.h
similarity index 96%
rename from gd/smp/ecdh_keys.h
rename to gd/security/ecdh_keys.h
index 2feb679..8ec25a8 100644
--- a/gd/smp/ecdh_keys.h
+++ b/gd/security/ecdh_keys.h
@@ -20,7 +20,7 @@
#include <array>
namespace bluetooth {
-namespace smp {
+namespace security {
struct EcdhPublicKey {
std::array<uint8_t, 32> x;
@@ -36,5 +36,5 @@
std::array<uint8_t, 32> ComputeDHKey(std::array<uint8_t, 32> my_private_key, EcdhPublicKey remote_public_key);
-} // namespace smp
+} // namespace security
} // namespace bluetooth
diff --git a/gd/smp/initial_informations.h b/gd/security/initial_informations.h
similarity index 96%
rename from gd/smp/initial_informations.h
rename to gd/security/initial_informations.h
index f703ddd..3ada65c 100644
--- a/gd/smp/initial_informations.h
+++ b/gd/security/initial_informations.h
@@ -27,12 +27,12 @@
#include "os/handler.h"
#include "packet/base_packet_builder.h"
#include "packet/packet_view.h"
-#include "smp/pairing_failure.h"
-#include "smp/smp_packets.h"
-#include "smp/ui.h"
+#include "security/pairing_failure.h"
+#include "security/smp_packets.h"
+#include "security/ui.h"
namespace bluetooth {
-namespace smp {
+namespace security {
using DistributedKeys =
std::tuple<std::optional<crypto_toolbox::Octet16> /* ltk */, std::optional<uint16_t> /*ediv*/,
@@ -109,5 +109,5 @@
std::function<void(PairingResultOrFailure)> OnPairingFinished;
};
-} // namespace smp
+} // namespace security
} // namespace bluetooth
diff --git a/gd/smp/pairing_failure.h b/gd/security/pairing_failure.h
similarity index 96%
rename from gd/smp/pairing_failure.h
rename to gd/security/pairing_failure.h
index 17abfb2..f7bbbae 100644
--- a/gd/smp/pairing_failure.h
+++ b/gd/security/pairing_failure.h
@@ -20,10 +20,10 @@
#include <string>
-#include "smp/smp_packets.h"
+#include "security/smp_packets.h"
namespace bluetooth {
-namespace smp {
+namespace security {
/* This structure holds the information about the failure in case of airing failure */
struct PairingFailure {
@@ -53,5 +53,5 @@
: /*location(location),*/ message(message), reason(reason) {}
};
-} // namespace smp
+} // namespace security
} // namespace bluetooth
\ No newline at end of file
diff --git a/gd/smp/pairing_handler_le.cc b/gd/security/pairing_handler_le.cc
similarity index 99%
rename from gd/smp/pairing_handler_le.cc
rename to gd/security/pairing_handler_le.cc
index 9307d55..0484971 100644
--- a/gd/smp/pairing_handler_le.cc
+++ b/gd/security/pairing_handler_le.cc
@@ -16,10 +16,10 @@
*
******************************************************************************/
-#include "smp/pairing_handler_le.h"
+#include "security/pairing_handler_le.h"
namespace bluetooth {
-namespace smp {
+namespace security {
void PairingHandlerLe::PairingMain(InitialInformations i) {
LOG_INFO("Pairing Started");
@@ -387,5 +387,5 @@
}
}
-} // namespace smp
+} // namespace security
} // namespace bluetooth
\ No newline at end of file
diff --git a/gd/smp/pairing_handler_le.h b/gd/security/pairing_handler_le.h
similarity index 98%
rename from gd/smp/pairing_handler_le.h
rename to gd/security/pairing_handler_le.h
index dd237aa..4c7fc0c 100644
--- a/gd/smp/pairing_handler_le.h
+++ b/gd/security/pairing_handler_le.h
@@ -32,11 +32,11 @@
#include "hci/hci_packets.h"
#include "hci/le_security_interface.h"
#include "packet/packet_view.h"
-#include "smp/ecdh_keys.h"
-#include "smp/initial_informations.h"
-#include "smp/pairing_failure.h"
-#include "smp/smp_packets.h"
-#include "smp/ui.h"
+#include "security/ecdh_keys.h"
+#include "security/initial_informations.h"
+#include "security/pairing_failure.h"
+#include "security/smp_packets.h"
+#include "security/ui.h"
// Code generated by PDL does not allow us ot do || and && operations on bits
// efficiently. Use those masks on fields requiring them until this is solved
@@ -55,7 +55,7 @@
using bluetooth::hci::EncryptionKeyRefreshCompleteView;
namespace bluetooth {
-namespace smp {
+namespace security {
using crypto_toolbox::Octet16;
@@ -129,7 +129,7 @@
Phase1ResultOrFailure ExchangePairingFeature(const InitialInformations& i);
- void SendL2capPacket(const InitialInformations& i, std::unique_ptr<bluetooth::smp::CommandBuilder> command) {
+ void SendL2capPacket(const InitialInformations& i, std::unique_ptr<bluetooth::security::CommandBuilder> command) {
i.proper_l2cap_interface->Enqueue(std::move(command), i.l2cap_handler);
}
@@ -489,5 +489,5 @@
std::thread thread_;
};
-} // namespace smp
+} // namespace security
} // namespace bluetooth
\ No newline at end of file
diff --git a/gd/smp/pairing_handler_le_legacy.cc b/gd/security/pairing_handler_le_legacy.cc
similarity index 98%
rename from gd/smp/pairing_handler_le_legacy.cc
rename to gd/security/pairing_handler_le_legacy.cc
index c7a3d26..bebaef4 100644
--- a/gd/smp/pairing_handler_le_legacy.cc
+++ b/gd/security/pairing_handler_le_legacy.cc
@@ -16,10 +16,10 @@
*
******************************************************************************/
-#include "smp/pairing_handler_le.h"
+#include "security/pairing_handler_le.h"
namespace bluetooth {
-namespace smp {
+namespace security {
LegacyStage1ResultOrFailure PairingHandlerLe::DoLegacyStage1(const InitialInformations& i,
const PairingRequestView& pairing_request,
@@ -226,5 +226,5 @@
/* STK */
return crypto_toolbox::s1(tk, srand, mrand);
}
-} // namespace smp
+} // namespace security
} // namespace bluetooth
\ No newline at end of file
diff --git a/gd/smp/pairing_handler_le_secure_connections.cc b/gd/security/pairing_handler_le_secure_connections.cc
similarity index 99%
rename from gd/smp/pairing_handler_le_secure_connections.cc
rename to gd/security/pairing_handler_le_secure_connections.cc
index e4ceb73..91af82a 100644
--- a/gd/smp/pairing_handler_le_secure_connections.cc
+++ b/gd/security/pairing_handler_le_secure_connections.cc
@@ -16,10 +16,10 @@
*
******************************************************************************/
-#include "smp/pairing_handler_le.h"
+#include "security/pairing_handler_le.h"
namespace bluetooth {
-namespace smp {
+namespace security {
std::variant<PairingFailure, KeyExchangeResult> PairingHandlerLe::ExchangePublicKeys(const InitialInformations& i,
OobDataFlag remote_have_oob_data) {
@@ -464,5 +464,5 @@
return Stage1Result{Na, Nb, ra, rb};
}
-} // namespace smp
+} // namespace security
} // namespace bluetooth
\ No newline at end of file
diff --git a/gd/smp/pairing_handler_le_unittest.cc b/gd/security/pairing_handler_le_unittest.cc
similarity index 97%
rename from gd/smp/pairing_handler_le_unittest.cc
rename to gd/security/pairing_handler_le_unittest.cc
index eca5955..e5239b4 100644
--- a/gd/smp/pairing_handler_le_unittest.cc
+++ b/gd/security/pairing_handler_le_unittest.cc
@@ -21,18 +21,18 @@
#include <memory>
#include "os/log.h"
-#include "smp/pairing_handler_le.h"
-#include "smp/test/mocks.h"
+#include "security/pairing_handler_le.h"
+#include "security/test/mocks.h"
using ::testing::_;
using ::testing::Eq;
using ::testing::Field;
using ::testing::VariantWith;
-using bluetooth::smp::CommandView;
+using bluetooth::security::CommandView;
namespace bluetooth {
-namespace smp {
+namespace security {
namespace {
@@ -46,7 +46,7 @@
}
std::condition_variable outgoing_l2cap_blocker_;
-std::optional<bluetooth::smp::CommandView> outgoing_l2cap_packet_;
+std::optional<bluetooth::security::CommandView> outgoing_l2cap_packet_;
bool WaitForOutgoingL2capPacket() {
std::mutex mutex;
@@ -327,5 +327,5 @@
pairing_handler.reset();
}
-} // namespace smp
+} // namespace security
} // namespace bluetooth
diff --git a/gd/smp/smp_packets.pdl b/gd/security/smp_packets.pdl
similarity index 100%
rename from gd/smp/smp_packets.pdl
rename to gd/security/smp_packets.pdl
diff --git a/gd/smp/test/fake_l2cap_test.cc b/gd/security/test/fake_l2cap_test.cc
similarity index 96%
rename from gd/smp/test/fake_l2cap_test.cc
rename to gd/security/test/fake_l2cap_test.cc
index 6393c5f..5faad8e 100644
--- a/gd/smp/test/fake_l2cap_test.cc
+++ b/gd/security/test/fake_l2cap_test.cc
@@ -23,8 +23,8 @@
#include "hci/le_security_interface.h"
#include "packet/raw_builder.h"
-#include "smp/pairing_handler_le.h"
-#include "smp/test/mocks.h"
+#include "security/pairing_handler_le.h"
+#include "security/test/mocks.h"
#include "os/handler.h"
#include "os/queue.h"
@@ -47,7 +47,7 @@
using bluetooth::hci::LeSecurityCommandBuilder;
namespace bluetooth {
-namespace smp {
+namespace security {
namespace {
@@ -124,5 +124,5 @@
bidi_queue.GetDownEnd()->UnregisterDequeue();
}
-} // namespace smp
+} // namespace security
} // namespace bluetooth
\ No newline at end of file
diff --git a/gd/smp/test/mocks.h b/gd/security/test/mocks.h
similarity index 96%
rename from gd/smp/test/mocks.h
rename to gd/security/test/mocks.h
index 529da4c..c347d36 100644
--- a/gd/smp/test/mocks.h
+++ b/gd/security/test/mocks.h
@@ -22,10 +22,10 @@
#include "hci/address.h"
#include "hci/le_security_interface.h"
-#include "smp/ui.h"
+#include "security/ui.h"
namespace bluetooth {
-namespace smp {
+namespace security {
class UIMock : public UI {
public:
@@ -52,5 +52,5 @@
common::OnceCallback<void(hci::CommandStatusView)> on_status, os::Handler* handler));
};
-} // namespace smp
+} // namespace security
} // namespace bluetooth
\ No newline at end of file
diff --git a/gd/smp/test/pairing_handler_le_pair_test.cc b/gd/security/test/pairing_handler_le_pair_test.cc
similarity index 98%
rename from gd/smp/test/pairing_handler_le_pair_test.cc
rename to gd/security/test/pairing_handler_le_pair_test.cc
index 3d1b4ca..81a6b64 100644
--- a/gd/smp/test/pairing_handler_le_pair_test.cc
+++ b/gd/security/test/pairing_handler_le_pair_test.cc
@@ -24,8 +24,8 @@
#include "common/testing/wired_pair_of_bidi_queues.h"
#include "hci/le_security_interface.h"
#include "packet/raw_builder.h"
-#include "smp/pairing_handler_le.h"
-#include "smp/test/mocks.h"
+#include "security/pairing_handler_le.h"
+#include "security/test/mocks.h"
using namespace std::chrono_literals;
using testing::_;
@@ -49,7 +49,7 @@
// --gtest_repeat=10 --gtest_shuffle
namespace bluetooth {
-namespace smp {
+namespace security {
CommandView CommandBuilderToView(std::unique_ptr<BasePacketBuilder> builder) {
std::shared_ptr<std::vector<uint8_t>> packet_bytes = std::make_shared<std::vector<uint8_t>>();
BitInserter it(*packet_bytes);
@@ -67,18 +67,18 @@
auto temp_evt_view = EventPacketView::Create(packet_bytes_view);
return EventPacketView::Create(temp_evt_view);
}
-} // namespace smp
+} // namespace security
} // namespace bluetooth
namespace {
constexpr uint16_t CONN_HANDLE_MASTER = 0x31, CONN_HANDLE_SLAVE = 0x32;
-std::unique_ptr<bluetooth::smp::PairingHandlerLe> pairing_handler_a, pairing_handler_b;
+std::unique_ptr<bluetooth::security::PairingHandlerLe> pairing_handler_a, pairing_handler_b;
} // namespace
namespace bluetooth {
-namespace smp {
+namespace security {
namespace {
Address ADDRESS_MASTER{{0x26, 0x64, 0x76, 0x86, 0xab, 0xba}};
@@ -267,7 +267,7 @@
}
public:
- std::unique_ptr<bluetooth::smp::CommandView> WaitFirstL2capCommand() {
+ std::unique_ptr<bluetooth::security::CommandView> WaitFirstL2capCommand() {
while (!first_command_sent) {
std::this_thread::sleep_for(1ms);
LOG_INFO("waiting for first command...");
@@ -284,7 +284,7 @@
LeSecurityInterfaceMock slave_le_security_mock;
uint16_t first_command_sent = false;
- std::unique_ptr<bluetooth::smp::CommandView> first_command;
+ std::unique_ptr<bluetooth::security::CommandView> first_command;
os::Thread* thread_;
os::Handler* handler_;
@@ -377,7 +377,7 @@
.OnPairingFinished = OnPairingFinishedSlave,
};
- std::unique_ptr<bluetooth::smp::CommandView> first_pkt;
+ std::unique_ptr<bluetooth::security::CommandView> first_pkt;
{
std::unique_lock<std::mutex> lock(handlers_initialization_guard);
pairing_handler_b = std::make_unique<PairingHandlerLe>(PairingHandlerLe::PHASE1, slave_setup);
@@ -640,5 +640,5 @@
EXPECT_TRUE(std::holds_alternative<PairingResult>(pairing_result_slave.value()));
}
-} // namespace smp
+} // namespace security
} // namespace bluetooth
diff --git a/gd/smp/ui.h b/gd/security/ui.h
similarity index 100%
rename from gd/smp/ui.h
rename to gd/security/ui.h