blob: 118ca6fa9a45812961f30a66c6d3bc33f9c1a081 [file] [log] [blame]
David Zeuthenc75ac312019-10-28 13:16:45 -04001/*
2 * Copyright 2020 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
17package android.hardware.identity@1.0;
18
19import IWritableIdentityCredential;
20import IIdentityCredential;
21
22/**
23 * IIdentityCredentialStore provides an interface to a secure store for user identity documents.
24 * This HAL is deliberately fairly general and abstract. To the extent possible, specification of
25 * the message formats and semantics of communication with credential verification devices and
26 * issuing authorities (IAs) is out of scope for this HAL. It provides the interface with secure
27 * storage but a credential-specific Android application will be required to implement the
28 * presentation and verification protocols and processes appropriate for the specific credential
29 * type.
30 *
31 * The design of this HAL makes few assumptions about the underlying secure hardware. In particular
32 * it does not assume that the secure hardware has any storage beyond that needed for a persistent,
33 * hardware-bound AES-128 key. However, its design allows the use of secure hardware that does have
34 * storage, specifically to enable "direct access". Most often credentials will be accessed through
35 * this HAL and through the Android layers above it but that requires that the Android device be
36 * powered up and fully functional. It is desirable to allow identity credential usage when the
37 * Android device's battery is too low to boot the Android operating system, so direct access to the
38 * secure hardware via NFC may allow data retrieval, if the secure hardware chooses to implement it.
39 * Definition of how data is retrieved in low power mode is explicitly out of scope for this HAL
40 * specification; it's up to the relevant identity credential standards to define.
41 *
42 * The 'default' HAL instance is explicitly not for direct access and the 'direct_access' HAL
43 * instance - if available - is for direct access. Applications are expected to provision their
44 * credential to both instances (and the contents may differ), not just one of them.
45 *
46 * Multiple credentials can be created. Each credential comprises:
47 *
48 * - A document type, which is a UTF-8 string of at most 256 bytes.
49 *
50 * - A set of namespaces, which serve to disambiguate value names. Namespaces are UTF-8 strings of
51 * up to 256 bytes in length (most should be much shorter). It is recommended that namespaces be
52 * structured as reverse domain names so that IANA effectively serves as the namespace registrar.
53 *
54 * - For each namespase, a set of name/value pairs, each with an associated set of access control
55 * profile IDs. Names are UTF-8 strings of up to 256 bytes in length (most should be much
56 * shorter). Values stored must be encoed as valid CBOR (https://tools.ietf.org/html/rfc7049) and
57 * the encoeded size is is limited to at most 512 KiB.
58 *
59 * - A set of access control profiles, each with a profile ID and a specification of the
60 * conditions which satisfy the profile's requirements.
61 *
62 * - An asymmetric key pair which is used to authenticate the credential to the IA, called the
63 * CredentialKey. This key is attested to by the secure hardware using Android Keystore
64 * attestation (https://source.android.com/security/keystore/attestation). See
65 * getAttestationCertificate() in the IWritableIdentityCredential for more information.
66 *
67 * - A set of zero or more named reader authentication public keys, which are used to authenticate
68 * an authorized reader to the credential.
69 *
70 * - A set of named signing keys, which are used to sign collections of values and session
71 * transcripts.
72 *
73 * Cryptographic notation:
74 *
75 * Throughout this HAL, cryptographic operations are specified in detail. To avoid repeating the
76 * definition of the notation, it's specified here. It is assumed that the reader is familiar with
77 * standard cryptographic algorithms and constructs.
78 *
79 * AES-GCM-ENC(K, N, D, A) represents AES-GCM encryption with key 'K', nonce 'N', additional
80 * authenticated data 'A' and data 'D'. The nonce is usually specified as 'R', meaning 12
81 * random bytes. The nonce is always 12 bytes and is prepended to the ciphertext. The GCM
82 * tag is 16 bytes, appended to the ciphertext. AES-GCM-DEC with the same argument notation
83 * represents the corresponding decryption operation.
84 *
85 * ECDSA(K, D) represents ECDSA signing of data 'D' with key 'K'.
86 *
87 * || represents concatenation
88 *
89 * {} represents an empty input; 0 bytes of data.
90 *
91 * HBK represents a device-unique, hardware-bound AES-128 key which exists only in secure
92 * hardware, except for "test" credential stores (see createCredential(), below). For test
93 * stores, an all-zero value is used in place of the HBK.
94 *
95 * Data encoding notation:
96 *
97 * Various fields need to be encoded as precisely-specified byte arrays. Where existing standards
98 * define appropriate encodings, those are used. For example, X.509 certificates. Where new
99 * encodings are needed, CBOR is used. CBOR maps are described in CDDL notation
100 * (https://tools.ietf.org/html/draft-ietf-cbor-cddl-06).
101 */
102interface IIdentityCredentialStore {
103
104 /**
105 * Returns information about hardware.
106 *
107 * The isDirectAccess output parameter indicates whether this credential store
108 * implementation is for direct access. Credentials provisioned in credential
109 * stores with this set to true, should use reader authentication on all data elements.
110 *
111 * @return result is OK on success, FAILED if an error occurred.
112 *
113 * @return credentialStoreName the name of the credential store implementation.
114 *
115 * @return credentialStoreAuthorName the name of the credential store author.
116 *
117 * @return dataChunkSize the maximum size of data chunks.
118 *
119 * @return isDirectAccess whether the provisioned credential is available through
120 * direct access.
121 *
122 * @return supportedDocTypes if empty, then any document type is supported, otherwise
123 * only the document types returned are supported.
124 */
125 getHardwareInformation()
126 generates(Result result,
127 string credentialStoreName,
128 string credentialStoreAuthorName,
129 uint32_t dataChunkSize,
130 bool isDirectAccess,
131 vec<string> supportedDocTypes);
132
133 /**
134 * createCredential creates a new Credential. When a Credential is created, two cryptographic
135 * keys are created: StorageKey, an AES key used to secure the externalized Credential
136 * contents, and CredentialKeyPair, an EC key pair used to authenticate the store to the IA. In
137 * addition, all of the Credential data content is imported and a certificate for the
138 * CredentialKeyPair and a signature produced with the CredentialKeyPair are created. These
139 * latter values may be checked by an issuing authority to verify that the data was imported
140 * into secure hardware and that it was imported unmodified.
141 *
142 * @param docType is an optional name (may be an empty string) that identifies the type of
143 * credential being created, e.g. "org.iso.18013-5.2019.mdl" (the doc type of the ISO
144 * driving license standard).
145 *
146 * @param testCredential indicates if this is a test store. Test credentials must use an
147 * all-zeros hardware-bound key (HBK) and must set the test bit in the
148 * personalizationReceipt (see finishAddingEntries(), in IWritableIdentityCredential).
149 *
150 * @return result is OK on success, FAILED if an error occurred.
151 *
152 * @return writableCredential is an IWritableIdentityCredential HIDL interface that provides
153 * operations to provision a credential.
154 */
155 createCredential(string docType, bool testCredential)
156 generates(Result result, IWritableIdentityCredential writableCredential);
157
158 /**
159 * getCredential retrieves an IIdentityCredential HIDL interface which allows use of a stored
160 * Credential.
161 *
162 * The cipher suite used to communicate with the remote verifier must also be specified. Currently
163 * only a single cipher-suite is supported and the details of this are as follow:
164 *
165 * - ECDHE with HKDF-SHA-256 for key agreement.
166 * - AES-256 with GCM block mode for authenticated encryption (nonces are incremented by one
167 * for every message).
168 * - ECDSA with SHA-256 for signing (used for signing session transcripts to defeat
169 * man-in-the-middle attacks), signing keys are not ephemeral.
170 *
171 * Support for other cipher suites may be added in a future version of this HAL.
172 *
173 * @param credentialData is a CBOR-encoded structure containing metadata about the credential
174 * and an encrypted byte array that contains data used to secure the credential. See the
175 * return argument of the same name in finishAddingEntries(), in IWritableIdentityCredential.
176 *
177 * @return result is OK on success or INVALID_DATA if the passed in credentialData
178 * cannot be decoded or decrypted.
179 *
180 * @return credential is an IIdentityCredential HIDL interface that provides operations on the
181 * Credential.
182 */
183 getCredential(vec<uint8_t> credentialData)
184 generates (Result result, IIdentityCredential credential);
185};