[Smart Lock] Add temporary UI strings and assets for Tx power-based proximity detection.
[chromium-blink-merge.git] / chrome / common / extensions / api / easy_unlock_private.idl
blob3b80d55d75c1c31e4027449a9b2ac5d6332e18c1
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // <code>chrome.easyUnlockPrivate</code> API that provides hooks to Chrome to
6 // be used by Easy Unlock component app.
7 [nodoc] namespace easyUnlockPrivate {
8 // Signature algorithms supported by the crypto library methods used by
9 // Easy Unlock.
10 enum SignatureType {
11 HMAC_SHA256,
12 ECDSA_P256_SHA256
15 // Encryption algorithms supported by the crypto library methods used by
16 // Easy Unlock.
17 enum EncryptionType {
18 AES_256_CBC
21 // Available states for the Easy Unlock app.
22 enum State {
23 // Screen is either not locked, or the Easy Unlock is not enabled.
24 INACTIVE,
25 // The Bluetooth is not enabled.
26 NO_BLUETOOTH,
27 // Bluetooth is being activated.
28 BLUETOOTH_CONNECTING,
29 // There are no phones eligible to unlock the device.
30 NO_PHONE,
31 // A phone eligible to unlock the device is detected, but can't be
32 // authenticated.
33 PHONE_NOT_AUTHENTICATED,
34 // A phone eligible to unlock the device is detected, but it's locked and
35 // thus unable to unlock the device.
36 PHONE_LOCKED,
37 // A phone eligible to unlock the device is detected, but it is not allowed
38 // to unlock the device because it doesn't have lock screen enabled.
39 PHONE_UNLOCKABLE,
40 // A phone eligible to unlock the device is detected, but it is not allowed
41 // to unlock the device because it does not report its lock screen state.
42 PHONE_UNSUPPORTED,
43 // A phone eligible to unlock the device is detected, but its received
44 // signal strength is too low, i.e. the phone is roughly more than 30 feet
45 // away, and therefore is not allowed to unlock the device.
46 RSSI_TOO_LOW,
47 // A phone eligible to unlock the device is found, but the local device's
48 // transmission power is too high, indicating that the phone is (probably)
49 // more than 1 foot away, and therefore is not allowed to unlock the device.
50 TX_POWER_TOO_HIGH,
51 // The devie can be unlocked using Easy Unlock.
52 AUTHENTICATED
55 // Type of a permit. All lower case to match permit.PermitRecord.Type.
56 enum PermitType {access, license};
58 // Options that can be passed to |unwrapSecureMessage| method.
59 dictionary UnwrapSecureMessageOptions {
60 // The data associated with the message. For the message to be succesfully
61 // verified, the message should have been created with the same associated
62 // data.
63 ArrayBuffer? associatedData;
65 // The encryption algorithm that should be used to decrypt the message.
66 // Should not be set for a cleartext message.
67 EncryptionType? encryptType;
69 // The algorithm to be used to verify signature contained in the message.
70 // Defaults to |HMAC_SHA256|. |ECDSA_P256_SHA256| can currently be used
71 // only with cleartext messages.
72 SignatureType? signType;
75 dictionary CreateSecureMessageOptions {
76 // Data associated with the message. The data will not be sent with the
77 // message, but the message recepient will use the same data on its side
78 // to verify the message.
79 ArrayBuffer? associatedData;
81 // Metadata to be added to the message header.
82 ArrayBuffer? publicMetadata;
84 // Verification key id added to the message header. Should be set if the
85 // message is signed using |ECDSA_P256_SHA256|. Used by the message
86 // recepient to determine which key should be used to verify the message
87 // signature.
88 ArrayBuffer? verificationKeyId;
90 // Decryption key id added to the message header. Used by the message
91 // recepient to determine which key should be used to decrypt the message.
92 ArrayBuffer? decryptionKeyId;
94 // The encryption algorithm that should be used to encrypt the message.
95 // Should not be set for a cleartext message.
96 EncryptionType? encryptType;
98 // The algorithm to be used to sign the message.
99 // Defaults to |HMAC_SHA256|. |ECDSA_P256_SHA256| can currently be used
100 // only with cleartext messages.
101 SignatureType? signType;
104 // A permit record contains the credentials used to request or grant
105 // authorization of a permit.
106 dictionary PermitRecord {
107 // ID of the permit, which identifies the service/application that these
108 // permit records are used in.
109 DOMString permitId;
111 // An identifier for this record that should be unique among all other
112 // records of the same permit.
113 DOMString id;
115 // Type of the record.
116 PermitType type;
118 // Websafe base64 encoded payload data of the record.
119 DOMString data;
122 // Device information that can be authenticated for Easy unlock.
123 dictionary Device {
124 // The Bluetooth address of the device.
125 DOMString bluetoothAddress;
127 // The name of the device.
128 DOMString? name;
130 // The permit record of the device.
131 PermitRecord? permitRecord;
133 // Websafe base64 encoded persistent symmetric key.
134 DOMString? psk;
137 // The information about a user associated with Easy unlock service.
138 dictionary UserInfo {
139 // The user id.
140 DOMString userId;
142 // Whether the user is logged in. If not logged in, the app is running on
143 // the signin screen.
144 boolean loggedIn;
146 // Whether all data needed to use Easy unlock service has been loaded for
147 // the user.
148 boolean dataReady;
151 // Callback for crypto methods that return a single array buffer.
152 callback DataCallback = void(optional ArrayBuffer data);
154 // An empty callback used purely for signalling success vs. failure.
155 callback EmptyCallback = void();
157 // Callback for the getStrings() method.
158 callback GetStringsCallback = void(object strings);
160 // Callback for method that generates an encryption key pair.
161 callback KeyPairCallback = void(optional ArrayBuffer public_key,
162 optional ArrayBuffer private_key);
164 // Callback for the getPermitAccess() method.
165 callback GetPermitAccessCallback = void(optional PermitRecord permitAccess);
167 // Callback for the getRemoteDevices() method.
168 callback GetRemoteDevicesCallback = void(Device[] devices);
170 // Callback for the |getUserInfo()| method. Note that the callback argument is
171 // a list for future use (on signin screen there may be more than one user
172 // associated with the easy unlock service). Currently the method returns at
173 // most one user.
174 callback GetUserInfoCallback = void(UserInfo[] users);
176 interface Functions {
177 // Gets localized strings required to render the API.
179 // |callback| : Called with a dictionary mapping names to resource strings.
180 // TODO(isherman): This is essentially copied from identity_private.idl.
181 // Perhaps this should be extracted to a common API instead?
182 static void getStrings(GetStringsCallback callback);
184 // Generates a ECDSA key pair for P256 curve.
185 // Public key will be in format recognized by secure wire transport protocol
186 // used by Easy Unlock app. Otherwise, the exact format for both key should
187 // should be considered obfuscated to the app. The app should not use them
188 // directly, but through this API.
189 // |callback|: Callback with the generated keys. On failure, none of the
190 // keys will be set.
191 static void generateEcP256KeyPair(KeyPairCallback callback);
193 // Given a private key and a public ECDSA key from different asymetric key
194 // pairs, it generates a symetric encryption key using EC Diffie-Hellman
195 // scheme.
196 // |privateKey|: A private key generated by the app using
197 // |generateEcP256KeyPair|.
198 // |publicKey|: A public key that should be in the same format as the
199 // public key generated by |generateEcP256KeyPair|. Generally not the
200 // one paired with |private_key|.
201 // |callback|: Function returning the generated secret symetric key.
202 // On failure, the returned value will not be set.
203 static void performECDHKeyAgreement(ArrayBuffer privateKey,
204 ArrayBuffer publicKey,
205 DataCallback callback);
207 // Creates a secure, signed message in format used by Easy Unlock app to
208 // establish secure communication channel over unsecure connection.
209 // |payload|: The payload the create message should carry.
210 // |key|: The key used to sign the message content. If encryption algorithm
211 // is set in |options| the same key will be used to encrypt the message.
212 // |options|: Additional (optional) parameters used to create the message.
213 // |callback|: Function returning the created message bytes. On failure,
214 // the returned value will not be set.
215 static void createSecureMessage(
216 ArrayBuffer payload,
217 ArrayBuffer key,
218 CreateSecureMessageOptions options,
219 DataCallback callback);
221 // Authenticates and, if needed, decrypts a secure message. The message is
222 // in the same format as the one created by |createSecureMessage|.
223 // |secureMessage|: The message to be unwrapped.
224 // |key|: Key to be used to authenticate the message sender. If encryption
225 // algorithm is set in |options|, the same key will be used to decrypt
226 // the message.
227 // |options|: Additional (optional) parameters used to unwrap the message.
228 // |callback|: Function returning an array buffer containing cleartext
229 // message header and body. They are returned in a single buffer in
230 // format used inside the message. If the massage authentication or
231 // decryption fails, the returned value will not be set.
232 static void unwrapSecureMessage(
233 ArrayBuffer secureMessage,
234 ArrayBuffer key,
235 UnwrapSecureMessageOptions options,
236 DataCallback callback);
238 // Connects to the SDP service on a device, given just the device's
239 // Bluetooth address. This function is useful as a faster alternative to
240 // Bluetooth discovery, when you already know the remote device's Bluetooth
241 // address. A successful call to this function has the side-effect of
242 // registering the device with the Bluetooth daemon, making it available for
243 // future outgoing connections.
244 // |deviceAddress|: The Bluetooth address of the device to connect to.
245 // |callback|: Called to indicate success or failure.
246 static void seekBluetoothDeviceByAddress(DOMString deviceAddress,
247 optional EmptyCallback callback);
249 // Connects the socket to a remote Bluetooth device over an insecure
250 // connection, i.e. a connection that requests no bonding and no
251 // man-in-the-middle protection. Other than the reduced security setting,
252 // behaves identically to the chrome.bluetoothSocket.connect() function.
253 // |socketId|: The socket identifier, as issued by the
254 // chrome.bluetoothSocket API.
255 // |deviceAddress|: The Bluetooth address of the device to connect to.
256 // |uuid|: The UUID of the service to connect to.
257 // |callback|: Called when the connect attempt is complete.
258 static void connectToBluetoothServiceInsecurely(long socketId,
259 DOMString deviceAddress,
260 DOMString uuid,
261 EmptyCallback callback);
263 // Updates the screenlock state to reflect the Easy Unlock app state.
264 static void updateScreenlockState(State state,
265 optional EmptyCallback callback);
267 // Saves the permit record for the local device.
268 // |permitAccess|: The permit record to be saved.
269 // |callback|: Called to indicate success or failure.
270 static void setPermitAccess(PermitRecord permitAccess,
271 optional EmptyCallback callback);
273 // Gets the permit record for the local device.
274 static void getPermitAccess(GetPermitAccessCallback callback);
276 // Clears the permit record for the local device.
277 static void clearPermitAccess(optional EmptyCallback callback);
279 // Saves the remote device list.
280 // |devices|: The list of remote devices to be saved.
281 // |callback|: Called to indicate success or failure.
282 static void setRemoteDevices(Device[] devices,
283 optional EmptyCallback callback);
285 // Gets the remote device list.
286 static void getRemoteDevices(GetRemoteDevicesCallback callback);
288 // Gets the sign-in challenge for the current user.
289 static void getSignInChallenge(DataCallback callback);
291 // Tries to sign-in the current user with a secret obtained by decrypting
292 // the sign-in challenge. Check chrome.runtime.lastError for failures. Upon
293 // success, the user session will be started.
294 static void trySignInSecret(ArrayBuffer signInSecret,
295 EmptyCallback callback);
297 // Retrieves information about the user associated with the Easy unlock
298 // service.
299 static void getUserInfo(GetUserInfoCallback callback);
302 interface Events {
303 // Event fired when the data for the user currently associated with
304 // Easy unlock service is updated.
305 // |userInfo| The updated user information.
306 static void onUserInfoUpdated(UserInfo userInfo);