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 #include <array>
21 #include <cstdint>
22 
23 namespace bluetooth {
24 namespace security {
25 namespace pairing {
26 
27 using SimplePairingHash = std::array<uint8_t, 16>;
28 using SimplePairingRandomizer = std::array<uint8_t, 16>;
29 
30 class OobData {
31  public:
OobData()32   OobData() {}
OobData(SimplePairingHash C,SimplePairingRandomizer R)33   OobData(SimplePairingHash C, SimplePairingRandomizer R) : C_(C), R_(R) {}
34 
GetC()35   SimplePairingHash GetC() {
36     return C_;
37   }
38 
GetR()39   SimplePairingRandomizer GetR() {
40     return R_;
41   }
42 
IsValid()43   bool IsValid() {
44     return !std::all_of(C_.begin(), C_.end(), [](uint8_t b) { return b == 0; }) &&
45            !std::all_of(R_.begin(), R_.end(), [](uint8_t b) { return b == 0; });
46   }
47 
48  private:
49   SimplePairingHash C_ = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
50   SimplePairingRandomizer R_ = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
51 };
52 
53 }  // namespace pairing
54 }  // namespace security
55 }  // namespace bluetooth
56