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

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

Issue 214863002: Extension API enterprise.platformKeys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Asynchronous calls revisited. Created 6 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 | Annotate | Revision Log
OLDNEW
(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
7 /**
8 * Enum of possible key types (subset of WebCrypto.KeyType).
9 * @enum {string}
10 */
11 var KeyType = {
12 public: 'public',
13 private: 'private'
14 };
15
16 /**
17 * Enum of possible key usages (subset of WebCrypto.KeyUsage).
18 * @enum {string}
19 */
20 var KeyUsage = {
21 sign: 'sign',
22 verify: 'verify'
23 };
24
25 /**
26 * Implementation of WebCrypto.Key used in enterprise.platformKeys.
27 * @param {KeyType} type The type of the new key.
28 * @param {ArrayBuffer} publicKeySpki The Subject Public Key Info in DER
29 * encoding.
30 * @param {KeyAlgorithm} algorithm The algorithm identifier.
31 * @param {KeyUsage[]} usages The allowed key usages.
32 * @param {boolean} extractable Whether the key is extractable.
33 * @constructor
34 */
35 var KeyImpl = function(type, publicKeySpki, algorithm, usages, extractable) {
36 this.type = type;
37 this.spki = publicKeySpki;
38 this.algorithm = algorithm;
39 this.usages = usages;
40 this.extractable = extractable;
41 };
42
43 var Key =
44 utils.expose('Key',
45 KeyImpl,
46 {readonly:['extractable', 'type', 'algorithm', 'usages']});
47
48 /**
49 * Returns |key|'s Subject Public Key Info. Throws an exception if |key| is not
50 * a valid Key object.
51 * @param {Key} key
52 * @return {ArrayBuffer} The Subject Public Key Info in DER encoding of |key|.
53 */
54 function getSpki(key) {
55 if (!privates(key))
56 throw new Error('Invalid key object.');
57 var keyImpl = privates(key).impl;
58 if (!keyImpl || !keyImpl.spki)
59 throw new Error('Invalid key object.');
60 return keyImpl.spki;
61 }
62
63 exports.Key = Key;
64 exports.KeyType = KeyType;
65 exports.KeyUsage = KeyUsage;
66 exports.getSpki = getSpki;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698