Chromium Code Reviews| Index: components/proximity_auth/ble/bluetooth_low_energy_eid_generator.h |
| diff --git a/components/proximity_auth/ble/bluetooth_low_energy_eid_generator.h b/components/proximity_auth/ble/bluetooth_low_energy_eid_generator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3bb9b62ccf9f206a68c66c308bf4b6a5fbf0dba0 |
| --- /dev/null |
| +++ b/components/proximity_auth/ble/bluetooth_low_energy_eid_generator.h |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_WEAVE_EID_GENERATOR_H_ |
| +#define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_WEAVE_EID_GENERATOR_H_ |
| + |
| +#include <stddef.h> |
| +#include <stdint.h> |
| + |
| +#include <memory> |
| + |
| +#include "components/proximity_auth/remote_device.h" |
| + |
| +namespace proximity_auth { |
| +namespace weave { |
| + |
| +// Represent a EID generator for a single device. The code client has the |
|
rkc
2016/07/27 00:56:34
What's an EID?
jingxuy
2016/07/27 23:31:48
Done.
|
| +// responsiblity for keeping track of multiple clients |
| +class BluetoothLowEnergyEidGenerator { |
| + public: |
| + class Factory { |
|
Kyle Horimoto
2016/07/27 17:58:48
Is there a reason that a Factory is needed for thi
jingxuy
2016/07/27 23:31:48
I was under the impression that you want to mock o
|
| + public: |
| + // TODO(jingxuy): this is just stop compiler from complaining. |
|
rkc
2016/07/27 00:56:34
Complaining about?
Generally when a compiler compl
jingxuy
2016/07/27 23:31:48
I didn't have a .cc file since I intend this class
|
| + static std::unique_ptr<BluetoothLowEnergyEidGenerator> NewInstance( |
| + const RemoteDevice& device) { |
| + return std::unique_ptr<BluetoothLowEnergyEidGenerator>( |
| + new BluetoothLowEnergyEidGenerator(device)); |
| + } |
| + |
| + // Exposed for testing. |
| + static void SetInstanceForTesting(Factory* factory); |
| + |
| + protected: |
| + // Exposed for testing. |
| + virtual std::unique_ptr<BluetoothLowEnergyEidGenerator> BuildInstance( |
| + const RemoteDevice& device); |
| + |
| + private: |
| + static Factory* factory_instance_; |
| + }; |
| + |
| + typedef uint8_t EidSeed[32]; |
|
rkc
2016/07/27 00:56:34
Why 32? Also, make this a constexpr.
Kyle Horimoto
2016/07/27 17:58:48
+1, I'm not sure that seeds are 32 bytes, but even
jingxuy
2016/07/27 23:31:48
According to Jeremy it is 256 bits. This typedef i
|
| + |
| + // TODO(tether-dev): Make this actually generate EID. |
| + // This function should look at the time and get the correct seed out of the |
| + // remote device. If this seed is different from the current_seed_, then |
| + // re-seed the generator. Otherwise generate based on time and stuff. |
| + uint16_t GetEid() { return 42; } |
|
rkc
2016/07/27 00:56:34
Again, why 42?
Kyle Horimoto
2016/07/27 17:58:48
This function should take a list of BeaconSeeds an
Kyle Horimoto
2016/07/27 17:58:48
I think she's just returning a fake value and will
jingxuy
2016/07/27 23:31:48
It has a TODO above the function explaining exactl
jingxuy
2016/07/27 23:31:48
I think our design for the EID generator is differ
jingxuy
2016/07/28 22:09:03
Resolved on offline discussion. Currently will tak
|
| + |
| + protected: |
| + BluetoothLowEnergyEidGenerator(const RemoteDevice& device) |
|
rkc
2016/07/27 00:56:34
Why is this protected?
jingxuy
2016/07/27 23:31:48
Same as the comment in the rotator. It comes with
|
| + : device_(device){}; |
| + |
| + private: |
| + const RemoteDevice& device_; |
| + |
| + EidSeed current_seed_; |
| +}; |
| + |
| +} // namespace weave |
| + |
| +} // namespace proximity_auth |
| + |
| +#endif |