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.
5 var utils
= require('utils');
6 var intersect
= require('platformKeys.utils').intersect
;
7 var keyModule
= require('platformKeys.Key');
8 var Key
= keyModule
.Key
;
9 var KeyType
= keyModule
.KeyType
;
10 var KeyUsage
= keyModule
.KeyUsage
;
13 * Implementation of WebCrypto.KeyPair used in enterprise.platformKeys.
14 * @param {ArrayBuffer} publicKeySpki The Subject Public Key Info in DER
16 * @param {KeyAlgorithm} algorithm The algorithm identifier.
17 * @param {KeyUsage[]} usages The allowed key usages.
20 var KeyPairImpl = function(publicKeySpki
, algorithm
, usages
) {
21 this.publicKey
= new Key(KeyType
.public,
24 intersect([KeyUsage
.verify
], usages
),
25 true /* extractable */);
26 this.privateKey
= new Key(KeyType
.private,
29 intersect([KeyUsage
.sign
], usages
),
30 false /* not extractable */);
33 exports
.KeyPair
= utils
.expose('KeyPair',
35 {readonly
:['publicKey', 'privateKey']});