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 internalAPI = require('enterprise.platformKeys.internalAPI'); | 6 var internalAPI = require('enterprise.platformKeys.internalAPI'); |
7 var intersect = require('enterprise.platformKeys.utils').intersect; | 7 var intersect = require('enterprise.platformKeys.utils').intersect; |
8 var KeyPair = require('enterprise.platformKeys.KeyPair').KeyPair; | 8 var KeyPair = require('enterprise.platformKeys.KeyPair').KeyPair; |
9 var keyModule = require('enterprise.platformKeys.Key'); | 9 var keyModule = require('enterprise.platformKeys.Key'); |
10 var getSpki = keyModule.getSpki; | 10 var getSpki = keyModule.getSpki; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 throw CreateDataError(); | 95 throw CreateDataError(); |
96 } | 96 } |
97 var normalizedAlgorithmParameters = | 97 var normalizedAlgorithmParameters = |
98 normalizeAlgorithm(algorithm, 'GenerateKey'); | 98 normalizeAlgorithm(algorithm, 'GenerateKey'); |
99 if (!normalizedAlgorithmParameters) { | 99 if (!normalizedAlgorithmParameters) { |
100 // TODO(pneubeck): It's not clear from the WebCrypto spec which error to | 100 // TODO(pneubeck): It's not clear from the WebCrypto spec which error to |
101 // throw here. | 101 // throw here. |
102 throw CreateSyntaxError(); | 102 throw CreateSyntaxError(); |
103 } | 103 } |
104 | 104 |
| 105 // normalizeAlgorithm returns an array, but publicExponent should be a |
| 106 // Uint8Array. |
| 107 normalizedAlgorithmParameters.publicExponent = |
| 108 new Uint8Array(normalizedAlgorithmParameters.publicExponent); |
| 109 |
105 if (normalizedAlgorithmParameters.name !== 'RSASSA-PKCS1-v1_5' || | 110 if (normalizedAlgorithmParameters.name !== 'RSASSA-PKCS1-v1_5' || |
106 !equalsStandardPublicExponent( | 111 !equalsStandardPublicExponent( |
107 normalizedAlgorithmParameters.publicExponent)) { | 112 normalizedAlgorithmParameters.publicExponent)) { |
108 // Note: This deviates from WebCrypto.SubtleCrypto. | 113 // Note: This deviates from WebCrypto.SubtleCrypto. |
109 throw CreateNotSupportedError(); | 114 throw CreateNotSupportedError(); |
110 } | 115 } |
111 | 116 |
112 internalAPI.generateKey(subtleCrypto.tokenId, | 117 internalAPI.generateKey(subtleCrypto.tokenId, |
113 normalizedAlgorithmParameters.modulusLength, | 118 normalizedAlgorithmParameters.modulusLength, |
114 function(spki) { | 119 function(spki) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // TODO(pneubeck): It should be possible to export to format 'jwk'. | 176 // TODO(pneubeck): It should be possible to export to format 'jwk'. |
172 throw CreateNotSupportedError(); | 177 throw CreateNotSupportedError(); |
173 } | 178 } |
174 }); | 179 }); |
175 }; | 180 }; |
176 | 181 |
177 exports.SubtleCrypto = | 182 exports.SubtleCrypto = |
178 utils.expose('SubtleCrypto', | 183 utils.expose('SubtleCrypto', |
179 SubtleCryptoImpl, | 184 SubtleCryptoImpl, |
180 {functions:['generateKey', 'sign', 'exportKey']}); | 185 {functions:['generateKey', 'sign', 'exportKey']}); |
OLD | NEW |