OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var utils = require('utils'); |
| 6 var intersect = require('enterprise.platformKeys.utils').intersect; |
| 7 var keyModule = require('enterprise.platformKeys.Key'); |
| 8 var Key = keyModule.Key; |
| 9 var KeyType = keyModule.KeyType; |
| 10 var KeyUsage = keyModule.KeyUsage; |
| 11 |
| 12 /** |
| 13 * Implementation of WebCrypto.KeyPair used in enterprise.platformKeys. |
| 14 * @param {ArrayBuffer} publicKeySpki The Subject Public Key Info in DER |
| 15 * encoding. |
| 16 * @param {KeyAlgorithm} algorithm The algorithm identifier. |
| 17 * @param {KeyUsage[]} usages The allowed key usages. |
| 18 * @constructor |
| 19 */ |
| 20 var KeyPairImpl = function(publicKeySpki, algorithm, usages) { |
| 21 this.publicKey = new Key(KeyType.public, |
| 22 publicKeySpki, |
| 23 algorithm, |
| 24 intersect([KeyUsage.verify], usages), |
| 25 true /* extractable */); |
| 26 this.privateKey = new Key(KeyType.private, |
| 27 publicKeySpki, |
| 28 algorithm, |
| 29 intersect([KeyUsage.sign], usages), |
| 30 false /* not extractable */); |
| 31 }; |
| 32 |
| 33 exports.KeyPair = utils.expose('KeyPair', |
| 34 KeyPairImpl, |
| 35 {readonly:['publicKey', 'privateKey']}); |
OLD | NEW |