Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / common / extensions / api / easy_unlock_private.idl
blob4f7d747986f038e368804b711c39230a865608f3
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's not close
41 // enough to be allowed to unlock the device.
42 PHONE_NOT_NEARBY,
43 // A phone eligible to unlock the device is detected, but it is not allowed
44 // to unlock the device because it does not report its lock screen state.
45 PHONE_UNSUPPORTED,
46 // The devie can be unlocked using Easy Unlock.
47 AUTHENTICATED
50 // Type of a permit. All lower case to match permit.PermitRecord.Type.
51 enum PermitType {access, license};
53 // Options that can be passed to |unwrapSecureMessage| method.
54 dictionary UnwrapSecureMessageOptions {
55 // The data associated with the message. For the message to be succesfully
56 // verified, the message should have been created with the same associated
57 // data.
58 ArrayBuffer? associatedData;
60 // The encryption algorithm that should be used to decrypt the message.
61 // Should not be set for a cleartext message.
62 EncryptionType? encryptType;
64 // The algorithm to be used to verify signature contained in the message.
65 // Defaults to |HMAC_SHA256|. |ECDSA_P256_SHA256| can currently be used
66 // only with cleartext messages.
67 SignatureType? signType;
70 dictionary CreateSecureMessageOptions {
71 // Data associated with the message. The data will not be sent with the
72 // message, but the message recepient will use the same data on its side
73 // to verify the message.
74 ArrayBuffer? associatedData;
76 // Metadata to be added to the message header.
77 ArrayBuffer? publicMetadata;
79 // Verification key id added to the message header. Should be set if the
80 // message is signed using |ECDSA_P256_SHA256|. Used by the message
81 // recepient to determine which key should be used to verify the message
82 // signature.
83 ArrayBuffer? verificationKeyId;
85 // Decryption key id added to the message header. Used by the message
86 // recepient to determine which key should be used to decrypt the message.
87 ArrayBuffer? decryptionKeyId;
89 // The encryption algorithm that should be used to encrypt the message.
90 // Should not be set for a cleartext message.
91 EncryptionType? encryptType;
93 // The algorithm to be used to sign the message.
94 // Defaults to |HMAC_SHA256|. |ECDSA_P256_SHA256| can currently be used
95 // only with cleartext messages.
96 SignatureType? signType;
99 // A permit record contains the credentials used to request or grant
100 // authorization of a permit.
101 dictionary PermitRecord {
102 // ID of the permit, which identifies the service/application that these
103 // permit records are used in.
104 DOMString permitId;
106 // An identifier for this record that should be unique among all other
107 // records of the same permit.
108 DOMString id;
110 // Type of the record.
111 PermitType type;
113 // Websafe base64 encoded payload data of the record.
114 DOMString data;
117 // Device information that can be authenticated for Easy unlock.
118 dictionary Device {
119 // The Bluetooth address of the device.
120 DOMString bluetoothAddress;
122 // The name of the device.
123 DOMString? name;
125 // The permit record of the device.
126 PermitRecord? permitRecord;
128 // Websafe base64 encoded persistent symmetric key.
129 DOMString? psk;
132 // The information about a user associated with Easy unlock service.
133 dictionary UserInfo {
134 // The user id.
135 DOMString userId;
137 // Whether the user is logged in. If not logged in, the app is running on
138 // the signin screen.
139 boolean loggedIn;
141 // Whether all data needed to use Easy unlock service has been loaded for
142 // the user.
143 boolean dataReady;
146 // Callback for crypto methods that return a single array buffer.
147 callback DataCallback = void(optional ArrayBuffer data);
149 // An empty callback used purely for signalling success vs. failure.
150 callback EmptyCallback = void();
152 // Callback for the getStrings() method.
153 callback GetStringsCallback = void(object strings);
155 // Callback for method that generates an encryption key pair.
156 callback KeyPairCallback = void(optional ArrayBuffer public_key,
157 optional ArrayBuffer private_key);
159 // Callback for the getPermitAccess() method.
160 callback GetPermitAccessCallback = void(optional PermitRecord permitAccess);
162 // Callback for the getRemoteDevices() method.
163 callback GetRemoteDevicesCallback = void(Device[] devices);
165 // Callback for the |getUserInfo()| method. Note that the callback argument is
166 // a list for future use (on signin screen there may be more than one user
167 // associated with the easy unlock service). Currently the method returns at
168 // most one user.
169 callback GetUserInfoCallback = void(UserInfo[] users);
171 interface Functions {
172 // Gets localized strings required to render the API.
174 // |callback| : Called with a dictionary mapping names to resource strings.
175 // TODO(isherman): This is essentially copied from identity_private.idl.
176 // Perhaps this should be extracted to a common API instead?
177 static void getStrings(GetStringsCallback callback);
179 // Generates a ECDSA key pair for P256 curve.
180 // Public key will be in format recognized by secure wire transport protocol
181 // used by Easy Unlock app. Otherwise, the exact format for both key should
182 // should be considered obfuscated to the app. The app should not use them
183 // directly, but through this API.
184 // |callback|: Callback with the generated keys. On failure, none of the
185 // keys will be set.
186 static void generateEcP256KeyPair(KeyPairCallback callback);
188 // Given a private key and a public ECDSA key from different asymetric key
189 // pairs, it generates a symetric encryption key using EC Diffie-Hellman
190 // scheme.
191 // |privateKey|: A private key generated by the app using
192 // |generateEcP256KeyPair|.
193 // |publicKey|: A public key that should be in the same format as the
194 // public key generated by |generateEcP256KeyPair|. Generally not the
195 // one paired with |private_key|.
196 // |callback|: Function returning the generated secret symetric key.
197 // On failure, the returned value will not be set.
198 static void performECDHKeyAgreement(ArrayBuffer privateKey,
199 ArrayBuffer publicKey,
200 DataCallback callback);
202 // Creates a secure, signed message in format used by Easy Unlock app to
203 // establish secure communication channel over unsecure connection.
204 // |payload|: The payload the create message should carry.
205 // |key|: The key used to sign the message content. If encryption algorithm
206 // is set in |options| the same key will be used to encrypt the message.
207 // |options|: Additional (optional) parameters used to create the message.
208 // |callback|: Function returning the created message bytes. On failure,
209 // the returned value will not be set.
210 static void createSecureMessage(
211 ArrayBuffer payload,
212 ArrayBuffer key,
213 CreateSecureMessageOptions options,
214 DataCallback callback);
216 // Authenticates and, if needed, decrypts a secure message. The message is
217 // in the same format as the one created by |createSecureMessage|.
218 // |secureMessage|: The message to be unwrapped.
219 // |key|: Key to be used to authenticate the message sender. If encryption
220 // algorithm is set in |options|, the same key will be used to decrypt
221 // the message.
222 // |options|: Additional (optional) parameters used to unwrap the message.
223 // |callback|: Function returning an array buffer containing cleartext
224 // message header and body. They are returned in a single buffer in
225 // format used inside the message. If the massage authentication or
226 // decryption fails, the returned value will not be set.
227 static void unwrapSecureMessage(
228 ArrayBuffer secureMessage,
229 ArrayBuffer key,
230 UnwrapSecureMessageOptions options,
231 DataCallback callback);
233 // Connects to the SDP service on a device, given just the device's
234 // Bluetooth address. This function is useful as a faster alternative to
235 // Bluetooth discovery, when you already know the remote device's Bluetooth
236 // address. A successful call to this function has the side-effect of
237 // registering the device with the Bluetooth daemon, making it available for
238 // future outgoing connections.
239 // |deviceAddress|: The Bluetooth address of the device to connect to.
240 // |callback|: Called to indicate success or failure.
241 static void seekBluetoothDeviceByAddress(DOMString deviceAddress,
242 optional EmptyCallback callback);
244 // Connects the socket to a remote Bluetooth device over an insecure
245 // connection, i.e. a connection that requests no bonding and no
246 // man-in-the-middle protection. Other than the reduced security setting,
247 // behaves identically to the chrome.bluetoothSocket.connect() function.
248 // |socketId|: The socket identifier, as issued by the
249 // chrome.bluetoothSocket API.
250 // |deviceAddress|: The Bluetooth address of the device to connect to.
251 // |uuid|: The UUID of the service to connect to.
252 // |callback|: Called when the connect attempt is complete.
253 static void connectToBluetoothServiceInsecurely(long socketId,
254 DOMString deviceAddress,
255 DOMString uuid,
256 EmptyCallback callback);
258 // Updates the screenlock state to reflect the Easy Unlock app state.
259 static void updateScreenlockState(State state,
260 optional EmptyCallback callback);
262 // Saves the permit record for the local device.
263 // |permitAccess|: The permit record to be saved.
264 // |callback|: Called to indicate success or failure.
265 static void setPermitAccess(PermitRecord permitAccess,
266 optional EmptyCallback callback);
268 // Gets the permit record for the local device.
269 static void getPermitAccess(GetPermitAccessCallback callback);
271 // Clears the permit record for the local device.
272 static void clearPermitAccess(optional EmptyCallback callback);
274 // Saves the remote device list.
275 // |devices|: The list of remote devices to be saved.
276 // |callback|: Called to indicate success or failure.
277 static void setRemoteDevices(Device[] devices,
278 optional EmptyCallback callback);
280 // Gets the remote device list.
281 static void getRemoteDevices(GetRemoteDevicesCallback callback);
283 // Gets the sign-in challenge for the current user.
284 static void getSignInChallenge(DataCallback callback);
286 // Tries to sign-in the current user with a secret obtained by decrypting
287 // the sign-in challenge. Check chrome.runtime.lastError for failures. Upon
288 // success, the user session will be started.
289 static void trySignInSecret(ArrayBuffer signInSecret,
290 EmptyCallback callback);
292 // Retrieves information about the user associated with the Easy unlock
293 // service.
294 static void getUserInfo(GetUserInfoCallback callback);
297 interface Events {
298 // Event fired when the data for the user currently associated with
299 // Easy unlock service is updated.
300 // |userInfo| The updated user information.
301 static void onUserInfoUpdated(UserInfo userInfo);