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..e75f61779c4ee9a1e4cf16bd07eb53ce2ca7ddc8 |
| --- /dev/null |
| +++ b/components/proximity_auth/ble/bluetooth_low_energy_eid_generator.h |
| @@ -0,0 +1,60 @@ |
| +// 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. |
| +// EID is ephemeral id needed to be included for the advertisement for security |
| +// and privacy reasons. |
| +// It has the repsonsiblity of getting the correct EID seed out of the |
| +// RemoteDevice and encode the seed with the timestamp to get the EID |
| +class BluetoothLowEnergyEidGenerator { |
| + public: |
| + class Factory { |
| + public: |
| + // TODO(jingxuy): this is just stop compiler from complaining. |
| + static std::unique_ptr<BluetoothLowEnergyEidGenerator> NewInstance() { |
| + return std::unique_ptr<BluetoothLowEnergyEidGenerator>( |
| + new BluetoothLowEnergyEidGenerator()); |
| + } |
| + |
| + // Exposed for testing. |
| + static void SetInstanceForTesting(Factory* factory); |
| + |
| + protected: |
| + // Exposed for testing. |
| + virtual std::unique_ptr<BluetoothLowEnergyEidGenerator> BuildInstance(); |
| + |
| + private: |
| + static Factory* factory_instance_; |
| + }; |
| + |
| + typedef uint8_t EidSeed[32]; |
| + |
| + // 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(const RemoteDevice& device) { return 42; } |
|
Kyle Horimoto
2016/07/29 03:15:39
1) Your function should take a public key as a par
jingxuy
2016/07/29 18:45:43
I thought we agreed on it take RemoteDevice? But I
Kyle Horimoto
2016/07/29 19:04:18
The public key of the local device as well as meta
jingxuy
2016/07/29 20:26:01
what's the type of public key? Are you talking abo
Kyle Horimoto
2016/07/29 21:07:45
Yep, though it needs to be converted into a data a
|
| + |
| + protected: |
| + BluetoothLowEnergyEidGenerator(){}; |
| +}; |
| + |
| +} // namespace weave |
| + |
| +} // namespace proximity_auth |
| + |
| +#endif |