Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var utils = require('utils'); | 5 var utils = require('utils'); |
| 6 var intersect = require('platformKeys.utils').intersect; | 6 var intersect = require('platformKeys.utils').intersect; |
| 7 var keyModule = require('platformKeys.Key'); | 7 var keyModule = require('platformKeys.Key'); |
| 8 var Key = keyModule.Key; | 8 var Key = keyModule.Key; |
| 9 var KeyType = keyModule.KeyType; | 9 var KeyType = keyModule.KeyType; |
| 10 var KeyUsage = keyModule.KeyUsage; | 10 var KeyUsage = keyModule.KeyUsage; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Implementation of WebCrypto.KeyPair used in enterprise.platformKeys. | 13 * Implementation of WebCrypto.KeyPair used in enterprise.platformKeys. |
| 14 * | |
|
Devlin
2016/04/26 22:41:25
I don't think this is typical style. Please rever
robwu
2016/04/26 23:14:33
Done.
| |
| 14 * @param {ArrayBuffer} publicKeySpki The Subject Public Key Info in DER | 15 * @param {ArrayBuffer} publicKeySpki The Subject Public Key Info in DER |
| 15 * encoding. | 16 * encoding. |
| 16 * @param {KeyAlgorithm} algorithm The algorithm identifier. | 17 * @param {KeyAlgorithm} algorithm The algorithm identifier. |
| 17 * @param {KeyUsage[]} usages The allowed key usages. | 18 * @param {KeyUsage[]} usages The allowed key usages. |
| 18 * @constructor | 19 * @constructor |
| 19 */ | 20 */ |
| 20 var KeyPairImpl = function(publicKeySpki, algorithm, usages) { | 21 function KeyPairImpl(publicKeySpki, algorithm, usages) { |
| 21 this.publicKey = new Key(KeyType.public, | 22 this.publicKey = new Key(KeyType.public, |
| 22 publicKeySpki, | 23 publicKeySpki, |
| 23 algorithm, | 24 algorithm, |
| 24 intersect([KeyUsage.verify], usages), | 25 intersect([KeyUsage.verify], usages), |
| 25 true /* extractable */); | 26 true /* extractable */); |
| 26 this.privateKey = new Key(KeyType.private, | 27 this.privateKey = new Key(KeyType.private, |
| 27 publicKeySpki, | 28 publicKeySpki, |
| 28 algorithm, | 29 algorithm, |
| 29 intersect([KeyUsage.sign], usages), | 30 intersect([KeyUsage.sign], usages), |
| 30 false /* not extractable */); | 31 false /* not extractable */); |
| 31 }; | 32 } |
| 33 $Object.setPrototypeOf(KeyPairImpl, null); | |
| 34 $Object.setPrototypeOf(KeyPairImpl.prototype, null); | |
|
Devlin
2016/04/26 22:41:25
Why do we need this?
robwu
2016/04/26 23:14:33
By default, instances inherit from Object, which c
Devlin
2016/04/27 00:10:25
I should have been more clear. Why do we need to
robwu
2016/04/27 09:09:21
On prototype for the reason above.
On the construc
Devlin
2016/04/27 17:33:02
Hmm... I'm a bit torn on this.
A few of the v8 fo
robwu
2016/04/28 20:27:50
Done.
| |
| 32 | 35 |
| 33 function KeyPair() { | 36 function KeyPair() { |
| 34 privates(KeyPair).constructPrivate(this, arguments); | 37 privates(KeyPair).constructPrivate(this, arguments); |
| 35 } | 38 } |
| 36 utils.expose(KeyPair, KeyPairImpl, { | 39 utils.expose(KeyPair, KeyPairImpl, { |
| 37 readonly: [ | 40 readonly: [ |
| 38 'publicKey', | 41 'publicKey', |
| 39 'privateKey', | 42 'privateKey', |
| 40 ], | 43 ], |
| 41 }); | 44 }); |
| 42 | 45 |
| 43 exports.$set('KeyPair', KeyPair); | 46 exports.$set('KeyPair', KeyPair); |
| OLD | NEW |