Chromium Code Reviews| Index: chrome/renderer/resources/extensions/platform_keys_custom_bindings.js |
| diff --git a/chrome/renderer/resources/extensions/platform_keys_custom_bindings.js b/chrome/renderer/resources/extensions/platform_keys_custom_bindings.js |
| index c9eb65956994cbb80d7cf254eee766f26d365b4c..5d4b39442008b882e658fa640b4b8266f6f11100 100644 |
| --- a/chrome/renderer/resources/extensions/platform_keys_custom_bindings.js |
| +++ b/chrome/renderer/resources/extensions/platform_keys_custom_bindings.js |
| @@ -6,19 +6,51 @@ |
| var binding = require('binding').Binding.create('platformKeys'); |
| var SubtleCrypto = require('platformKeys.SubtleCrypto').SubtleCrypto; |
| +var getPublicKey = require('platformKeys.getPublicKey').getPublicKey; |
| var internalAPI = require('platformKeys.internalAPI'); |
| +var keyModule = require('platformKeys.Key'); |
| +var Key = keyModule.Key; |
| +var KeyType = keyModule.KeyType; |
| +var KeyUsage = keyModule.KeyUsage; |
| + |
| +function createPublicKey(publicKeySpki, algorithm) { |
| + return new Key(KeyType.public, publicKeySpki, algorithm, [KeyUsage.verify], |
| + true /* extractable */); |
| +} |
| + |
| +function createPrivateKey(publicKeySpki, algorithm) { |
| + return new Key(KeyType.private, publicKeySpki, algorithm, [KeyUsage.sign], |
| + false /* not extractable */); |
| +} |
| + |
| binding.registerCustomHook(function(api) { |
| var apiFunctions = api.apiFunctions; |
| var subtleCrypto = new SubtleCrypto('' /* tokenId */); |
| apiFunctions.setHandleRequest( |
| 'selectClientCertificates', function(details, callback) { |
| - internalAPI.selectClientCertificates(details, callback); |
| + internalAPI.selectClientCertificates(details, function(matches) { |
| + callback($Array.map(matches, function(match) { |
| + if (match.keyAlgorithm.publicExponent) { |
| + match.keyAlgorithm.publicExponent = |
| + new Uint8Array(match.keyAlgorithm.publicExponent); |
|
Ryan Sleevi
2015/02/03 01:44:50
Ditto remarks here
pneubeck (no reviews)
2015/02/03 20:15:00
added a comment here as well.
|
| + } |
| + return match; |
| + })); |
| + }); |
| }); |
| apiFunctions.setHandleRequest( |
| 'subtleCrypto', function() { return subtleCrypto }); |
| + |
| + apiFunctions.setHandleRequest( |
| + 'getKeyPair', function(cert, params, callback) { |
| + getPublicKey(cert, params, function(publicKey, algorithm) { |
| + callback(createPublicKey(publicKey, algorithm), |
| + createPrivateKey(publicKey, algorithm)); |
| + }); |
| + }); |
| }); |
| exports.binding = binding.generate(); |