Shawn Willden | c3ab05c | 2015-03-14 08:23:41 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | #include <stdint.h> |
| 18 | |
| 19 | #ifndef ANDROID_HARDWARE_HW_AUTH_TOKEN_H |
| 20 | #define ANDROID_HARDWARE_HW_AUTH_TOKEN_H |
| 21 | |
Andres Morales | 89dd74c | 2015-04-09 11:46:52 -0700 | [diff] [blame] | 22 | #ifdef __cplusplus |
Shawn Willden | c51d01e | 2015-03-18 18:59:52 -0600 | [diff] [blame] | 23 | extern "C" { |
| 24 | #endif // __cplusplus |
Shawn Willden | c3ab05c | 2015-03-14 08:23:41 -0600 | [diff] [blame] | 25 | |
Jongrak Kwon | d6aebac | 2016-12-13 14:58:45 -0800 | [diff] [blame^] | 26 | #define HW_AUTH_TOKEN_VERSION 0 |
Andres Morales | 8e7aa99 | 2015-04-08 12:38:26 -0700 | [diff] [blame] | 27 | |
Shawn Willden | c3ab05c | 2015-03-14 08:23:41 -0600 | [diff] [blame] | 28 | typedef enum { |
| 29 | HW_AUTH_NONE = 0, |
Shawn Willden | 85cec0f | 2015-04-06 11:50:04 -0600 | [diff] [blame] | 30 | HW_AUTH_PASSWORD = 1 << 0, |
| 31 | HW_AUTH_FINGERPRINT = 1 << 1, |
Shawn Willden | c3ab05c | 2015-03-14 08:23:41 -0600 | [diff] [blame] | 32 | // Additional entries should be powers of 2. |
| 33 | HW_AUTH_ANY = UINT32_MAX, |
| 34 | } hw_authenticator_type_t; |
| 35 | |
| 36 | /** |
| 37 | * Data format for an authentication record used to prove successful authentication. |
| 38 | */ |
| 39 | typedef struct __attribute__((__packed__)) { |
| 40 | uint8_t version; // Current version is 0 |
| 41 | uint64_t challenge; |
| 42 | uint64_t user_id; // secure user ID, not Android user ID |
| 43 | uint64_t authenticator_id; // secure authenticator ID |
| 44 | uint32_t authenticator_type; // hw_authenticator_type_t, in network order |
Andres Morales | 606167c | 2015-04-13 10:21:32 -0700 | [diff] [blame] | 45 | uint64_t timestamp; // in network order |
Shawn Willden | c3ab05c | 2015-03-14 08:23:41 -0600 | [diff] [blame] | 46 | uint8_t hmac[32]; |
| 47 | } hw_auth_token_t; |
| 48 | |
Andres Morales | 89dd74c | 2015-04-09 11:46:52 -0700 | [diff] [blame] | 49 | #ifdef __cplusplus |
Shawn Willden | c51d01e | 2015-03-18 18:59:52 -0600 | [diff] [blame] | 50 | } // extern "C" |
| 51 | #endif // __cplusplus |
Shawn Willden | c3ab05c | 2015-03-14 08:23:41 -0600 | [diff] [blame] | 52 | |
| 53 | #endif // ANDROID_HARDWARE_HW_AUTH_TOKEN_H |