chrome.enterprise.platformKeys

Description: Use the chrome.enterprise.platformKeys API to generate hardware-backed keys and to install certificates for these keys. The certificates will be managed by the platform and can be used for TLS authentication, network access or by other extension through chrome.platformKeys.
Availability: Since Chrome 37.
Permissions: "enterprise.platformKeys"

Important: This API works only on Chrome OS.

Note: This API is only for extensions pre-installed by policy.

Usage

Typical usage of this API to enroll a client certificate follows these steps:
  • Get all available tokens using enterprise.platformKeys.getTokens.
  • Find the Token with id equal "user". Use this Token subsequently.
  • Generate a key pair using the generateKey Token method (defined in SubtleCrypto). This will return handle to the key.
  • Export the public key using the exportKey Token method (defined in SubtleCrypto).
  • Create the signature of the certification request's data using the sign Token method (defined in SubtleCrypto).
  • Complete the certification request and send it to the certification authority.
  • If a certificate is received, import it using enterprise.platformKeys.importCertificate

Here's an example that shows the major API interaction except the building and sending of the certification request:

      function getUserToken(callback) {
        chrome.enterprise.platformKeys.getTokens(function(tokens) {
          for (var i = 0; i < tokens.length; i++) {
            if (tokens[i].id == "user") {
              callback(tokens[i]);
              return;
            }
          }
          callback(undefined);
        });
      }
      
      function generateAndSign(userToken) {
        var data = new Uint8Array([0, 5, 1, 2, 3, 4, 5, 6]);
        var algorithm = {
          name: "RSASSA-PKCS1-v1_5",
          // RsaHashedKeyGenParams
          modulusLength: 2048,
          publicExponent:
              new Uint8Array([0x01, 0x00, 0x01]),  // Equivalent to 65537
          hash: {
            name: "SHA-1",
          }
        };
        var cachedKeyPair;
        userToken.subtleCrypto.generateKey(algorithm, false, ["sign"])
          .then(function(keyPair) {
                  cachedKeyPair = keyPair;
                  return userToken.subtleCrypto.exportKey("spki", keyPair.publicKey);
                },
                console.log.bind(console))
          .then(function(publicKeySpki) {
                  // Build the Certification Request using the public key.
                  return userToken.subtleCrypto.sign(
                      {name : "RSASSA-PKCS1-v1_5"}, cachedKeyPair.privateKey, data);
                },
                console.log.bind(console))
          .then(function(signature) {
                    // Complete the Certification Request with |signature|.
                    // Send out the request to the CA, calling back
                    // onClientCertificateReceived.
                },
                console.log.bind(console));
      }
      
      function onClientCertificateReceived(userToken, certificate) {
        chrome.enterprise.platformKeys.importCertificate(userToken.id, certificate);
      }
      
      getUserToken(generateAndSign);
      

Summary

Types
Token
Methods
getTokens chrome.enterprise.platformKeys.getTokens(function callback)
getCertificates chrome.enterprise.platformKeys.getCertificates(string tokenId, function callback)
importCertificate chrome.enterprise.platformKeys.importCertificate(string tokenId, ArrayBuffer certificate, function callback)
removeCertificate chrome.enterprise.platformKeys.removeCertificate(string tokenId, ArrayBuffer certificate, function callback)
challengeMachineKey chrome.enterprise.platformKeys.challengeMachineKey(ArrayBuffer challenge, boolean registerKey, function callback)
challengeUserKey chrome.enterprise.platformKeys.challengeUserKey(ArrayBuffer challenge, boolean registerKey, function callback)

Types

Token

properties
string id

Uniquely identifies this Token.

Static IDs are "user" and "system", referring to the platform's user-specific and the system-wide hardware token, respectively. Any other tokens (with other identifiers) might be returned by enterprise.platformKeys.getTokens.

SubtleCrypto subtleCrypto

Implements the WebCrypto's SubtleCrypto interface. The cryptographic operations, including key generation, are hardware-backed.

Only non-extractable RSASSA-PKCS1-V1_5 keys with modulusLength up to 2048 can be generated. Each key can be used for signing data at most once.

Keys generated on a specific Token cannot be used with any other Tokens, nor can they be used with window.crypto.subtle. Equally, Key objects created with window.crypto.subtle cannot be used with this interface.

Methods

getTokens

chrome.enterprise.platformKeys.getTokens(function callback)

Returns the available Tokens. In a regular user's session the list will always contain the user's token with id "user". If a system-wide TPM token is available, the returned list will also contain the system-wide token with id "system". The system-wide token will be the same for all sessions on this device (device in the sense of e.g. a Chromebook).

Parameters
function callback

Invoked by getTokens with the list of available Tokens.

The callback parameter should be a function that looks like this:

function(array of Token tokens) {...};
array of Token tokens

The list of available tokens.

getCertificates

chrome.enterprise.platformKeys.getCertificates(string tokenId, function callback)

Returns the list of all client certificates available from the given token. Can be used to check for the existence and expiration of client certificates that are usable for a certain authentication.

Parameters
string tokenId

The id of a Token returned by getTokens.

function callback

Called back with the list of the available certificates.

The callback parameter should be a function that looks like this:

function(array of ArrayBuffer certificates) {...};
array of ArrayBuffer certificates

The list of certificates, each in DER encoding of a X.509 certificate.

importCertificate

chrome.enterprise.platformKeys.importCertificate(string tokenId, ArrayBuffer certificate, function callback)

Imports certificate to the given token if the certified key is already stored in this token. After a successful certification request, this function should be used to store the obtained certificate and to make it available to the operating system and browser for authentication.

Parameters
string tokenId

The id of a Token returned by getTokens.

ArrayBuffer certificate

The DER encoding of a X.509 certificate.

function (optional) callback

Called back when this operation is finished.

If you specify the callback parameter, it should be a function that looks like this:

function() {...};

removeCertificate

chrome.enterprise.platformKeys.removeCertificate(string tokenId, ArrayBuffer certificate, function callback)

Removes certificate from the given token if present. Should be used to remove obsolete certificates so that they are not considered during authentication and do not clutter the certificate choice. Should be used to free storage in the certificate store.

Parameters
string tokenId

The id of a Token returned by getTokens.

ArrayBuffer certificate

The DER encoding of a X.509 certificate.

function (optional) callback

Called back when this operation is finished.

If you specify the callback parameter, it should be a function that looks like this:

function() {...};

challengeMachineKey

chrome.enterprise.platformKeys.challengeMachineKey(ArrayBuffer challenge, boolean registerKey, function callback)

Since Chrome 50.

Challenges a hardware-backed Enterprise Machine Key and emits the response as part of a remote attestation protocol. Only useful on Chrome OS and in conjunction with the Verified Access Web API which both issues challenges and verifies responses. A successful verification by the Verified Access Web API is a strong signal of all of the following: * The current device is a legitimate Chrome OS device. * The current device is managed by the domain specified during verification. * The current signed-in user is managed by the domain specified during verification. * The current device state complies with enterprise device policy. For example, a policy may specify that the device must not be in developer mode. * Any device identity emitted by the verification is tightly bound to the hardware of the current device. This function is highly restricted and will fail if the current device is not managed, the current user is not managed, or if this operation has not explicitly been enabled for the caller by enterprise device policy. The Enterprise Machine Key does not reside in the "system" token and is not accessible by any other API.

Parameters
ArrayBuffer challenge

A challenge as emitted by the Verified Access Web API.

boolean (optional) registerKey

Since Chrome 59.

If set, the current Enterprise Machine Key is registered with the "system" token and relinquishes the Enterprise Machine Key role. The key can then be associated with a certificate and used like any other signing key. This key is 2048-bit RSA. Subsequent calls to this function will then generate a new Enterprise Machine Key.

function callback

Called back with the challenge response.

The callback parameter should be a function that looks like this:

function(ArrayBuffer response) {...};
ArrayBuffer response

The challenge response.

challengeUserKey

chrome.enterprise.platformKeys.challengeUserKey(ArrayBuffer challenge, boolean registerKey, function callback)

Since Chrome 50.

Challenges a hardware-backed Enterprise User Key and emits the response as part of a remote attestation protocol. Only useful on Chrome OS and in conjunction with the Verified Access Web API which both issues challenges and verifies responses. A successful verification by the Verified Access Web API is a strong signal of all of the following: * The current device is a legitimate Chrome OS device. * The current device is managed by the domain specified during verification. * The current signed-in user is managed by the domain specified during verification. * The current device state complies with enterprise user policy. For example, a policy may specify that the device must not be in developer mode. * The public key emitted by the verification is tightly bound to the hardware of the current device and to the current signed-in user. This function is highly restricted and will fail if the current device is not managed, the current user is not managed, or if this operation has not explicitly been enabled for the caller by enterprise user policy. The Enterprise User Key does not reside in the "user" token and is not accessible by any other API.

Parameters
ArrayBuffer challenge

A challenge as emitted by the Verified Access Web API.

boolean registerKey

If set, the current Enterprise User Key is registered with the "user" token and relinquishes the Enterprise User Key role. The key can then be associated with a certificate and used like any other signing key. This key is 2048-bit RSA. Subsequent calls to this function will then generate a new Enterprise User Key.

function callback

Called back with the challenge response.

The callback parameter should be a function that looks like this:

function(ArrayBuffer response) {...};
ArrayBuffer response

The challenge response.