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 namespace easyUnlockPrivate
{
8 // Signature algorithms supported by the crypto library methods used by
15 // Encryption algorithms supported by the crypto library methods used by
21 // Available states for the Easy Unlock app.
23 // Screen is either not locked, or the Easy Unlock is not enabled.
25 // The Bluetooth is not enabled.
27 // Bluetooth is being activated.
29 // There are no phones eligible to unlock the device.
31 // A phone eligible to unlock the device is detected, but can't be
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.
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.
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.
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.
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.
51 // A phone eligible to unlock the device is found; but (a) the phone is
52 // locked, and (b) the local device's transmission power is too high,
53 // indicating that the phone is (probably) more than 1 foot away, and
54 // therefore is not allowed to unlock the device.
55 PHONE_LOCKED_AND_TX_POWER_TOO_HIGH
,
56 // The device can be unlocked using Easy Unlock.
60 // Type of a permit. All lower case to match permit.PermitRecord.Type.
61 enum PermitType
{access
, license
};
63 // Options that can be passed to |unwrapSecureMessage| method.
64 dictionary UnwrapSecureMessageOptions
{
65 // The data associated with the message. For the message to be succesfully
66 // verified, the message should have been created with the same associated
68 ArrayBuffer? associatedData
;
70 // The encryption algorithm that should be used to decrypt the message.
71 // Should not be set for a cleartext message.
72 EncryptionType? encryptType
;
74 // The algorithm to be used to verify signature contained in the message.
75 // Defaults to |HMAC_SHA256|. |ECDSA_P256_SHA256| can currently be used
76 // only with cleartext messages.
77 SignatureType? signType
;
80 dictionary CreateSecureMessageOptions
{
81 // Data associated with the message. The data will not be sent with the
82 // message, but the message recepient will use the same data on its side
83 // to verify the message.
84 ArrayBuffer? associatedData
;
86 // Metadata to be added to the message header.
87 ArrayBuffer? publicMetadata
;
89 // Verification key id added to the message header. Should be set if the
90 // message is signed using |ECDSA_P256_SHA256|. Used by the message
91 // recepient to determine which key should be used to verify the message
93 ArrayBuffer? verificationKeyId
;
95 // Decryption key id added to the message header. Used by the message
96 // recepient to determine which key should be used to decrypt the message.
97 ArrayBuffer? decryptionKeyId
;
99 // The encryption algorithm that should be used to encrypt the message.
100 // Should not be set for a cleartext message.
101 EncryptionType? encryptType
;
103 // The algorithm to be used to sign the message.
104 // Defaults to |HMAC_SHA256|. |ECDSA_P256_SHA256| can currently be used
105 // only with cleartext messages.
106 SignatureType? signType
;
109 // A permit record contains the credentials used to request or grant
110 // authorization of a permit.
111 dictionary PermitRecord
{
112 // ID of the permit, which identifies the service/application that these
113 // permit records are used in.
116 // An identifier for this record that should be unique among all other
117 // records of the same permit.
120 // Type of the record.
123 // Websafe base64 encoded payload data of the record.
127 // Device information that can be authenticated for Easy unlock.
129 // The Bluetooth address of the device.
130 DOMString bluetoothAddress
;
132 // The name of the device.
135 // The permit record of the device.
136 PermitRecord? permitRecord
;
138 // Websafe base64 encoded persistent symmetric key.
142 // The information about a user associated with Easy unlock service.
143 dictionary UserInfo
{
147 // Whether the user is logged in. If not logged in, the app is running on
148 // the signin screen.
151 // Whether to require the remote device to be in very close proximity before
152 // allowing unlock (~1 feet).
153 boolean requireCloseProximity
;
155 // Whether all data needed to use Easy unlock service has been loaded for
166 // A rectangle, in screen coordinates, measured in device-independent pixels.
174 // Callback for crypto methods that return a single array buffer.
175 callback DataCallback
= void(optional ArrayBuffer data
);
177 // An empty callback used purely for signalling success vs. failure.
178 callback EmptyCallback
= void();
180 // Callback for the getStrings() method.
181 callback GetStringsCallback
= void(object strings
);
183 // Callback for method that generates an encryption key pair.
184 callback KeyPairCallback
= void(optional ArrayBuffer public_key
,
185 optional ArrayBuffer private_key
);
187 // Callback for the getPermitAccess() method.
188 callback GetPermitAccessCallback
= void(optional PermitRecord permitAccess
);
190 // Callback for the getRemoteDevices() method.
191 callback GetRemoteDevicesCallback
= void(Device
[] devices
);
193 // Callback for the |getUserInfo()| method. Note that the callback argument is
194 // a list for future use (on signin screen there may be more than one user
195 // associated with the easy unlock service). Currently the method returns at
197 callback GetUserInfoCallback
= void(UserInfo
[] users
);
199 // Callback for |getSignInChallenge()| method.
200 // In case challenge could not be created both |challenge| and |signedNonce|
202 // If the requested nonce could not be signed, |signedNonce| will be empty.
203 // |challenge|: The sign in challenge to be used when signing in the user
204 // currently associated with the Easy Unlock service.
205 // |signedNonce|: Nonce signed by Chrome OS TPM, provided as an argument to
206 // the |getSignInChallenge()| function and signed by the TPM key
207 // associated with the user.
208 callback SignInChallengeCallback
= void(optional ArrayBuffer challenge
,
209 optional ArrayBuffer signedNonce
);
211 // Callback for the |getConnectionInfo()| method.
212 // |rssi|: The received signal strength from the remote device in dB.
213 // |transmit_power| The local transmission power to the remote device in dB.
214 // |max_transmit_power| The maximum transmission power that can be achieved.
215 callback ConnectionInfoCallback
= void(
216 long rssi
, long transmit_power
, long max_transmit_power
);
218 interface Functions
{
219 // Gets localized strings required to render the API.
221 // |callback| : Called with a dictionary mapping names to resource strings.
222 // TODO(isherman): This is essentially copied from identity_private.idl.
223 // Perhaps this should be extracted to a common API instead?
224 static
void getStrings
(GetStringsCallback
callback);
226 // Generates a ECDSA key pair for P256 curve.
227 // Public key will be in format recognized by secure wire transport protocol
228 // used by Easy Unlock app. Otherwise, the exact format for both key should
229 // should be considered obfuscated to the app. The app should not use them
230 // directly, but through this API.
231 // |callback|: Callback with the generated keys. On failure, none of the
233 static
void generateEcP256KeyPair
(KeyPairCallback
callback);
235 // Given a private key and a public ECDSA key from different asymetric key
236 // pairs, it generates a symetric encryption key using EC Diffie-Hellman
238 // |privateKey|: A private key generated by the app using
239 // |generateEcP256KeyPair|.
240 // |publicKey|: A public key that should be in the same format as the
241 // public key generated by |generateEcP256KeyPair|. Generally not the
242 // one paired with |private_key|.
243 // |callback|: Function returning the generated secret symetric key.
244 // On failure, the returned value will not be set.
245 static
void performECDHKeyAgreement
(ArrayBuffer privateKey
,
246 ArrayBuffer publicKey
,
247 DataCallback
callback);
249 // Creates a secure, signed message in format used by Easy Unlock app to
250 // establish secure communication channel over unsecure connection.
251 // |payload|: The payload the create message should carry.
252 // |key|: The key used to sign the message content. If encryption algorithm
253 // is set in |options| the same key will be used to encrypt the message.
254 // |options|: Additional (optional) parameters used to create the message.
255 // |callback|: Function returning the created message bytes. On failure,
256 // the returned value will not be set.
257 static
void createSecureMessage
(
260 CreateSecureMessageOptions options
,
261 DataCallback
callback);
263 // Authenticates and, if needed, decrypts a secure message. The message is
264 // in the same format as the one created by |createSecureMessage|.
265 // |secureMessage|: The message to be unwrapped.
266 // |key|: Key to be used to authenticate the message sender. If encryption
267 // algorithm is set in |options|, the same key will be used to decrypt
269 // |options|: Additional (optional) parameters used to unwrap the message.
270 // |callback|: Function returning an array buffer containing cleartext
271 // message header and body. They are returned in a single buffer in
272 // format used inside the message. If the massage authentication or
273 // decryption fails, the returned value will not be set.
274 static
void unwrapSecureMessage
(
275 ArrayBuffer secureMessage
,
277 UnwrapSecureMessageOptions options
,
278 DataCallback
callback);
280 // Connects to the SDP service on a device, given just the device's
281 // Bluetooth address. This function is useful as a faster alternative to
282 // Bluetooth discovery, when you already know the remote device's Bluetooth
283 // address. A successful call to this function has the side-effect of
284 // registering the device with the Bluetooth daemon, making it available for
285 // future outgoing connections.
286 // |deviceAddress|: The Bluetooth address of the device to connect to.
287 // |callback|: Called to indicate success or failure.
288 static
void seekBluetoothDeviceByAddress
(DOMString deviceAddress
,
289 optional EmptyCallback
callback);
291 // Connects the socket to a remote Bluetooth device over an insecure
292 // connection, i.e. a connection that requests no bonding and no
293 // man-in-the-middle protection. Other than the reduced security setting,
294 // behaves identically to the chrome.bluetoothSocket.connect() function.
295 // |socketId|: The socket identifier, as issued by the
296 // chrome.bluetoothSocket API.
297 // |deviceAddress|: The Bluetooth address of the device to connect to.
298 // |uuid|: The UUID of the service to connect to.
299 // |callback|: Called when the connect attempt is complete.
300 static
void connectToBluetoothServiceInsecurely
(long socketId
,
301 DOMString deviceAddress
,
303 EmptyCallback
callback);
305 // Updates the screenlock state to reflect the Easy Unlock app state.
306 static
void updateScreenlockState
(State state
,
307 optional EmptyCallback
callback);
309 // Saves the permit record for the local device.
310 // |permitAccess|: The permit record to be saved.
311 // |callback|: Called to indicate success or failure.
312 static
void setPermitAccess
(PermitRecord permitAccess
,
313 optional EmptyCallback
callback);
315 // Gets the permit record for the local device.
316 static
void getPermitAccess
(GetPermitAccessCallback
callback);
318 // Clears the permit record for the local device.
319 static
void clearPermitAccess
(optional EmptyCallback
callback);
321 // Saves the remote device list.
322 // |devices|: The list of remote devices to be saved.
323 // |callback|: Called to indicate success or failure.
324 static
void setRemoteDevices
(Device
[] devices
,
325 optional EmptyCallback
callback);
327 // Gets the remote device list.
328 static
void getRemoteDevices
(GetRemoteDevicesCallback
callback);
330 // Gets the sign-in challenge for the current user.
331 // |nonce|: Nonce that should be signed by the Chrome OS TPM. The signed
332 // nonce is returned with the sign-in challenge.
333 static
void getSignInChallenge
(ArrayBuffer nonce
,
334 SignInChallengeCallback
callback);
336 // Tries to sign-in the current user with a secret obtained by decrypting
337 // the sign-in challenge. Check chrome.runtime.lastError for failures. Upon
338 // success, the user session will be started.
339 static
void trySignInSecret
(ArrayBuffer signInSecret
,
340 EmptyCallback
callback);
342 // Retrieves information about the user associated with the Easy unlock
344 static
void getUserInfo
(GetUserInfoCallback
callback);
346 // Gets the connection info for the Bluetooth device identified by
348 static
void getConnectionInfo
(DOMString deviceAddress
,
349 ConnectionInfoCallback
callback);
351 // Shows an error bubble with the given |message|, anchored to an edge of
352 // the given |anchorRect| -- typically the right edge, but possibly a
353 // different edge if there is not space for the bubble to the right of the
354 // anchor rectangle. If the |link_range| is non-empty, renders the text
355 // within the |message| that is contained in the |link_range| as a link with
356 // the given |link_target| URL.
357 static
void showErrorBubble
(DOMString
message,
359 DOMString link_target
,
364 // Event fired when the data for the user currently associated with
365 // Easy unlock service is updated.
366 // |userInfo| The updated user information.
367 static
void onUserInfoUpdated
(UserInfo userInfo
);