Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: chrome/renderer/resources/extensions/enterprise_platform_keys/key_pair.js

Issue 1915753002: Sanitize inheritance in callers of utils.expose (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit: space after ':' Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * @param {ArrayBuffer} publicKeySpki The Subject Public Key Info in DER 14 * @param {ArrayBuffer} publicKeySpki The Subject Public Key Info in DER
15 * encoding. 15 * encoding.
16 * @param {KeyAlgorithm} algorithm The algorithm identifier. 16 * @param {KeyAlgorithm} algorithm The algorithm identifier.
17 * @param {KeyUsage[]} usages The allowed key usages. 17 * @param {KeyUsage[]} usages The allowed key usages.
18 * @constructor 18 * @constructor
19 */ 19 */
20 var KeyPairImpl = function(publicKeySpki, algorithm, usages) { 20 function KeyPairImpl(publicKeySpki, algorithm, usages) {
21 this.publicKey = new Key(KeyType.public, 21 this.publicKey = new Key(KeyType.public,
22 publicKeySpki, 22 publicKeySpki,
23 algorithm, 23 algorithm,
24 intersect([KeyUsage.verify], usages), 24 intersect([KeyUsage.verify], usages),
25 true /* extractable */); 25 true /* extractable */);
26 this.privateKey = new Key(KeyType.private, 26 this.privateKey = new Key(KeyType.private,
27 publicKeySpki, 27 publicKeySpki,
28 algorithm, 28 algorithm,
29 intersect([KeyUsage.sign], usages), 29 intersect([KeyUsage.sign], usages),
30 false /* not extractable */); 30 false /* not extractable */);
31 }; 31 }
32 $Object.setPrototypeOf(KeyPairImpl.prototype, null);
32 33
33 function KeyPair() { 34 function KeyPair() {
34 privates(KeyPair).constructPrivate(this, arguments); 35 privates(KeyPair).constructPrivate(this, arguments);
35 } 36 }
36 utils.expose(KeyPair, KeyPairImpl, { 37 utils.expose(KeyPair, KeyPairImpl, {
37 readonly: [ 38 readonly: [
38 'publicKey', 39 'publicKey',
39 'privateKey', 40 'privateKey',
40 ], 41 ],
41 }); 42 });
42 43
43 exports.$set('KeyPair', KeyPair); 44 exports.$set('KeyPair', KeyPair);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698