blob: 488da6d1b798696f3bd66bd869f7eef86ea23f41 [file] [log] [blame]
Janis Danisevskisa0c33ea2017-11-09 14:58:36 -08001/*
2**
3** Copyright 2017, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
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#ifndef CONFIRMATIONUI_1_0_DEFAULT_PLATFORMSPECIFICS_H_
19#define CONFIRMATIONUI_1_0_DEFAULT_PLATFORMSPECIFICS_H_
20
21#include <stdint.h>
22#include <time.h>
23
24#include <android/hardware/confirmationui/1.0/IConfirmationResultCallback.h>
25#include <android/hardware/confirmationui/1.0/generic/GenericOperation.h>
26#include <android/hardware/confirmationui/support/confirmationui_utils.h>
27
28namespace android {
29namespace hardware {
30namespace confirmationui {
31namespace V1_0 {
32namespace implementation {
33
34struct MonotonicClockTimeStamper {
35 class TimeStamp {
36 public:
37 explicit TimeStamp(uint64_t ts) : timestamp_(ts), ok_(true) {}
38 TimeStamp() : timestamp_(0), ok_(false) {}
39 bool isOk() const { return ok_; }
40 operator const uint64_t() const { return timestamp_; }
41
42 private:
43 uint64_t timestamp_;
44 bool ok_;
45 };
46 static TimeStamp now();
47};
48
49class HMacImplementation {
50 public:
51 static support::NullOr<support::array<uint8_t, 32>> hmac256(
52 const uint8_t key[32], std::initializer_list<support::ByteBufferProxy> buffers);
53};
54
Janis Danisevskisbb6377e2018-02-23 11:23:20 -080055class MyOperation : public generic::Operation<sp<IConfirmationResultCallback>,
56 MonotonicClockTimeStamper, HMacImplementation> {
57 public:
58 static MyOperation& get() {
59 static MyOperation op;
60 return op;
61 }
62};
Janis Danisevskisa0c33ea2017-11-09 14:58:36 -080063
64} // namespace implementation
65} // namespace V1_0
66} // namespace confirmationui
67} // namespace hardware
68} // namespace android
69
70#endif // CONFIRMATIONUI_1_0_DEFAULT_PLATFORMSPECIFICS_H_