OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 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 // Callback for crypto methods that return a single array buffer. |
| 9 callback DataCallback = void(optional ArrayBuffer data); |
| 10 |
| 11 // Callback for method that generates an encryption key pair. |
| 12 callback KeyPairCallback = void(optional ArrayBuffer public_key, |
| 13 optional ArrayBuffer private_key); |
| 14 |
| 15 interface Functions { |
| 16 // Generates a ECDSA key pair for P256 curve. |
| 17 // Public key will be in format recognized by secure wire transport protocol |
| 18 // used by Easy Unlock app. Otherwise, the exact format for both key should |
| 19 // should be considered obfuscated to the app. The app should not use them |
| 20 // directly, but through this API. |
| 21 // |callback|: Callback with the generated keys. On failure, none of the |
| 22 // keys will be set. |
| 23 static void generateEcP256KeyPair(KeyPairCallback callback); |
| 24 |
| 25 // Given a private key and a public ECDSA key from different asymetric key |
| 26 // pairs, it generates a symetric encryption key using EC Diffie-Hellman |
| 27 // scheme. |
| 28 // |privateKey|: A private key generated by the app using |
| 29 // |generateEcP256KeyPair|. |
| 30 // |publicKey|: A public key that should be in the same format as the |
| 31 // public key generated by |generateEcP256KeyPair|. Generally not the |
| 32 // one paired with |private_key|. |
| 33 // |callback|: Function returning the generated secret symetric key. |
| 34 // On failure, the returned value will not be set. |
| 35 static void performECDHKeyAgreement(ArrayBuffer privateKey, |
| 36 ArrayBuffer publicKey, |
| 37 DataCallback callback); |
| 38 |
| 39 // Creates a secure, signed message in format used by Easy Unlock app to |
| 40 // establish secure communication channel over unsecure connection. |
| 41 // |payload|: The payload the create message should carry. |
| 42 // |secretKey|: The symetric key used to sign and, if needed, encrypt the |
| 43 // message content. |
| 44 // |associatedData|: Data associated with the message. The data will not be |
| 45 // sent with the message, but the message recepient will use the same |
| 46 // data on its side to verify the message. |
| 47 // |publicMetadata|: Metadata to be added to the message header. |
| 48 // |encrypt|: Whether the message should be encrypted. If set |secretKey| |
| 49 // will be used for encryption. |
| 50 // |callback|: Function returning the created message bytes. On failure, |
| 51 // the returned value will not be set. |
| 52 static void createSecureMessage( |
| 53 ArrayBuffer payload, |
| 54 ArrayBuffer secretKey, |
| 55 ArrayBuffer associatedData, |
| 56 ArrayBuffer publicMetadata, |
| 57 boolean encrypt, |
| 58 DataCallback callback); |
| 59 |
| 60 // Authenticates and, if needed, decrypts a secure message. The message is |
| 61 // in the same format as the one created by |createSecureMessage|. |
| 62 // |secureMessage|: The message to be unwrapped. |
| 63 // |secretKey|: Symetric key to be used to authenticate the message sender |
| 64 // and decrypt the message (if needed). |
| 65 // |associatedData|: The data associated with the message. For the message |
| 66 // to be succesfully verified, the message should have been created with |
| 67 // the same associated data. |
| 68 // |encrypted|: Whether the message is encrypted. |
| 69 // |callback|: Function returning an array buffer containing cleartext |
| 70 // message header and body. They are returned in a single buffer in |
| 71 // format used inside the message. If the massage authentication or |
| 72 // decryption fails, the returned value will not be set. |
| 73 static void unwrapSecureMessage( |
| 74 ArrayBuffer secureMessage, |
| 75 ArrayBuffer secretKey, |
| 76 ArrayBuffer associatedData, |
| 77 boolean encrypted, |
| 78 DataCallback callback); |
| 79 }; |
| 80 }; |
OLD | NEW |