blob: c0b504737646d3eb16673064fb2bfcb0c90d409d [file] [log] [blame]
Andres Morales33dfdc72015-05-12 15:37:20 -07001/*
2 * Copyright 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SOFT_GATEKEEPER_DEVICE_H_
18#define SOFT_GATEKEEPER_DEVICE_H_
19
20#include <gatekeeper/soft_gatekeeper.h>
21#include <UniquePtr.h>
22
23using namespace gatekeeper;
24
25namespace android {
26
27/**
28 * Software based GateKeeper implementation
29 */
30class SoftGateKeeperDevice {
31public:
32 SoftGateKeeperDevice() {
33 impl_.reset(new SoftGateKeeper());
34 }
35
36 // Wrappers to translate the gatekeeper HAL API to the Kegyuard Messages API.
37
38 /**
39 * Enrolls password_payload, which should be derived from a user selected pin or password,
40 * with the authentication factor private key used only for enrolling authentication
41 * factor data.
42 *
43 * Returns: 0 on success or an error code less than 0 on error.
44 * On error, enrolled_password_handle will not be allocated.
45 */
46 int enroll(uint32_t uid,
47 const uint8_t *current_password_handle, uint32_t current_password_handle_length,
48 const uint8_t *current_password, uint32_t current_password_length,
49 const uint8_t *desired_password, uint32_t desired_password_length,
50 uint8_t **enrolled_password_handle, uint32_t *enrolled_password_handle_length);
51
52 /**
53 * Verifies provided_password matches enrolled_password_handle.
54 *
55 * Implementations of this module may retain the result of this call
56 * to attest to the recency of authentication.
57 *
58 * On success, writes the address of a verification token to auth_token,
59 * usable to attest password verification to other trusted services. Clients
60 * may pass NULL for this value.
61 *
62 * Returns: 0 on success or an error code less than 0 on error
63 * On error, verification token will not be allocated
64 */
65 int verify(uint32_t uid, uint64_t challenge,
66 const uint8_t *enrolled_password_handle, uint32_t enrolled_password_handle_length,
67 const uint8_t *provided_password, uint32_t provided_password_length,
68 uint8_t **auth_token, uint32_t *auth_token_length);
69private:
70 UniquePtr<GateKeeper> impl_;
71};
72
73} // namespace gatekeeper
74
75#endif //SOFT_GATEKEEPER_DEVICE_H_