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

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

Issue 1939833003: Sanitize inheritance in callers of utils.expose (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: 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 internalAPI = require('enterprise.platformKeys.internalAPI'); 6 var internalAPI = require('enterprise.platformKeys.internalAPI');
7 var intersect = require('platformKeys.utils').intersect; 7 var intersect = require('platformKeys.utils').intersect;
8 var subtleCryptoModule = require('platformKeys.SubtleCrypto'); 8 var subtleCryptoModule = require('platformKeys.SubtleCrypto');
9 var SubtleCryptoImpl = subtleCryptoModule.SubtleCryptoImpl; 9 var SubtleCryptoImpl = subtleCryptoModule.SubtleCryptoImpl;
10 var KeyPair = require('enterprise.platformKeys.KeyPair').KeyPair; 10 var KeyPair = require('enterprise.platformKeys.KeyPair').KeyPair;
11 var KeyUsage = require('platformKeys.Key').KeyUsage; 11 var KeyUsage = require('platformKeys.Key').KeyUsage;
12 12
13 var normalizeAlgorithm = 13 var normalizeAlgorithm =
14 requireNative('platform_keys_natives').NormalizeAlgorithm; 14 requireNative('platform_keys_natives').NormalizeAlgorithm;
15 15
16 // This error is thrown by the internal and public API's token functions and 16 // This error is thrown by the internal and public API's token functions and
17 // must be rethrown by this custom binding. Keep this in sync with the C++ part 17 // must be rethrown by this custom binding. Keep this in sync with the C++ part
18 // of this API. 18 // of this API.
19 var errorInvalidToken = "The token is not valid."; 19 var errorInvalidToken = 'The token is not valid.';
20 20
21 // The following errors are specified in WebCrypto. 21 // The following errors are specified in WebCrypto.
22 // TODO(pneubeck): These should be DOMExceptions. 22 // TODO(pneubeck): These should be DOMExceptions.
23 function CreateNotSupportedError() { 23 function CreateNotSupportedError() {
24 return new Error('The algorithm is not supported'); 24 return new Error('The algorithm is not supported');
25 } 25 }
26 26
27 function CreateInvalidAccessError() { 27 function CreateInvalidAccessError() {
28 return new Error('The requested operation is not valid for the provided key'); 28 return new Error('The requested operation is not valid for the provided key');
29 } 29 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 return true; 70 return true;
71 } 71 }
72 72
73 /** 73 /**
74 * Implementation of WebCrypto.SubtleCrypto used in enterprise.platformKeys. 74 * Implementation of WebCrypto.SubtleCrypto used in enterprise.platformKeys.
75 * Derived from platformKeys.SubtleCrypto. 75 * Derived from platformKeys.SubtleCrypto.
76 * @param {string} tokenId The id of the backing Token. 76 * @param {string} tokenId The id of the backing Token.
77 * @constructor 77 * @constructor
78 */ 78 */
79 var EnterpriseSubtleCryptoImpl = function(tokenId) { 79 function EnterpriseSubtleCryptoImpl(tokenId) {
80 SubtleCryptoImpl.call(this, tokenId); 80 $Function.call(SubtleCryptoImpl, this, tokenId);
81 }; 81 }
82 82
83 EnterpriseSubtleCryptoImpl.prototype = 83 EnterpriseSubtleCryptoImpl.prototype =
84 Object.create(SubtleCryptoImpl.prototype); 84 $Object.create(SubtleCryptoImpl.prototype);
85 85
86 EnterpriseSubtleCryptoImpl.prototype.generateKey = 86 EnterpriseSubtleCryptoImpl.prototype.generateKey =
87 function(algorithm, extractable, keyUsages) { 87 function(algorithm, extractable, keyUsages) {
88 var subtleCrypto = this; 88 var subtleCrypto = this;
89 return new Promise(function(resolve, reject) { 89 return new Promise(function(resolve, reject) {
90 // TODO(pneubeck): Apply the algorithm normalization of the WebCrypto 90 // TODO(pneubeck): Apply the algorithm normalization of the WebCrypto
91 // implementation. 91 // implementation.
92 92
93 if (extractable) { 93 if (extractable) {
94 // Note: This deviates from WebCrypto.SubtleCrypto. 94 // Note: This deviates from WebCrypto.SubtleCrypto.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 utils.expose(SubtleCrypto, EnterpriseSubtleCryptoImpl, { 138 utils.expose(SubtleCrypto, EnterpriseSubtleCryptoImpl, {
139 superclass: subtleCryptoModule.SubtleCrypto, 139 superclass: subtleCryptoModule.SubtleCrypto,
140 functions: [ 140 functions: [
141 'generateKey', 141 'generateKey',
142 // 'sign', 'exportKey' are exposed by the base class 142 // 'sign', 'exportKey' are exposed by the base class
143 ], 143 ],
144 }); 144 });
145 145
146 exports.$set('SubtleCrypto', SubtleCrypto); 146 exports.$set('SubtleCrypto', SubtleCrypto);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698