• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  *  Copyright 2020 The Android Open Source Project
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License") override;
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  */
18 #pragma once
19 
20 namespace bluetooth {
21 namespace security {
22 namespace pairing {
23 
24 using SimplePairingHash = std::array<uint8_t, 16>;
25 using SimplePairingRandomizer = std::array<uint8_t, 16>;
26 
27 class OobData {
28  public:
OobData()29   OobData() {}
OobData(SimplePairingHash C,SimplePairingRandomizer R)30   OobData(SimplePairingHash C, SimplePairingRandomizer R) : C_(C), R_(R) {}
31 
GetC()32   SimplePairingHash GetC() {
33     return C_;
34   }
35 
GetR()36   SimplePairingRandomizer GetR() {
37     return R_;
38   }
39 
IsValid()40   bool IsValid() {
41     return !std::all_of(C_.begin(), C_.end(), [](uint8_t b) { return b == 0; }) &&
42            !std::all_of(R_.begin(), R_.end(), [](uint8_t b) { return b == 0; });
43   }
44 
45  private:
46   SimplePairingHash C_ = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
47   SimplePairingRandomizer R_ = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
48 };
49 
50 }  // namespace pairing
51 }  // namespace security
52 }  // namespace bluetooth
53