160d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root/* 260d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * Copyright (C) 2011 The Android Open Source Project 360d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * 460d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * Licensed under the Apache License, Version 2.0 (the "License"); 560d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * you may not use this file except in compliance with the License. 660d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * You may obtain a copy of the License at 760d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * 860d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * http://www.apache.org/licenses/LICENSE-2.0 960d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * 1060d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * Unless required by applicable law or agreed to in writing, software 1160d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * distributed under the License is distributed on an "AS IS" BASIS, 1260d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1360d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * See the License for the specific language governing permissions and 1460d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * limitations under the License. 1560d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root */ 1660d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 1760d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root#ifndef ANDROID_HARDWARE_KEYMASTER_H 1860d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root#define ANDROID_HARDWARE_KEYMASTER_H 1960d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 2060d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root#include <stdint.h> 2160d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root#include <sys/cdefs.h> 2260d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root#include <sys/types.h> 2360d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 2460d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root#include <hardware/hardware.h> 2560d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 2660d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root__BEGIN_DECLS 2760d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 2860d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root/** 2960d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * The id of this module 3060d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root */ 3160d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root#define KEYSTORE_HARDWARE_MODULE_ID "keystore" 3260d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 3360d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root#define KEYSTORE_KEYMASTER "keymaster" 3460d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 359271d04d888c5676ccd9707378d18cad0f06d607Kenny Root/** 36c124b23f94a0a88e872253720c0e27594a9a9938Kenny Root * Settings for "module_api_version" and "hal_api_version" 37c124b23f94a0a88e872253720c0e27594a9a9938Kenny Root * fields in the keymaster_module initialization. 389271d04d888c5676ccd9707378d18cad0f06d607Kenny Root */ 39c124b23f94a0a88e872253720c0e27594a9a9938Kenny Root#define KEYMASTER_HEADER_VERSION 2 40c124b23f94a0a88e872253720c0e27594a9a9938Kenny Root 41c124b23f94a0a88e872253720c0e27594a9a9938Kenny Root#define KEYMASTER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) 42c124b23f94a0a88e872253720c0e27594a9a9938Kenny Root#define KEYMASTER_DEVICE_API_VERSION_0_2 HARDWARE_DEVICE_API_VERSION_2(0, 2, KEYMASTER_HEADER_VERSION) 439271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 443c338f473122e85fd64379524a91219872f80720Kenny Root/** 453c338f473122e85fd64379524a91219872f80720Kenny Root * Flags for keymaster_device::flags 463c338f473122e85fd64379524a91219872f80720Kenny Root */ 473c338f473122e85fd64379524a91219872f80720Kenny Rootenum { 483c338f473122e85fd64379524a91219872f80720Kenny Root /* 493c338f473122e85fd64379524a91219872f80720Kenny Root * Indicates this keymaster implementation does not have hardware that 503c338f473122e85fd64379524a91219872f80720Kenny Root * keeps private keys out of user space. 513c338f473122e85fd64379524a91219872f80720Kenny Root * 523c338f473122e85fd64379524a91219872f80720Kenny Root * This should not be implemented on anything other than the default 533c338f473122e85fd64379524a91219872f80720Kenny Root * implementation. 543c338f473122e85fd64379524a91219872f80720Kenny Root */ 553c338f473122e85fd64379524a91219872f80720Kenny Root KEYMASTER_SOFTWARE_ONLY = 0x00000001, 563c338f473122e85fd64379524a91219872f80720Kenny Root}; 573c338f473122e85fd64379524a91219872f80720Kenny Root 5860d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Rootstruct keystore_module { 599271d04d888c5676ccd9707378d18cad0f06d607Kenny Root hw_module_t common; 6060d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root}; 6160d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 6260d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root/** 639271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * Asymmetric key pair types. 6460d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root */ 6560d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Roottypedef enum { 669271d04d888c5676ccd9707378d18cad0f06d607Kenny Root TYPE_RSA = 1, 672541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root TYPE_DSA = 2, 682541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root TYPE_EC = 3, 699271d04d888c5676ccd9707378d18cad0f06d607Kenny Root} keymaster_keypair_t; 709271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 719271d04d888c5676ccd9707378d18cad0f06d607Kenny Root/** 729271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * Parameters needed to generate an RSA key. 739271d04d888c5676ccd9707378d18cad0f06d607Kenny Root */ 749271d04d888c5676ccd9707378d18cad0f06d607Kenny Roottypedef struct { 759271d04d888c5676ccd9707378d18cad0f06d607Kenny Root uint32_t modulus_size; 769271d04d888c5676ccd9707378d18cad0f06d607Kenny Root uint64_t public_exponent; 779271d04d888c5676ccd9707378d18cad0f06d607Kenny Root} keymaster_rsa_keygen_params_t; 789271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 799271d04d888c5676ccd9707378d18cad0f06d607Kenny Root/** 802541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * Parameters needed to generate a DSA key. 812541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root */ 822541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Roottypedef struct { 832541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root uint32_t key_size; 842541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root uint32_t generator_len; 852541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root uint32_t prime_p_len; 862541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root uint32_t prime_q_len; 872541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root const uint8_t* generator; 882541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root const uint8_t* prime_p; 892541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root const uint8_t* prime_q; 902541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root} keymaster_dsa_keygen_params_t; 912541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root 922541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root/** 932541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * Parameters needed to generate an EC key. 942541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * 952541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * Field size is the only parameter in version 2. The sizes correspond to these required curves: 962541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * 972541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * 192 = NIST P-192 982541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * 224 = NIST P-224 992541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * 256 = NIST P-256 1002541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * 384 = NIST P-384 1012541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * 521 = NIST P-521 1022541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * 1032541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * The parameters for these curves are available at: http://www.nsa.gov/ia/_files/nist-routines.pdf 1042541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * in Chapter 4. 1052541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root */ 1062541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Roottypedef struct { 1072541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root uint32_t field_size; 1082541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root} keymaster_ec_keygen_params_t; 1092541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root 1102541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root/** 1112541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root * Digest type. 1129271d04d888c5676ccd9707378d18cad0f06d607Kenny Root */ 1139271d04d888c5676ccd9707378d18cad0f06d607Kenny Roottypedef enum { 1149271d04d888c5676ccd9707378d18cad0f06d607Kenny Root DIGEST_NONE, 1152541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root} keymaster_digest_t; 1169271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 1179271d04d888c5676ccd9707378d18cad0f06d607Kenny Root/** 1189271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * Type of padding used for RSA operations. 1199271d04d888c5676ccd9707378d18cad0f06d607Kenny Root */ 1209271d04d888c5676ccd9707378d18cad0f06d607Kenny Roottypedef enum { 1219271d04d888c5676ccd9707378d18cad0f06d607Kenny Root PADDING_NONE, 1229271d04d888c5676ccd9707378d18cad0f06d607Kenny Root} keymaster_rsa_padding_t; 1239271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 1242541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root 1252541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Roottypedef struct { 1262541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root keymaster_digest_t digest_type; 1272541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root} keymaster_dsa_sign_params_t; 1282541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root 1292541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Roottypedef struct { 1302541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root keymaster_digest_t digest_type; 1312541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root} keymaster_ec_sign_params_t; 1322541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root 1339271d04d888c5676ccd9707378d18cad0f06d607Kenny Roottypedef struct { 1342541a0a8f7a2c86658d435efb49843a88b4d97e0Kenny Root keymaster_digest_t digest_type; 1359271d04d888c5676ccd9707378d18cad0f06d607Kenny Root keymaster_rsa_padding_t padding_type; 1369271d04d888c5676ccd9707378d18cad0f06d607Kenny Root} keymaster_rsa_sign_params_t; 13760d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 13860d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root/** 13960d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * The parameters that can be set for a given keymaster implementation. 14060d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root */ 14160d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Rootstruct keymaster_device { 14260d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root struct hw_device_t common; 14360d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 144c124b23f94a0a88e872253720c0e27594a9a9938Kenny Root /** 145c124b23f94a0a88e872253720c0e27594a9a9938Kenny Root * THIS IS DEPRECATED. Use the new "module_api_version" and "hal_api_version" 146c124b23f94a0a88e872253720c0e27594a9a9938Kenny Root * fields in the keymaster_module initialization instead. 147c124b23f94a0a88e872253720c0e27594a9a9938Kenny Root */ 1489271d04d888c5676ccd9707378d18cad0f06d607Kenny Root uint32_t client_version; 1499271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 1503c338f473122e85fd64379524a91219872f80720Kenny Root /** 1513c338f473122e85fd64379524a91219872f80720Kenny Root * See flags defined for keymaster_device::flags above. 1523c338f473122e85fd64379524a91219872f80720Kenny Root */ 1533c338f473122e85fd64379524a91219872f80720Kenny Root uint32_t flags; 1543c338f473122e85fd64379524a91219872f80720Kenny Root 15560d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root void* context; 15660d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 15760d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root /** 15860d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * Generates a public and private key. The key-blob returned is opaque 1599271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * and must subsequently provided for signing and verification. 16060d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * 16160d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * Returns: 0 on success or an error code less than 0. 16260d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root */ 1639271d04d888c5676ccd9707378d18cad0f06d607Kenny Root int (*generate_keypair)(const struct keymaster_device* dev, 1649271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const keymaster_keypair_t key_type, const void* key_params, 1659271d04d888c5676ccd9707378d18cad0f06d607Kenny Root uint8_t** key_blob, size_t* key_blob_length); 16660d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 16760d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root /** 1689271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * Imports a public and private key pair. The imported keys will be in 1699271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * PKCS#8 format with DER encoding (Java standard). The key-blob 1709271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * returned is opaque and will be subsequently provided for signing 1719271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * and verification. 17260d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * 17360d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * Returns: 0 on success or an error code less than 0. 17460d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root */ 17560d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root int (*import_keypair)(const struct keymaster_device* dev, 1769271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const uint8_t* key, const size_t key_length, 1779271d04d888c5676ccd9707378d18cad0f06d607Kenny Root uint8_t** key_blob, size_t* key_blob_length); 17860d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 17960d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root /** 1809271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * Gets the public key part of a key pair. The public key must be in 1819271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * X.509 format (Java standard) encoded byte array. 1829271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * 1839271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * Returns: 0 on success or an error code less than 0. 1849271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * On error, x509_data should not be allocated. 1859271d04d888c5676ccd9707378d18cad0f06d607Kenny Root */ 1869271d04d888c5676ccd9707378d18cad0f06d607Kenny Root int (*get_keypair_public)(const struct keymaster_device* dev, 1879271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const uint8_t* key_blob, const size_t key_blob_length, 1889271d04d888c5676ccd9707378d18cad0f06d607Kenny Root uint8_t** x509_data, size_t* x509_data_length); 1899271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 1909271d04d888c5676ccd9707378d18cad0f06d607Kenny Root /** 1919271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * Deletes the key pair associated with the key blob. 1928ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * 1938ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * This function is optional and should be set to NULL if it is not 1948ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * implemented. 1958ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * 1968ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * Returns 0 on success or an error code less than 0. 1979271d04d888c5676ccd9707378d18cad0f06d607Kenny Root */ 1989271d04d888c5676ccd9707378d18cad0f06d607Kenny Root int (*delete_keypair)(const struct keymaster_device* dev, 1999271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const uint8_t* key_blob, const size_t key_blob_length); 2009271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 2019271d04d888c5676ccd9707378d18cad0f06d607Kenny Root /** 2028ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * Deletes all keys in the hardware keystore. Used when keystore is 2038ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * reset completely. 2048ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * 2058ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * This function is optional and should be set to NULL if it is not 2068ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * implemented. 2078ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * 2088ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root * Returns 0 on success or an error code less than 0. 2098ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root */ 2108ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root int (*delete_all)(const struct keymaster_device* dev); 2118ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root 2128ae65e71996ce871cda97cc9114cb5211cb273bfKenny Root /** 2139271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * Signs data using a key-blob generated before. This can use either 2149271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * an asymmetric key or a secret key. 21560d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * 21660d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * Returns: 0 on success or an error code less than 0. 21760d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root */ 21860d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root int (*sign_data)(const struct keymaster_device* dev, 2199271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const void* signing_params, 2209271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const uint8_t* key_blob, const size_t key_blob_length, 2219271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const uint8_t* data, const size_t data_length, 2229271d04d888c5676ccd9707378d18cad0f06d607Kenny Root uint8_t** signed_data, size_t* signed_data_length); 22360d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 22460d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root /** 2259271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * Verifies data signed with a key-blob. This can use either 2269271d04d888c5676ccd9707378d18cad0f06d607Kenny Root * an asymmetric key or a secret key. 22760d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * 22860d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root * Returns: 0 on successful verification or an error code less than 0. 22960d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root */ 23060d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root int (*verify_data)(const struct keymaster_device* dev, 2319271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const void* signing_params, 2329271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const uint8_t* key_blob, const size_t key_blob_length, 2339271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const uint8_t* signed_data, const size_t signed_data_length, 2349271d04d888c5676ccd9707378d18cad0f06d607Kenny Root const uint8_t* signature, const size_t signature_length); 23560d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root}; 23660d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Roottypedef struct keymaster_device keymaster_device_t; 23760d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 2389271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 2399271d04d888c5676ccd9707378d18cad0f06d607Kenny Root/* Convenience API for opening and closing keymaster devices */ 2409271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 2419271d04d888c5676ccd9707378d18cad0f06d607Kenny Rootstatic inline int keymaster_open(const struct hw_module_t* module, 2429271d04d888c5676ccd9707378d18cad0f06d607Kenny Root keymaster_device_t** device) 2439271d04d888c5676ccd9707378d18cad0f06d607Kenny Root{ 2449271d04d888c5676ccd9707378d18cad0f06d607Kenny Root int rc = module->methods->open(module, KEYSTORE_KEYMASTER, 2459271d04d888c5676ccd9707378d18cad0f06d607Kenny Root (struct hw_device_t**) device); 2469271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 2479271d04d888c5676ccd9707378d18cad0f06d607Kenny Root return rc; 2489271d04d888c5676ccd9707378d18cad0f06d607Kenny Root} 2499271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 2509271d04d888c5676ccd9707378d18cad0f06d607Kenny Rootstatic inline int keymaster_close(keymaster_device_t* device) 2519271d04d888c5676ccd9707378d18cad0f06d607Kenny Root{ 2529271d04d888c5676ccd9707378d18cad0f06d607Kenny Root return device->common.close(&device->common); 2539271d04d888c5676ccd9707378d18cad0f06d607Kenny Root} 2549271d04d888c5676ccd9707378d18cad0f06d607Kenny Root 25560d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root__END_DECLS 25660d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 25760d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root#endif // ANDROID_HARDWARE_KEYMASTER_H 25860d0e5f24b40e4d9f4a191cfe4444ca98234decaKenny Root 259