Bug 1026314 - Rename Key to CryptoKey in WebCrypto r=rbarnes,bz
☠☠ backed out by 225cc2ec2231 ☠ ☠
authorTim Taubert <ttaubert@mozilla.com>
Mon, 23 Jun 2014 23:25:13 +0200
changeset 214340 38831e922852b53b7552e38582c18d98f20ac19b
parent 214339 e5c7ac63a01754a39648b2abb0f13c0a1af77f25
child 214341 523ef80786ad8544c394ffb3673c5a82c3c839cf
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrbarnes, bz
bugs1026314
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1026314 - Rename Key to CryptoKey in WebCrypto r=rbarnes,bz
dom/base/SubtleCrypto.cpp
dom/base/SubtleCrypto.h
dom/base/nsJSEnvironment.cpp
dom/crypto/CryptoKey.cpp
dom/crypto/CryptoKey.h
dom/crypto/CryptoKeyPair.cpp
dom/crypto/CryptoKeyPair.h
dom/crypto/Key.cpp
dom/crypto/Key.h
dom/crypto/KeyAlgorithm.h
dom/crypto/KeyPair.cpp
dom/crypto/KeyPair.h
dom/crypto/WebCryptoTask.cpp
dom/crypto/WebCryptoTask.h
dom/crypto/moz.build
dom/webidl/SubtleCrypto.webidl
--- a/dom/base/SubtleCrypto.cpp
+++ b/dom/base/SubtleCrypto.cpp
@@ -41,44 +41,44 @@ SubtleCrypto::WrapObject(JSContext* aCx)
   nsRefPtr<Promise> p = new Promise(global); \
   nsRefPtr<WebCryptoTask> task = WebCryptoTask::Operation ## Task(__VA_ARGS__); \
   task->DispatchWithPromise(p); \
   return p.forget();
 
 already_AddRefed<Promise>
 SubtleCrypto::Encrypt(JSContext* cx,
                       const ObjectOrString& algorithm,
-                      Key& key,
+                      CryptoKey& key,
                       const CryptoOperationData& data)
 {
   SUBTLECRYPTO_METHOD_BODY(Encrypt, cx, algorithm, key, data)
 }
 
 already_AddRefed<Promise>
 SubtleCrypto::Decrypt(JSContext* cx,
                       const ObjectOrString& algorithm,
-                      Key& key,
+                      CryptoKey& key,
                       const CryptoOperationData& data)
 {
   SUBTLECRYPTO_METHOD_BODY(Decrypt, cx, algorithm, key, data)
 }
 
 already_AddRefed<Promise>
 SubtleCrypto::Sign(JSContext* cx,
                    const ObjectOrString& algorithm,
-                   Key& key,
+                   CryptoKey& key,
                    const CryptoOperationData& data)
 {
   SUBTLECRYPTO_METHOD_BODY(Sign, cx, algorithm, key, data)
 }
 
 already_AddRefed<Promise>
 SubtleCrypto::Verify(JSContext* cx,
                      const ObjectOrString& algorithm,
-                     Key& key,
+                     CryptoKey& key,
                      const CryptoOperationData& signature,
                      const CryptoOperationData& data)
 {
   SUBTLECRYPTO_METHOD_BODY(Verify, cx, algorithm, key, signature, data)
 }
 
 already_AddRefed<Promise>
 SubtleCrypto::Digest(JSContext* cx,
@@ -98,42 +98,42 @@ SubtleCrypto::ImportKey(JSContext* cx,
                         const Sequence<nsString>& keyUsages)
 {
   SUBTLECRYPTO_METHOD_BODY(ImportKey, cx, format, keyData, algorithm,
                                       extractable, keyUsages)
 }
 
 already_AddRefed<Promise>
 SubtleCrypto::ExportKey(const nsAString& format,
-                        Key& key)
+                        CryptoKey& key)
 {
   SUBTLECRYPTO_METHOD_BODY(ExportKey, format, key)
 }
 
 already_AddRefed<Promise>
 SubtleCrypto::GenerateKey(JSContext* cx, const ObjectOrString& algorithm,
                           bool extractable, const Sequence<nsString>& keyUsages)
 {
   SUBTLECRYPTO_METHOD_BODY(GenerateKey, cx, algorithm, extractable, keyUsages)
 }
 
 already_AddRefed<Promise>
 SubtleCrypto::DeriveKey(JSContext* cx,
                         const ObjectOrString& algorithm,
-                        Key& baseKey,
+                        CryptoKey& baseKey,
                         const ObjectOrString& derivedKeyType,
                         bool extractable, const Sequence<nsString>& keyUsages)
 {
   SUBTLECRYPTO_METHOD_BODY(DeriveKey, cx, algorithm, baseKey, derivedKeyType,
                                       extractable, keyUsages)
 }
 
 already_AddRefed<Promise>
 SubtleCrypto::DeriveBits(JSContext* cx,
                          const ObjectOrString& algorithm,
-                         Key& baseKey,
+                         CryptoKey& baseKey,
                          uint32_t length)
 {
   SUBTLECRYPTO_METHOD_BODY(DeriveBits, cx, algorithm, baseKey, length)
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/SubtleCrypto.h
+++ b/dom/base/SubtleCrypto.h
@@ -6,17 +6,17 @@
 
 #ifndef mozilla_dom_SubtleCrypto_h
 #define mozilla_dom_SubtleCrypto_h
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsPIDOMWindow.h"
 #include "mozilla/dom/UnionTypes.h"
-#include "mozilla/dom/Key.h"
+#include "mozilla/dom/CryptoKey.h"
 #include "js/TypeDecls.h"
 
 namespace mozilla {
 namespace dom {
 
 class Promise;
 
 typedef ArrayBufferViewOrArrayBuffer CryptoOperationData;
@@ -38,63 +38,63 @@ public:
   {
     return mWindow;
   }
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   already_AddRefed<Promise> Encrypt(JSContext* cx,
                                     const ObjectOrString& algorithm,
-                                    Key& key,
+                                    CryptoKey& key,
                                     const CryptoOperationData& data);
 
   already_AddRefed<Promise> Decrypt(JSContext* cx,
                                     const ObjectOrString& algorithm,
-                                    Key& key,
+                                    CryptoKey& key,
                                     const CryptoOperationData& data);
 
   already_AddRefed<Promise> Sign(JSContext* cx,
                                  const ObjectOrString& algorithm,
-                                 Key& key,
+                                 CryptoKey& key,
                                  const CryptoOperationData& data);
 
   already_AddRefed<Promise> Verify(JSContext* cx,
                                    const ObjectOrString& algorithm,
-                                   Key& key,
+                                   CryptoKey& key,
                                    const CryptoOperationData& signature,
                                    const CryptoOperationData& data);
 
   already_AddRefed<Promise> Digest(JSContext* cx,
                                    const ObjectOrString& aAlgorithm,
                                    const CryptoOperationData& aData);
 
   already_AddRefed<Promise> ImportKey(JSContext* cx,
                                       const nsAString& format,
                                       const KeyData& keyData,
                                       const ObjectOrString& algorithm,
                                       bool extractable,
                                       const Sequence<nsString>& keyUsages);
 
-  already_AddRefed<Promise> ExportKey(const nsAString& format, Key& key);
+  already_AddRefed<Promise> ExportKey(const nsAString& format, CryptoKey& key);
 
   already_AddRefed<Promise> GenerateKey(JSContext* cx,
                                         const ObjectOrString& algorithm,
                                         bool extractable,
                                         const Sequence<nsString>& keyUsages);
 
   already_AddRefed<Promise> DeriveKey(JSContext* cx,
                                       const ObjectOrString& algorithm,
-                                      Key& baseKey,
+                                      CryptoKey& baseKey,
                                       const ObjectOrString& derivedKeyType,
                                       bool extractable,
                                       const Sequence<nsString>& keyUsages);
 
   already_AddRefed<Promise> DeriveBits(JSContext* cx,
                                        const ObjectOrString& algorithm,
-                                       Key& baseKey,
+                                       CryptoKey& baseKey,
                                        uint32_t length);
 
 private:
   nsCOMPtr<nsPIDOMWindow> mWindow;
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -51,17 +51,17 @@
 #include "prmem.h"
 #include "WrapperFactory.h"
 #include "nsGlobalWindow.h"
 #include "nsScriptNameSpaceManager.h"
 #include "StructuredCloneTags.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/dom/ErrorEvent.h"
 #include "mozilla/dom/ImageData.h"
-#include "mozilla/dom/Key.h"
+#include "mozilla/dom/CryptoKey.h"
 #include "mozilla/dom/ImageDataBinding.h"
 #include "mozilla/dom/SubtleCryptoBinding.h"
 #include "nsAXPCNativeCallContext.h"
 #include "mozilla/CycleCollectedJSRuntime.h"
 
 #include "nsJSPrincipals.h"
 
 #ifdef XP_MACOSX
@@ -2816,17 +2816,17 @@ NS_DOMReadStructuredClone(JSContext* cx,
     nsIGlobalObject *global = xpc::GetNativeForGlobal(JS::CurrentGlobalOrNull(cx));
     if (!global) {
       return nullptr;
     }
 
     // Prevent the return value from being trashed by a GC during ~nsRefPtr.
     JS::Rooted<JSObject*> result(cx);
     {
-      nsRefPtr<Key> key = new Key(global);
+      nsRefPtr<CryptoKey> key = new CryptoKey(global);
       if (!key->ReadStructuredClone(reader)) {
         result = nullptr;
       } else {
         result = key->WrapObject(cx);
       }
     }
     return result;
   }
@@ -2854,18 +2854,18 @@ NS_DOMWriteStructuredClone(JSContext* cx
     JSAutoCompartment ac(cx, dataArray);
     JS::Rooted<JS::Value> arrayValue(cx, JS::ObjectValue(*dataArray));
     return JS_WriteUint32Pair(writer, SCTAG_DOM_IMAGEDATA, 0) &&
            JS_WriteUint32Pair(writer, width, height) &&
            JS_WriteTypedArray(writer, arrayValue);
   }
 
   // Handle Key cloning
-  Key* key;
-  if (NS_SUCCEEDED(UNWRAP_OBJECT(Key, obj, key))) {
+  CryptoKey* key;
+  if (NS_SUCCEEDED(UNWRAP_OBJECT(CryptoKey, obj, key))) {
     return JS_WriteUint32Pair(writer, SCTAG_DOM_WEBCRYPTO_KEY, 0) &&
            key->WriteStructuredClone(writer);
   }
 
   // Don't know what this is
   xpc::Throw(cx, NS_ERROR_DOM_DATA_CLONE_ERR);
   return false;
 }
rename from dom/crypto/Key.cpp
rename to dom/crypto/CryptoKey.cpp
--- a/dom/crypto/Key.cpp
+++ b/dom/crypto/CryptoKey.cpp
@@ -2,107 +2,107 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "pk11pub.h"
 #include "cryptohi.h"
 #include "ScopedNSSTypes.h"
-#include "mozilla/dom/Key.h"
+#include "mozilla/dom/CryptoKey.h"
 #include "mozilla/dom/WebCryptoCommon.h"
 #include "mozilla/dom/SubtleCryptoBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Key, mGlobal, mAlgorithm)
-NS_IMPL_CYCLE_COLLECTING_ADDREF(Key)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(Key)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Key)
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CryptoKey, mGlobal, mAlgorithm)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(CryptoKey)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(CryptoKey)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CryptoKey)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 nsresult
-StringToUsage(const nsString& aUsage, Key::KeyUsage& aUsageOut)
+StringToUsage(const nsString& aUsage, CryptoKey::KeyUsage& aUsageOut)
 {
   if (aUsage.EqualsLiteral(WEBCRYPTO_KEY_USAGE_ENCRYPT)) {
-    aUsageOut = Key::ENCRYPT;
+    aUsageOut = CryptoKey::ENCRYPT;
   } else if (aUsage.EqualsLiteral(WEBCRYPTO_KEY_USAGE_DECRYPT)) {
-    aUsageOut = Key::DECRYPT;
+    aUsageOut = CryptoKey::DECRYPT;
   } else if (aUsage.EqualsLiteral(WEBCRYPTO_KEY_USAGE_SIGN)) {
-    aUsageOut = Key::SIGN;
+    aUsageOut = CryptoKey::SIGN;
   } else if (aUsage.EqualsLiteral(WEBCRYPTO_KEY_USAGE_VERIFY)) {
-    aUsageOut = Key::VERIFY;
+    aUsageOut = CryptoKey::VERIFY;
   } else if (aUsage.EqualsLiteral(WEBCRYPTO_KEY_USAGE_DERIVEKEY)) {
-    aUsageOut = Key::DERIVEKEY;
+    aUsageOut = CryptoKey::DERIVEKEY;
   } else if (aUsage.EqualsLiteral(WEBCRYPTO_KEY_USAGE_DERIVEBITS)) {
-    aUsageOut = Key::DERIVEBITS;
+    aUsageOut = CryptoKey::DERIVEBITS;
   } else if (aUsage.EqualsLiteral(WEBCRYPTO_KEY_USAGE_WRAPKEY)) {
-    aUsageOut = Key::WRAPKEY;
+    aUsageOut = CryptoKey::WRAPKEY;
   } else if (aUsage.EqualsLiteral(WEBCRYPTO_KEY_USAGE_UNWRAPKEY)) {
-    aUsageOut = Key::UNWRAPKEY;
+    aUsageOut = CryptoKey::UNWRAPKEY;
   } else {
     return NS_ERROR_DOM_SYNTAX_ERR;
   }
   return NS_OK;
 }
 
-Key::Key(nsIGlobalObject* aGlobal)
+CryptoKey::CryptoKey(nsIGlobalObject* aGlobal)
   : mGlobal(aGlobal)
   , mAttributes(0)
   , mSymKey()
   , mPrivateKey(nullptr)
   , mPublicKey(nullptr)
 {
   SetIsDOMBinding();
 }
 
-Key::~Key()
+CryptoKey::~CryptoKey()
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown()) {
     return;
   }
   destructorSafeDestroyNSSReference();
   shutdown(calledFromObject);
 }
 
 JSObject*
-Key::WrapObject(JSContext* aCx)
+CryptoKey::WrapObject(JSContext* aCx)
 {
-  return KeyBinding::Wrap(aCx, this);
+  return CryptoKeyBinding::Wrap(aCx, this);
 }
 
 void
-Key::GetType(nsString& aRetVal) const
+CryptoKey::GetType(nsString& aRetVal) const
 {
   uint32_t type = mAttributes & TYPE_MASK;
   switch (type) {
     case PUBLIC:  aRetVal.AssignLiteral(WEBCRYPTO_KEY_TYPE_PUBLIC); break;
     case PRIVATE: aRetVal.AssignLiteral(WEBCRYPTO_KEY_TYPE_PRIVATE); break;
     case SECRET:  aRetVal.AssignLiteral(WEBCRYPTO_KEY_TYPE_SECRET); break;
   }
 }
 
 bool
-Key::Extractable() const
+CryptoKey::Extractable() const
 {
   return (mAttributes & EXTRACTABLE);
 }
 
 KeyAlgorithm*
-Key::Algorithm() const
+CryptoKey::Algorithm() const
 {
   return mAlgorithm;
 }
 
 void
-Key::GetUsages(nsTArray<nsString>& aRetVal) const
+CryptoKey::GetUsages(nsTArray<nsString>& aRetVal) const
 {
   if (mAttributes & ENCRYPT) {
     aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_ENCRYPT));
   }
   if (mAttributes & DECRYPT) {
     aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_DECRYPT));
   }
   if (mAttributes & SIGN) {
@@ -120,24 +120,24 @@ Key::GetUsages(nsTArray<nsString>& aRetV
   if (mAttributes & WRAPKEY) {
     aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_WRAPKEY));
   }
   if (mAttributes & UNWRAPKEY) {
     aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_UNWRAPKEY));
   }
 }
 
-Key::KeyType
-Key::GetKeyType() const
+CryptoKey::KeyType
+CryptoKey::GetKeyType() const
 {
-  return static_cast<Key::KeyType>(mAttributes & TYPE_MASK);
+  return static_cast<CryptoKey::KeyType>(mAttributes & TYPE_MASK);
 }
 
 nsresult
-Key::SetType(const nsString& aType)
+CryptoKey::SetType(const nsString& aType)
 {
   mAttributes &= CLEAR_TYPE;
   if (aType.EqualsLiteral(WEBCRYPTO_KEY_TYPE_SECRET)) {
     mAttributes |= SECRET;
   } else if (aType.EqualsLiteral(WEBCRYPTO_KEY_TYPE_PUBLIC)) {
     mAttributes |= PUBLIC;
   } else if (aType.EqualsLiteral(WEBCRYPTO_KEY_TYPE_PRIVATE)) {
     mAttributes |= PRIVATE;
@@ -145,152 +145,152 @@ Key::SetType(const nsString& aType)
     mAttributes |= UNKNOWN;
     return NS_ERROR_DOM_SYNTAX_ERR;
   }
 
   return NS_OK;
 }
 
 void
-Key::SetType(Key::KeyType aType)
+CryptoKey::SetType(CryptoKey::KeyType aType)
 {
   mAttributes &= CLEAR_TYPE;
   mAttributes |= aType;
 }
 
 void
-Key::SetExtractable(bool aExtractable)
+CryptoKey::SetExtractable(bool aExtractable)
 {
   mAttributes &= CLEAR_EXTRACTABLE;
   if (aExtractable) {
     mAttributes |= EXTRACTABLE;
   }
 }
 
 void
-Key::SetAlgorithm(KeyAlgorithm* aAlgorithm)
+CryptoKey::SetAlgorithm(KeyAlgorithm* aAlgorithm)
 {
   mAlgorithm = aAlgorithm;
 }
 
 void
-Key::ClearUsages()
+CryptoKey::ClearUsages()
 {
   mAttributes &= CLEAR_USAGES;
 }
 
 nsresult
-Key::AddUsage(const nsString& aUsage)
+CryptoKey::AddUsage(const nsString& aUsage)
 {
   return AddUsageIntersecting(aUsage, USAGES_MASK);
 }
 
 nsresult
-Key::AddUsageIntersecting(const nsString& aUsage, uint32_t aUsageMask)
+CryptoKey::AddUsageIntersecting(const nsString& aUsage, uint32_t aUsageMask)
 {
   KeyUsage usage;
   if (NS_FAILED(StringToUsage(aUsage, usage))) {
     return NS_ERROR_DOM_SYNTAX_ERR;
   }
 
   if (usage & aUsageMask) {
     AddUsage(usage);
     return NS_OK;
   }
 
   return NS_OK;
 }
 
 void
-Key::AddUsage(Key::KeyUsage aUsage)
+CryptoKey::AddUsage(CryptoKey::KeyUsage aUsage)
 {
   mAttributes |= aUsage;
 }
 
 bool
-Key::HasUsage(Key::KeyUsage aUsage)
+CryptoKey::HasUsage(CryptoKey::KeyUsage aUsage)
 {
   return !!(mAttributes & aUsage);
 }
 
 bool
-Key::HasUsageOtherThan(uint32_t aUsages)
+CryptoKey::HasUsageOtherThan(uint32_t aUsages)
 {
   return !!(mAttributes & USAGES_MASK & ~aUsages);
 }
 
-void Key::SetSymKey(const CryptoBuffer& aSymKey)
+void CryptoKey::SetSymKey(const CryptoBuffer& aSymKey)
 {
   mSymKey = aSymKey;
 }
 
 void
-Key::SetPrivateKey(SECKEYPrivateKey* aPrivateKey)
+CryptoKey::SetPrivateKey(SECKEYPrivateKey* aPrivateKey)
 {
   nsNSSShutDownPreventionLock locker;
   if (!aPrivateKey || isAlreadyShutDown()) {
     mPrivateKey = nullptr;
     return;
   }
   mPrivateKey = SECKEY_CopyPrivateKey(aPrivateKey);
 }
 
 void
-Key::SetPublicKey(SECKEYPublicKey* aPublicKey)
+CryptoKey::SetPublicKey(SECKEYPublicKey* aPublicKey)
 {
   nsNSSShutDownPreventionLock locker;
   if (!aPublicKey || isAlreadyShutDown()) {
     mPublicKey = nullptr;
     return;
   }
   mPublicKey = SECKEY_CopyPublicKey(aPublicKey);
 }
 
 const CryptoBuffer&
-Key::GetSymKey() const
+CryptoKey::GetSymKey() const
 {
   return mSymKey;
 }
 
 SECKEYPrivateKey*
-Key::GetPrivateKey() const
+CryptoKey::GetPrivateKey() const
 {
   nsNSSShutDownPreventionLock locker;
   if (!mPrivateKey || isAlreadyShutDown()) {
     return nullptr;
   }
   return SECKEY_CopyPrivateKey(mPrivateKey.get());
 }
 
 SECKEYPublicKey*
-Key::GetPublicKey() const
+CryptoKey::GetPublicKey() const
 {
   nsNSSShutDownPreventionLock locker;
   if (!mPublicKey || isAlreadyShutDown()) {
     return nullptr;
   }
   return SECKEY_CopyPublicKey(mPublicKey.get());
 }
 
-void Key::virtualDestroyNSSReference()
+void CryptoKey::virtualDestroyNSSReference()
 {
   destructorSafeDestroyNSSReference();
 }
 
-void Key::destructorSafeDestroyNSSReference()
+void CryptoKey::destructorSafeDestroyNSSReference()
 {
   mPrivateKey.dispose();
   mPublicKey.dispose();
 }
 
 
 // Serialization and deserialization convenience methods
 
 SECKEYPrivateKey*
-Key::PrivateKeyFromPkcs8(CryptoBuffer& aKeyData,
+CryptoKey::PrivateKeyFromPkcs8(CryptoBuffer& aKeyData,
                          const nsNSSShutDownPreventionLock& /*proofOfLock*/)
 {
   SECKEYPrivateKey* privKey;
   ScopedPK11SlotInfo slot(PK11_GetInternalSlot());
   ScopedSECItem pkcs8Item(aKeyData.ToSECItem());
   if (!pkcs8Item) {
     return nullptr;
   }
@@ -304,92 +304,92 @@ Key::PrivateKeyFromPkcs8(CryptoBuffer& a
 
   if (NS_FAILED(rv)) {
     return nullptr;
   }
   return privKey;
 }
 
 SECKEYPublicKey*
-Key::PublicKeyFromSpki(CryptoBuffer& aKeyData,
+CryptoKey::PublicKeyFromSpki(CryptoBuffer& aKeyData,
                        const nsNSSShutDownPreventionLock& /*proofOfLock*/)
 {
   ScopedSECItem spkiItem(aKeyData.ToSECItem());
   if (!spkiItem) {
     return nullptr;
   }
 
   ScopedCERTSubjectPublicKeyInfo spki(SECKEY_DecodeDERSubjectPublicKeyInfo(spkiItem.get()));
   if (!spki) {
     return nullptr;
   }
 
   return SECKEY_ExtractPublicKey(spki.get());
 }
 
 nsresult
-Key::PrivateKeyToPkcs8(SECKEYPrivateKey* aPrivKey,
+CryptoKey::PrivateKeyToPkcs8(SECKEYPrivateKey* aPrivKey,
                        CryptoBuffer& aRetVal,
                        const nsNSSShutDownPreventionLock& /*proofOfLock*/)
 {
   ScopedSECItem pkcs8Item(PK11_ExportDERPrivateKeyInfo(aPrivKey, nullptr));
   if (!pkcs8Item.get()) {
     return NS_ERROR_DOM_INVALID_ACCESS_ERR;
   }
   aRetVal.Assign(pkcs8Item.get());
   return NS_OK;
 }
 
 nsresult
-Key::PublicKeyToSpki(SECKEYPublicKey* aPubKey,
+CryptoKey::PublicKeyToSpki(SECKEYPublicKey* aPubKey,
                      CryptoBuffer& aRetVal,
                      const nsNSSShutDownPreventionLock& /*proofOfLock*/)
 {
   ScopedSECItem spkiItem(PK11_DEREncodePublicKey(aPubKey));
   if (!spkiItem.get()) {
     return NS_ERROR_DOM_INVALID_ACCESS_ERR;
   }
 
   aRetVal.Assign(spkiItem.get());
   return NS_OK;
 }
 
 bool
-Key::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const
+CryptoKey::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown()) {
     return false;
   }
 
   // Write in five pieces
   // 1. Attributes
   // 2. Symmetric key as raw (if present)
   // 3. Private key as pkcs8 (if present)
   // 4. Public key as spki (if present)
   // 5. Algorithm in whatever form it chooses
   CryptoBuffer priv, pub;
 
   if (mPrivateKey) {
-    Key::PrivateKeyToPkcs8(mPrivateKey, priv, locker);
+    CryptoKey::PrivateKeyToPkcs8(mPrivateKey, priv, locker);
   }
 
   if (mPublicKey) {
-    Key::PublicKeyToSpki(mPublicKey, pub, locker);
+    CryptoKey::PublicKeyToSpki(mPublicKey, pub, locker);
   }
 
   return JS_WriteUint32Pair(aWriter, mAttributes, 0) &&
          WriteBuffer(aWriter, mSymKey) &&
          WriteBuffer(aWriter, priv) &&
          WriteBuffer(aWriter, pub) &&
          mAlgorithm->WriteStructuredClone(aWriter);
 }
 
 bool
-Key::ReadStructuredClone(JSStructuredCloneReader* aReader)
+CryptoKey::ReadStructuredClone(JSStructuredCloneReader* aReader)
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown()) {
     return false;
   }
 
   uint32_t zero;
   CryptoBuffer sym, priv, pub;
@@ -403,20 +403,20 @@ Key::ReadStructuredClone(JSStructuredClo
   if (!read) {
     return false;
   }
 
   if (sym.Length() > 0)  {
     mSymKey = sym;
   }
   if (priv.Length() > 0) {
-    mPrivateKey = Key::PrivateKeyFromPkcs8(priv, locker);
+    mPrivateKey = CryptoKey::PrivateKeyFromPkcs8(priv, locker);
   }
   if (pub.Length() > 0)  {
-    mPublicKey = Key::PublicKeyFromSpki(pub, locker);
+    mPublicKey = CryptoKey::PublicKeyFromSpki(pub, locker);
   }
   mAlgorithm = algorithm;
 
   // Ensure that what we've read is consistent
   // If the attributes indicate a key type, should have a key of that type
   if (!((GetKeyType() == SECRET  && mSymKey.Length() > 0) ||
         (GetKeyType() == PRIVATE && mPrivateKey) ||
         (GetKeyType() == PUBLIC  && mPublicKey))) {
rename from dom/crypto/Key.h
rename to dom/crypto/CryptoKey.h
--- a/dom/crypto/Key.h
+++ b/dom/crypto/CryptoKey.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef mozilla_dom_Key_h
-#define mozilla_dom_Key_h
+#ifndef mozilla_dom_CryptoKey_h
+#define mozilla_dom_CryptoKey_h
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsIGlobalObject.h"
 #include "nsNSSShutDown.h"
 #include "pk11pub.h"
 #include "keyhi.h"
 #include "ScopedNSSTypes.h"
@@ -44,27 +44,27 @@ In the order of a hex value for a uint32
  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |~~~~~~~~~~~~~~~|     Usage     |     Type      |~~~~~~~~~~~~~|E|
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
 Thus, internally, a key has the following fields:
 * uint32_t - flags for extractable, usage, type
 * KeyAlgorithm - the algorithm (which must serialize/deserialize itself)
-* The actual keys (which the Key must serialize)
+* The actual keys (which the CryptoKey must serialize)
 
 */
 
-class Key MOZ_FINAL : public nsISupports,
-                      public nsWrapperCache,
-                      public nsNSSShutDownObject
+class CryptoKey MOZ_FINAL : public nsISupports,
+                            public nsWrapperCache,
+                            public nsNSSShutDownObject
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Key)
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CryptoKey)
 
   static const uint32_t CLEAR_EXTRACTABLE = 0xFFFFFFE;
   static const uint32_t EXTRACTABLE = 0x00000001;
 
   static const uint32_t CLEAR_TYPE = 0xFFFF00FF;
   static const uint32_t TYPE_MASK = 0x0000FF00;
   enum KeyType {
     UNKNOWN = 0x00000000,
@@ -81,17 +81,17 @@ public:
     SIGN       = 0x00040000,
     VERIFY     = 0x00080000,
     DERIVEKEY  = 0x00100000,
     DERIVEBITS = 0x00200000,
     WRAPKEY    = 0x00400000,
     UNWRAPKEY  = 0x00800000
   };
 
-  Key(nsIGlobalObject* aWindow);
+  CryptoKey(nsIGlobalObject* aWindow);
 
   nsIGlobalObject* GetParentObject() const
   {
     return mGlobal;
   }
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
@@ -149,24 +149,24 @@ public:
                                   CryptoBuffer& aRetVal,
                                   const nsNSSShutDownPreventionLock& /*proofOfLock*/);
 
   // Structured clone methods use these to clone keys
   bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const;
   bool ReadStructuredClone(JSStructuredCloneReader* aReader);
 
 private:
-  ~Key();
+  ~CryptoKey();
 
   nsRefPtr<nsIGlobalObject> mGlobal;
   uint32_t mAttributes; // see above
   nsRefPtr<KeyAlgorithm> mAlgorithm;
 
   // Only one key handle should be set, according to the KeyType
   CryptoBuffer mSymKey;
   ScopedSECKEYPrivateKey mPrivateKey;
   ScopedSECKEYPublicKey mPublicKey;
 };
 
 } // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_dom_Key_h
+#endif // mozilla_dom_CryptoKey_h
rename from dom/crypto/KeyPair.cpp
rename to dom/crypto/CryptoKeyPair.cpp
--- a/dom/crypto/KeyPair.cpp
+++ b/dom/crypto/CryptoKeyPair.cpp
@@ -1,31 +1,31 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "mozilla/dom/KeyPair.h"
+#include "mozilla/dom/CryptoKeyPair.h"
 #include "mozilla/dom/SubtleCryptoBinding.h"
 #include "nsContentUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(KeyPair, mGlobal, mPublicKey, mPrivateKey)
-NS_IMPL_CYCLE_COLLECTING_ADDREF(KeyPair)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(KeyPair)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(KeyPair)
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CryptoKeyPair, mGlobal, mPublicKey, mPrivateKey)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(CryptoKeyPair)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(CryptoKeyPair)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CryptoKeyPair)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 JSObject*
-KeyPair::WrapObject(JSContext* aCx)
+CryptoKeyPair::WrapObject(JSContext* aCx)
 {
-  return KeyPairBinding::Wrap(aCx, this);
+  return CryptoKeyPairBinding::Wrap(aCx, this);
 }
 
 
 } // namespace dom
 } // namespace mozilla
rename from dom/crypto/KeyPair.h
rename to dom/crypto/CryptoKeyPair.h
--- a/dom/crypto/KeyPair.h
+++ b/dom/crypto/CryptoKeyPair.h
@@ -1,63 +1,63 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef mozilla_dom_KeyPair_h
-#define mozilla_dom_KeyPair_h
+#ifndef mozilla_dom_CryptoKeyPair_h
+#define mozilla_dom_CryptoKeyPair_h
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsIGlobalObject.h"
-#include "mozilla/dom/Key.h"
+#include "mozilla/dom/CryptoKey.h"
 #include "js/TypeDecls.h"
 
 namespace mozilla {
 namespace dom {
 
-class KeyPair MOZ_FINAL : public nsISupports,
-                          public nsWrapperCache
+class CryptoKeyPair MOZ_FINAL : public nsISupports,
+                                public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(KeyPair)
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CryptoKeyPair)
 
 public:
-  KeyPair(nsIGlobalObject* aGlobal)
+  CryptoKeyPair(nsIGlobalObject* aGlobal)
     : mGlobal(aGlobal)
-    , mPublicKey(new Key(aGlobal))
-    , mPrivateKey(new Key(aGlobal))
+    , mPublicKey(new CryptoKey(aGlobal))
+    , mPrivateKey(new CryptoKey(aGlobal))
   {
     SetIsDOMBinding();
   }
 
   nsIGlobalObject* GetParentObject() const
   {
     return mGlobal;
   }
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
-  Key* PublicKey() const
+  CryptoKey* PublicKey() const
   {
     return mPublicKey;
   }
 
-  Key* PrivateKey() const
+  CryptoKey* PrivateKey() const
   {
     return mPrivateKey;
   }
 
 private:
-  ~KeyPair() {}
+  ~CryptoKeyPair() {}
 
   nsRefPtr<nsIGlobalObject> mGlobal;
-  nsRefPtr<Key> mPublicKey;
-  nsRefPtr<Key> mPrivateKey;
+  nsRefPtr<CryptoKey> mPublicKey;
+  nsRefPtr<CryptoKey> mPrivateKey;
 };
 
 } // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_dom_KeyPair_h
+#endif // mozilla_dom_CryptoKeyPair_h
--- a/dom/crypto/KeyAlgorithm.h
+++ b/dom/crypto/KeyAlgorithm.h
@@ -13,17 +13,17 @@
 #include "pk11pub.h"
 #include "mozilla/dom/CryptoBuffer.h"
 #include "js/StructuredClone.h"
 #include "js/TypeDecls.h"
 
 namespace mozilla {
 namespace dom {
 
-class Key;
+class CryptoKey;
 class KeyAlgorithm;
 
 enum KeyAlgorithmStructuredCloneTags {
   SCTAG_KEYALG,
   SCTAG_AESKEYALG,
   SCTAG_HMACKEYALG,
   SCTAG_RSAKEYALG,
   SCTAG_RSAHASHEDKEYALG
--- a/dom/crypto/WebCryptoTask.cpp
+++ b/dom/crypto/WebCryptoTask.cpp
@@ -6,19 +6,19 @@
 
 #include "pk11pub.h"
 #include "cryptohi.h"
 #include "secerr.h"
 #include "ScopedNSSTypes.h"
 
 #include "mozilla/dom/WebCryptoTask.h"
 #include "mozilla/dom/TypedArray.h"
-#include "mozilla/dom/Key.h"
+#include "mozilla/dom/CryptoKey.h"
 #include "mozilla/dom/KeyAlgorithm.h"
-#include "mozilla/dom/KeyPair.h"
+#include "mozilla/dom/CryptoKeyPair.h"
 #include "mozilla/dom/AesKeyAlgorithm.h"
 #include "mozilla/dom/HmacKeyAlgorithm.h"
 #include "mozilla/dom/RsaKeyAlgorithm.h"
 #include "mozilla/dom/RsaHashedKeyAlgorithm.h"
 #include "mozilla/dom/CryptoBuffer.h"
 #include "mozilla/dom/WebCryptoCommon.h"
 
 #include "mozilla/Telemetry.h"
@@ -226,17 +226,17 @@ private:
     mResultPromise->MaybeResolve(ret);
   }
 };
 
 class AesTask : public ReturnArrayBufferViewTask
 {
 public:
   AesTask(JSContext* aCx, const ObjectOrString& aAlgorithm,
-          mozilla::dom::Key& aKey, const CryptoOperationData& aData,
+          mozilla::dom::CryptoKey& aKey, const CryptoOperationData& aData,
           bool aEncrypt)
     : mSymKey(aKey.GetSymKey())
     , mEncrypt(aEncrypt)
   {
     ATTEMPT_BUFFER_INIT(mData, aData);
 
     nsString algName;
     mEarlyRv = GetAlgorithmName(aCx, aAlgorithm, algName);
@@ -403,17 +403,17 @@ private:
     return rv;
   }
 };
 
 class RsaesPkcs1Task : public ReturnArrayBufferViewTask
 {
 public:
   RsaesPkcs1Task(JSContext* aCx, const ObjectOrString& aAlgorithm,
-                 mozilla::dom::Key& aKey, const CryptoOperationData& aData,
+                 mozilla::dom::CryptoKey& aKey, const CryptoOperationData& aData,
                  bool aEncrypt)
     : mPrivKey(aKey.GetPrivateKey())
     , mPubKey(aKey.GetPublicKey())
     , mEncrypt(aEncrypt)
   {
     Telemetry::Accumulate(Telemetry::WEBCRYPTO_ALG, TA_RSAES_PKCS1);
 
     ATTEMPT_BUFFER_INIT(mData, aData);
@@ -476,17 +476,17 @@ private:
     return NS_OK;
   }
 };
 
 class HmacTask : public WebCryptoTask
 {
 public:
   HmacTask(JSContext* aCx, const ObjectOrString& aAlgorithm,
-           mozilla::dom::Key& aKey,
+           mozilla::dom::CryptoKey& aKey,
            const CryptoOperationData& aSignature,
            const CryptoOperationData& aData,
            bool aSign)
     : mMechanism(aKey.Algorithm()->Mechanism())
     , mSymKey(aKey.GetSymKey())
     , mSign(aSign)
   {
     ATTEMPT_BUFFER_INIT(mData, aData);
@@ -579,17 +579,17 @@ private:
     }
   }
 };
 
 class RsassaPkcs1Task : public WebCryptoTask
 {
 public:
   RsassaPkcs1Task(JSContext* aCx, const ObjectOrString& aAlgorithm,
-                  mozilla::dom::Key& aKey,
+                  mozilla::dom::CryptoKey& aKey,
                   const CryptoOperationData& aSignature,
                   const CryptoOperationData& aData,
                   bool aSign)
     : mOidTag(SEC_OID_UNKNOWN)
     , mPrivKey(aKey.GetPrivateKey())
     , mPubKey(aKey.GetPublicKey())
     , mSign(aSign)
     , mVerified(false)
@@ -770,17 +770,17 @@ public:
     // Get the current global object from the context
     nsIGlobalObject *global = xpc::GetNativeForGlobal(JS::CurrentGlobalOrNull(aCx));
     if (!global) {
       mEarlyRv = NS_ERROR_DOM_UNKNOWN_ERR;
       return;
     }
 
     // This stuff pretty much always happens, so we'll do it here
-    mKey = new Key(global);
+    mKey = new CryptoKey(global);
     mKey->SetExtractable(aExtractable);
     mKey->ClearUsages();
     for (uint32_t i = 0; i < aKeyUsages.Length(); ++i) {
       mEarlyRv = mKey->AddUsage(aKeyUsages[i]);
       if (NS_FAILED(mEarlyRv)) {
         return;
       }
     }
@@ -788,17 +788,17 @@ public:
     mEarlyRv = GetAlgorithmName(aCx, aAlgorithm, mAlgName);
     if (NS_FAILED(mEarlyRv)) {
       mEarlyRv = NS_ERROR_DOM_DATA_ERR;
       return;
     }
   }
 
 protected:
-  nsRefPtr<Key> mKey;
+  nsRefPtr<CryptoKey> mKey;
   nsString mAlgName;
 
 private:
   virtual void Resolve() MOZ_OVERRIDE
   {
     mResultPromise->MaybeResolve(mKey);
   }
 
@@ -862,40 +862,40 @@ public:
     // Construct an appropriate KeyAlorithm,
     // and verify that usages are appropriate
     nsRefPtr<KeyAlgorithm> algorithm;
     nsIGlobalObject* global = mKey->GetParentObject();
     uint32_t length = 8 * mKeyData.Length(); // bytes to bits
     if (mAlgName.EqualsLiteral(WEBCRYPTO_ALG_AES_CBC) ||
         mAlgName.EqualsLiteral(WEBCRYPTO_ALG_AES_CTR) ||
         mAlgName.EqualsLiteral(WEBCRYPTO_ALG_AES_GCM)) {
-      if (mKey->HasUsageOtherThan(Key::ENCRYPT | Key::DECRYPT)) {
+      if (mKey->HasUsageOtherThan(CryptoKey::ENCRYPT | CryptoKey::DECRYPT)) {
         return NS_ERROR_DOM_DATA_ERR;
       }
 
       if ( (length != 128) && (length != 192) && (length != 256) ) {
         return NS_ERROR_DOM_DATA_ERR;
       }
       algorithm = new AesKeyAlgorithm(global, mAlgName, length);
     } else if (mAlgName.EqualsLiteral(WEBCRYPTO_ALG_HMAC)) {
-      if (mKey->HasUsageOtherThan(Key::SIGN | Key::VERIFY)) {
+      if (mKey->HasUsageOtherThan(CryptoKey::SIGN | CryptoKey::VERIFY)) {
         return NS_ERROR_DOM_DATA_ERR;
       }
 
       algorithm = new HmacKeyAlgorithm(global, mAlgName, length, mHashName);
       if (algorithm->Mechanism() == UNKNOWN_CK_MECHANISM) {
         return NS_ERROR_DOM_SYNTAX_ERR;
       }
     } else {
       return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
     }
 
     mKey->SetAlgorithm(algorithm);
     mKey->SetSymKey(mKeyData);
-    mKey->SetType(Key::SECRET);
+    mKey->SetType(CryptoKey::SECRET);
     mEarlyComplete = true;
     return NS_OK;
   }
 
 private:
   CryptoBuffer mKeyData;
   nsString mHashName;
 };
@@ -952,39 +952,39 @@ private:
 
   virtual nsresult DoCrypto() MOZ_OVERRIDE
   {
     nsNSSShutDownPreventionLock locker;
 
     // Import the key data itself
     ScopedSECKEYPublicKey pubKey;
     if (mFormat.EqualsLiteral(WEBCRYPTO_KEY_FORMAT_PKCS8)) {
-      ScopedSECKEYPrivateKey privKey(Key::PrivateKeyFromPkcs8(mKeyData, locker));
+      ScopedSECKEYPrivateKey privKey(CryptoKey::PrivateKeyFromPkcs8(mKeyData, locker));
       if (!privKey.get()) {
         return NS_ERROR_DOM_DATA_ERR;
       }
 
       mKey->SetPrivateKey(privKey.get());
-      mKey->SetType(Key::PRIVATE);
+      mKey->SetType(CryptoKey::PRIVATE);
       pubKey = SECKEY_ConvertToPublicKey(privKey.get());
       if (!pubKey) {
         return NS_ERROR_DOM_UNKNOWN_ERR;
       }
     } else if (mFormat.EqualsLiteral(WEBCRYPTO_KEY_FORMAT_SPKI)) {
-      pubKey = Key::PublicKeyFromSpki(mKeyData, locker);
+      pubKey = CryptoKey::PublicKeyFromSpki(mKeyData, locker);
       if (!pubKey.get()) {
         return NS_ERROR_DOM_DATA_ERR;
       }
 
       if (pubKey->keyType != rsaKey) {
         return NS_ERROR_DOM_DATA_ERR;
       }
 
       mKey->SetPublicKey(pubKey.get());
-      mKey->SetType(Key::PUBLIC);
+      mKey->SetType(CryptoKey::PUBLIC);
     } else if (mFormat.EqualsLiteral(WEBCRYPTO_KEY_FORMAT_JWK)) {
       return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
     } else {
       // Invalid key format
       return NS_ERROR_DOM_SYNTAX_ERR;
     }
 
     // Extract relevant information from the public key
@@ -994,29 +994,29 @@ private:
     return NS_OK;
   }
 
   virtual nsresult AfterCrypto() MOZ_OVERRIDE
   {
     // Construct an appropriate KeyAlgorithm
     nsIGlobalObject* global = mKey->GetParentObject();
     if (mAlgName.EqualsLiteral(WEBCRYPTO_ALG_RSAES_PKCS1)) {
-      if ((mKey->GetKeyType() == Key::PUBLIC &&
-           mKey->HasUsageOtherThan(Key::ENCRYPT)) ||
-          (mKey->GetKeyType() == Key::PRIVATE &&
-           mKey->HasUsageOtherThan(Key::DECRYPT))) {
+      if ((mKey->GetKeyType() == CryptoKey::PUBLIC &&
+           mKey->HasUsageOtherThan(CryptoKey::ENCRYPT)) ||
+          (mKey->GetKeyType() == CryptoKey::PRIVATE &&
+           mKey->HasUsageOtherThan(CryptoKey::DECRYPT))) {
         return NS_ERROR_DOM_DATA_ERR;
       }
 
       mKey->SetAlgorithm(new RsaKeyAlgorithm(global, mAlgName, mModulusLength, mPublicExponent));
     } else if (mAlgName.EqualsLiteral(WEBCRYPTO_ALG_RSASSA_PKCS1)) {
-      if ((mKey->GetKeyType() == Key::PUBLIC &&
-           mKey->HasUsageOtherThan(Key::VERIFY)) ||
-          (mKey->GetKeyType() == Key::PRIVATE &&
-           mKey->HasUsageOtherThan(Key::SIGN))) {
+      if ((mKey->GetKeyType() == CryptoKey::PUBLIC &&
+           mKey->HasUsageOtherThan(CryptoKey::VERIFY)) ||
+          (mKey->GetKeyType() == CryptoKey::PRIVATE &&
+           mKey->HasUsageOtherThan(CryptoKey::SIGN))) {
         return NS_ERROR_DOM_DATA_ERR;
       }
 
       nsRefPtr<RsaHashedKeyAlgorithm> algorithm = new RsaHashedKeyAlgorithm(
                                                           global,
                                                           mAlgName,
                                                           mModulusLength,
                                                           mPublicExponent,
@@ -1030,17 +1030,17 @@ private:
     return NS_OK;
   }
 };
 
 
 class UnifiedExportKeyTask : public ReturnArrayBufferViewTask
 {
 public:
-  UnifiedExportKeyTask(const nsAString& aFormat, Key& aKey)
+  UnifiedExportKeyTask(const nsAString& aFormat, CryptoKey& aKey)
     : mFormat(aFormat)
     , mSymKey(aKey.GetSymKey())
     , mPrivateKey(aKey.GetPrivateKey())
     , mPublicKey(aKey.GetPublicKey())
   {
     if (!aKey.Extractable()) {
       mEarlyRv = NS_ERROR_DOM_INVALID_ACCESS_ERR;
       return;
@@ -1073,27 +1073,27 @@ private:
       return NS_OK;
     } else if (mFormat.EqualsLiteral(WEBCRYPTO_KEY_FORMAT_PKCS8)) {
       if (!mPrivateKey) {
         return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
       }
 
       switch (mPrivateKey->keyType) {
         case rsaKey:
-          Key::PrivateKeyToPkcs8(mPrivateKey.get(), mResult, locker);
+          CryptoKey::PrivateKeyToPkcs8(mPrivateKey.get(), mResult, locker);
           return NS_OK;
         default:
           return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
       }
     } else if (mFormat.EqualsLiteral(WEBCRYPTO_KEY_FORMAT_SPKI)) {
       if (!mPublicKey) {
         return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
       }
 
-      return Key::PublicKeyToSpki(mPublicKey.get(), mResult, locker);
+      return CryptoKey::PublicKeyToSpki(mPublicKey.get(), mResult, locker);
     } else if (mFormat.EqualsLiteral(WEBCRYPTO_KEY_FORMAT_JWK)) {
       return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
     }
 
     return NS_ERROR_DOM_SYNTAX_ERR;
   }
 };
 
@@ -1106,19 +1106,19 @@ public:
   {
     nsIGlobalObject* global = xpc::GetNativeForGlobal(JS::CurrentGlobalOrNull(aCx));
     if (!global) {
       mEarlyRv = NS_ERROR_DOM_UNKNOWN_ERR;
       return;
     }
 
     // Create an empty key and set easy attributes
-    mKey = new Key(global);
+    mKey = new CryptoKey(global);
     mKey->SetExtractable(aExtractable);
-    mKey->SetType(Key::SECRET);
+    mKey->SetType(CryptoKey::SECRET);
 
     // Extract algorithm name
     nsString algName;
     mEarlyRv = GetAlgorithmName(aCx, aAlgorithm, algName);
     if (NS_FAILED(mEarlyRv)) {
       mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR;
       return;
     }
@@ -1137,17 +1137,17 @@ public:
       }
 
       mLength = params.mLength.Value();
       if (mLength != 128 && mLength != 192 && mLength != 256) {
         mEarlyRv = NS_ERROR_DOM_DATA_ERR;
         return;
       }
       algorithm = new AesKeyAlgorithm(global, algName, mLength);
-      allowedUsages = Key::ENCRYPT | Key::DECRYPT;
+      allowedUsages = CryptoKey::ENCRYPT | CryptoKey::DECRYPT;
     } else if (algName.EqualsLiteral(WEBCRYPTO_ALG_HMAC)) {
       RootedDictionary<HmacKeyGenParams> params(aCx);
       mEarlyRv = Coerce(aCx, params, aAlgorithm);
       if (NS_FAILED(mEarlyRv) || !params.mHash.WasPassed()) {
         mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR;
         return;
       }
 
@@ -1184,17 +1184,17 @@ public:
       }
 
       if (mLength == 0) {
         mEarlyRv = NS_ERROR_DOM_DATA_ERR;
         return;
       }
 
       algorithm = new HmacKeyAlgorithm(global, algName, mLength, hashName);
-      allowedUsages = Key::SIGN | Key::VERIFY;
+      allowedUsages = CryptoKey::SIGN | CryptoKey::VERIFY;
     } else {
       mEarlyRv = NS_ERROR_DOM_NOT_SUPPORTED_ERR;
       return;
     }
 
     // Add key usages
     mKey->ClearUsages();
     for (uint32_t i = 0; i < aKeyUsages.Length(); ++i) {
@@ -1206,17 +1206,17 @@ public:
 
     mLength = mLength >> 3; // bits to bytes
     mMechanism = algorithm->Mechanism();
     mKey->SetAlgorithm(algorithm);
     // SetSymKey done in Resolve, after we've done the keygen
   }
 
 private:
-  nsRefPtr<Key> mKey;
+  nsRefPtr<CryptoKey> mKey;
   size_t mLength;
   CK_MECHANISM_TYPE mMechanism;
   CryptoBuffer mKeyData;
 
   virtual nsresult DoCrypto() MOZ_OVERRIDE
   {
     ScopedPK11SlotInfo slot(PK11_GetInternalSlot());
     MOZ_ASSERT(slot.get());
@@ -1258,17 +1258,17 @@ public:
   {
     nsIGlobalObject* global = xpc::GetNativeForGlobal(JS::CurrentGlobalOrNull(aCx));
     if (!global) {
       mEarlyRv = NS_ERROR_DOM_UNKNOWN_ERR;
       return;
     }
 
     // Create an empty key and set easy attributes
-    mKeyPair = new KeyPair(global);
+    mKeyPair = new CryptoKeyPair(global);
 
     // Extract algorithm name
     nsString algName;
     mEarlyRv = GetAlgorithmName(aCx, aAlgorithm, algName);
     if (NS_FAILED(mEarlyRv)) {
       mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR;
       return;
     }
@@ -1307,18 +1307,18 @@ public:
       // Set up params struct
       mRsaParams.keySizeInBits = modulusLength;
       bool converted = publicExponent.GetBigIntValue(mRsaParams.pe);
       if (!converted) {
         mEarlyRv = NS_ERROR_DOM_INVALID_ACCESS_ERR;
         return;
       }
 
-      privateAllowedUsages = Key::SIGN;
-      publicAllowedUsages = Key::VERIFY;
+      privateAllowedUsages = CryptoKey::SIGN;
+      publicAllowedUsages = CryptoKey::VERIFY;
     } else if (algName.EqualsLiteral(WEBCRYPTO_ALG_RSAES_PKCS1)) {
       RootedDictionary<RsaKeyGenParams> params(aCx);
       mEarlyRv = Coerce(aCx, params, aAlgorithm);
       if (NS_FAILED(mEarlyRv) || !params.mModulusLength.WasPassed() ||
           !params.mPublicExponent.WasPassed()) {
         mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR;
         return;
       }
@@ -1338,28 +1338,28 @@ public:
       // Set up params struct
       mRsaParams.keySizeInBits = modulusLength;
       bool converted = publicExponent.GetBigIntValue(mRsaParams.pe);
       if (!converted) {
         mEarlyRv = NS_ERROR_DOM_INVALID_ACCESS_ERR;
         return;
       }
 
-      privateAllowedUsages = Key::DECRYPT | Key::UNWRAPKEY;
-      publicAllowedUsages = Key::ENCRYPT | Key::WRAPKEY;
+      privateAllowedUsages = CryptoKey::DECRYPT | CryptoKey::UNWRAPKEY;
+      publicAllowedUsages = CryptoKey::ENCRYPT | CryptoKey::WRAPKEY;
     } else {
       mEarlyRv = NS_ERROR_DOM_NOT_SUPPORTED_ERR;
       return;
     }
 
     mKeyPair->PrivateKey()->SetExtractable(aExtractable);
-    mKeyPair->PrivateKey()->SetType(Key::PRIVATE);
+    mKeyPair->PrivateKey()->SetType(CryptoKey::PRIVATE);
 
     mKeyPair->PublicKey()->SetExtractable(true);
-    mKeyPair->PublicKey()->SetType(Key::PUBLIC);
+    mKeyPair->PublicKey()->SetType(CryptoKey::PUBLIC);
 
     mKeyPair->PrivateKey()->ClearUsages();
     mKeyPair->PublicKey()->ClearUsages();
     for (uint32_t i=0; i < aKeyUsages.Length(); ++i) {
       mEarlyRv = mKeyPair->PrivateKey()->AddUsageIntersecting(aKeyUsages[i],
                                                               privateAllowedUsages);
       if (NS_FAILED(mEarlyRv)) {
         return;
@@ -1369,17 +1369,17 @@ public:
                                                              publicAllowedUsages);
       if (NS_FAILED(mEarlyRv)) {
         return;
       }
     }
   }
 
 private:
-  nsRefPtr<KeyPair> mKeyPair;
+  nsRefPtr<CryptoKeyPair> mKeyPair;
   CK_MECHANISM_TYPE mMechanism;
   PK11RSAGenParams mRsaParams;
   ScopedSECKEYPublicKey mPublicKey;
   ScopedSECKEYPrivateKey mPrivateKey;
 
   virtual void ReleaseNSSResources() MOZ_OVERRIDE
   {
     mPublicKey.dispose();
@@ -1422,33 +1422,33 @@ private:
 };
 
 
 // Task creation methods for WebCryptoTask
 
 WebCryptoTask*
 WebCryptoTask::EncryptDecryptTask(JSContext* aCx,
                                   const ObjectOrString& aAlgorithm,
-                                  Key& aKey,
+                                  CryptoKey& aKey,
                                   const CryptoOperationData& aData,
                                   bool aEncrypt)
 {
   TelemetryMethod method = (aEncrypt)? TM_ENCRYPT : TM_DECRYPT;
   Telemetry::Accumulate(Telemetry::WEBCRYPTO_METHOD, method);
   Telemetry::Accumulate(Telemetry::WEBCRYPTO_EXTRACTABLE_ENC, aKey.Extractable());
 
   nsString algName;
   nsresult rv = GetAlgorithmName(aCx, aAlgorithm, algName);
   if (NS_FAILED(rv)) {
     return new FailureTask(rv);
   }
 
   // Ensure key is usable for this operation
-  if ((aEncrypt  && !aKey.HasUsage(Key::ENCRYPT)) ||
-      (!aEncrypt && !aKey.HasUsage(Key::DECRYPT))) {
+  if ((aEncrypt  && !aKey.HasUsage(CryptoKey::ENCRYPT)) ||
+      (!aEncrypt && !aKey.HasUsage(CryptoKey::DECRYPT))) {
     return new FailureTask(NS_ERROR_DOM_INVALID_ACCESS_ERR);
   }
 
   if (algName.EqualsLiteral(WEBCRYPTO_ALG_AES_CBC) ||
       algName.EqualsLiteral(WEBCRYPTO_ALG_AES_CTR) ||
       algName.EqualsLiteral(WEBCRYPTO_ALG_AES_GCM)) {
     return new AesTask(aCx, aAlgorithm, aKey, aData, aEncrypt);
   } else if (algName.EqualsLiteral(WEBCRYPTO_ALG_RSAES_PKCS1)) {
@@ -1456,34 +1456,34 @@ WebCryptoTask::EncryptDecryptTask(JSCont
   }
 
   return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
 }
 
 WebCryptoTask*
 WebCryptoTask::SignVerifyTask(JSContext* aCx,
                               const ObjectOrString& aAlgorithm,
-                              Key& aKey,
+                              CryptoKey& aKey,
                               const CryptoOperationData& aSignature,
                               const CryptoOperationData& aData,
                               bool aSign)
 {
   TelemetryMethod method = (aSign)? TM_SIGN : TM_VERIFY;
   Telemetry::Accumulate(Telemetry::WEBCRYPTO_METHOD, method);
   Telemetry::Accumulate(Telemetry::WEBCRYPTO_EXTRACTABLE_SIG, aKey.Extractable());
 
   nsString algName;
   nsresult rv = GetAlgorithmName(aCx, aAlgorithm, algName);
   if (NS_FAILED(rv)) {
     return new FailureTask(rv);
   }
 
   // Ensure key is usable for this operation
-  if ((aSign  && !aKey.HasUsage(Key::SIGN)) ||
-      (!aSign && !aKey.HasUsage(Key::VERIFY))) {
+  if ((aSign  && !aKey.HasUsage(CryptoKey::SIGN)) ||
+      (!aSign && !aKey.HasUsage(CryptoKey::VERIFY))) {
     return new FailureTask(NS_ERROR_DOM_INVALID_ACCESS_ERR);
   }
 
   if (algName.EqualsLiteral(WEBCRYPTO_ALG_HMAC)) {
     return new HmacTask(aCx, aAlgorithm, aKey, aSignature, aData, aSign);
   } else if (algName.EqualsLiteral(WEBCRYPTO_ALG_RSASSA_PKCS1)) {
     return new RsassaPkcs1Task(aCx, aAlgorithm, aKey, aSignature, aData, aSign);
   }
@@ -1529,17 +1529,17 @@ WebCryptoTask::ImportKeyTask(JSContext* 
                                 aExtractable, aKeyUsages);
   } else {
     return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
   }
 }
 
 WebCryptoTask*
 WebCryptoTask::ExportKeyTask(const nsAString& aFormat,
-                             Key& aKey)
+                             CryptoKey& aKey)
 {
   Telemetry::Accumulate(Telemetry::WEBCRYPTO_METHOD, TM_EXPORTKEY);
 
   if (aFormat.EqualsLiteral(WEBCRYPTO_KEY_FORMAT_JWK)) {
     return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
   } else {
     return new UnifiedExportKeyTask(aFormat, aKey);
   }
@@ -1571,29 +1571,29 @@ WebCryptoTask::GenerateKeyTask(JSContext
   } else {
     return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
   }
 }
 
 WebCryptoTask*
 WebCryptoTask::DeriveKeyTask(JSContext* aCx,
                              const ObjectOrString& aAlgorithm,
-                             Key& aBaseKey,
+                             CryptoKey& aBaseKey,
                              const ObjectOrString& aDerivedKeyType,
                              bool aExtractable,
                              const Sequence<nsString>& aKeyUsages)
 {
   Telemetry::Accumulate(Telemetry::WEBCRYPTO_METHOD, TM_DERIVEKEY);
   return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
 }
 
 WebCryptoTask*
 WebCryptoTask::DeriveBitsTask(JSContext* aCx,
                               const ObjectOrString& aAlgorithm,
-                              Key& aKey,
+                              CryptoKey& aKey,
                               uint32_t aLength)
 {
   Telemetry::Accumulate(Telemetry::WEBCRYPTO_METHOD, TM_DERIVEBITS);
   return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
 }
 
 
 } // namespace dom
--- a/dom/crypto/WebCryptoTask.h
+++ b/dom/crypto/WebCryptoTask.h
@@ -8,17 +8,17 @@
 #define mozilla_dom_WebCryptoTask_h
 
 #include "CryptoTask.h"
 
 #include "nsIGlobalObject.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/SubtleCryptoBinding.h"
-#include "mozilla/dom/Key.h"
+#include "mozilla/dom/CryptoKey.h"
 
 namespace mozilla {
 namespace dom {
 
 typedef ArrayBufferViewOrArrayBuffer CryptoOperationData;
 typedef ArrayBufferViewOrArrayBuffer KeyData;
 
 /*
@@ -82,57 +82,57 @@ public:
 
      mEarlyRv = Dispatch("SubtleCrypto");
      MAYBE_EARLY_FAIL(mEarlyRv)
   }
 
 protected:
   static WebCryptoTask* EncryptDecryptTask(JSContext* aCx,
                            const ObjectOrString& aAlgorithm,
-                           Key& aKey,
+                           CryptoKey& aKey,
                            const CryptoOperationData& aData,
                            bool aEncrypt);
 
   static WebCryptoTask* SignVerifyTask(JSContext* aCx,
                           const ObjectOrString& aAlgorithm,
-                          Key& aKey,
+                          CryptoKey& aKey,
                           const CryptoOperationData& aSignature,
                           const CryptoOperationData& aData,
                           bool aSign);
 
 public:
   static WebCryptoTask* EncryptTask(JSContext* aCx,
                           const ObjectOrString& aAlgorithm,
-                          Key& aKey,
+                          CryptoKey& aKey,
                           const CryptoOperationData& aData)
   {
     return EncryptDecryptTask(aCx, aAlgorithm, aKey, aData, true);
   }
 
   static WebCryptoTask* DecryptTask(JSContext* aCx,
                           const ObjectOrString& aAlgorithm,
-                          Key& aKey,
+                          CryptoKey& aKey,
                           const CryptoOperationData& aData)
   {
     return EncryptDecryptTask(aCx, aAlgorithm, aKey, aData, false);
   }
 
   static WebCryptoTask* SignTask(JSContext* aCx,
                           const ObjectOrString& aAlgorithm,
-                          Key& aKey,
+                          CryptoKey& aKey,
                           const CryptoOperationData& aData)
   {
     CryptoOperationData dummy;
     dummy.SetAsArrayBuffer(aCx);
     return SignVerifyTask(aCx, aAlgorithm, aKey, dummy, aData, true);
   }
 
   static WebCryptoTask* VerifyTask(JSContext* aCx,
                           const ObjectOrString& aAlgorithm,
-                          Key& aKey,
+                          CryptoKey& aKey,
                           const CryptoOperationData& aSignature,
                           const CryptoOperationData& aData)
   {
     return SignVerifyTask(aCx, aAlgorithm, aKey, aSignature, aData, false);
   }
 
   static WebCryptoTask* DigestTask(JSContext* aCx,
                           const ObjectOrString& aAlgorithm,
@@ -140,31 +140,31 @@ public:
 
   static WebCryptoTask* ImportKeyTask(JSContext* aCx,
                           const nsAString& aFormat,
                           const KeyData& aKeyData,
                           const ObjectOrString& aAlgorithm,
                           bool aExtractable,
                           const Sequence<nsString>& aKeyUsages);
   static WebCryptoTask* ExportKeyTask(const nsAString& aFormat,
-                          Key& aKey);
+                          CryptoKey& aKey);
   static WebCryptoTask* GenerateKeyTask(JSContext* aCx,
                           const ObjectOrString& aAlgorithm,
                           bool aExtractable,
                           const Sequence<nsString>& aKeyUsages);
 
   static WebCryptoTask* DeriveKeyTask(JSContext* aCx,
                           const ObjectOrString& aAlgorithm,
-                          Key& aBaseKey,
+                          CryptoKey& aBaseKey,
                           const ObjectOrString& aDerivedKeyType,
                           bool extractable,
                           const Sequence<nsString>& aKeyUsages);
   static WebCryptoTask* DeriveBitsTask(JSContext* aCx,
                           const ObjectOrString& aAlgorithm,
-                          Key& aKey,
+                          CryptoKey& aKey,
                           uint32_t aLength);
 
 protected:
   nsRefPtr<Promise> mResultPromise;
   nsresult mEarlyRv;
   bool mEarlyComplete;
 
   WebCryptoTask()
--- a/dom/crypto/moz.build
+++ b/dom/crypto/moz.build
@@ -4,33 +4,33 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 TEST_DIRS += ['test']
 
 EXPORTS.mozilla.dom += [
     'AesKeyAlgorithm.h',
     'CryptoBuffer.h',
+    'CryptoKey.h',
+    'CryptoKeyPair.h',
     'HmacKeyAlgorithm.h',
-    'Key.h',
     'KeyAlgorithm.h',
-    'KeyPair.h',
     'RsaHashedKeyAlgorithm.h',
     'RsaKeyAlgorithm.h',
     'WebCryptoCommon.h',
     'WebCryptoTask.h',
 ]
 
 UNIFIED_SOURCES += [
     'AesKeyAlgorithm.cpp',
     'CryptoBuffer.cpp',
+    'CryptoKey.cpp',
+    'CryptoKeyPair.cpp',
     'HmacKeyAlgorithm.cpp',
-    'Key.cpp',
     'KeyAlgorithm.cpp',
-    'KeyPair.cpp',
     'RsaHashedKeyAlgorithm.cpp',
     'RsaKeyAlgorithm.cpp',
     'WebCryptoTask.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
--- a/dom/webidl/SubtleCrypto.webidl
+++ b/dom/webidl/SubtleCrypto.webidl
@@ -97,64 +97,64 @@ dictionary DhKeyGenParams : Algorithm {
 typedef DOMString NamedCurve;
 dictionary EcKeyGenParams : Algorithm {
   NamedCurve namedCurve;
 };
 
 /***** The Main API *****/
 
 [Pref="dom.webcrypto.enabled"]
-interface Key {
+interface CryptoKey {
   readonly attribute KeyType type;
   readonly attribute boolean extractable;
   readonly attribute KeyAlgorithm algorithm;
   [Cached, Constant, Frozen] readonly attribute sequence<KeyUsage> usages;
 };
 
 [Pref="dom.webcrypto.enabled"]
-interface KeyPair {
-  readonly attribute Key publicKey;
-  readonly attribute Key privateKey;
+interface CryptoKeyPair {
+  readonly attribute CryptoKey publicKey;
+  readonly attribute CryptoKey privateKey;
 };
 
 typedef DOMString KeyFormat;
 typedef (ArrayBufferView or ArrayBuffer) CryptoOperationData;
 typedef (ArrayBufferView or ArrayBuffer) KeyData;
 typedef (object or DOMString) AlgorithmIdentifier;
 
 [Pref="dom.webcrypto.enabled"]
 interface SubtleCrypto {
   Promise encrypt(AlgorithmIdentifier algorithm,
-                  Key key,
+                  CryptoKey key,
                   CryptoOperationData data);
   Promise decrypt(AlgorithmIdentifier algorithm,
-                  Key key,
+                  CryptoKey key,
                   CryptoOperationData data);
   Promise sign(AlgorithmIdentifier algorithm,
-               Key key,
+               CryptoKey key,
                CryptoOperationData data);
   Promise verify(AlgorithmIdentifier algorithm,
-                 Key key,
+                 CryptoKey key,
                  CryptoOperationData signature,
                  CryptoOperationData data);
   Promise digest(AlgorithmIdentifier algorithm,
                  CryptoOperationData data);
 
   Promise generateKey(AlgorithmIdentifier algorithm,
                       boolean extractable,
                       sequence<KeyUsage> keyUsages );
   Promise deriveKey(AlgorithmIdentifier algorithm,
-                    Key baseKey,
+                    CryptoKey baseKey,
                     AlgorithmIdentifier derivedKeyType,
                     boolean extractable,
                     sequence<KeyUsage> keyUsages );
   Promise deriveBits(AlgorithmIdentifier algorithm,
-                     Key baseKey,
+                     CryptoKey baseKey,
                      unsigned long length);
 
   Promise importKey(KeyFormat format,
                     KeyData keyData,
                     AlgorithmIdentifier algorithm,
                     boolean extractable,
                     sequence<KeyUsage> keyUsages );
-  Promise exportKey(KeyFormat format, Key key);
+  Promise exportKey(KeyFormat format, CryptoKey key);
 };