Bug 1250930 - Use correct global when creating a key in GenerateSymmetricKeyTask r=bz

This commit is contained in:
Tim Taubert 2016-03-08 11:15:29 +01:00
parent 6eec770808
commit 1551754c99
3 changed files with 10 additions and 12 deletions

View File

@ -121,7 +121,8 @@ SubtleCrypto::GenerateKey(JSContext* cx, const ObjectOrString& algorithm,
bool extractable, const Sequence<nsString>& keyUsages,
ErrorResult& aRv)
{
SUBTLECRYPTO_METHOD_BODY(GenerateKey, aRv, cx, algorithm, extractable, keyUsages)
SUBTLECRYPTO_METHOD_BODY(GenerateKey, aRv, mParent, cx, algorithm,
extractable, keyUsages)
}
already_AddRefed<Promise>

View File

@ -2188,18 +2188,12 @@ private:
class GenerateSymmetricKeyTask : public WebCryptoTask
{
public:
GenerateSymmetricKeyTask(JSContext* aCx,
GenerateSymmetricKeyTask(nsIGlobalObject* aGlobal, JSContext* aCx,
const ObjectOrString& aAlgorithm, bool aExtractable,
const Sequence<nsString>& aKeyUsages)
{
nsIGlobalObject* global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
if (!global) {
mEarlyRv = NS_ERROR_DOM_UNKNOWN_ERR;
return;
}
// Create an empty key and set easy attributes
mKey = new CryptoKey(global);
mKey = new CryptoKey(aGlobal);
mKey->SetExtractable(aExtractable);
mKey->SetType(CryptoKey::SECRET);
@ -3386,7 +3380,8 @@ WebCryptoTask::CreateExportKeyTask(const nsAString& aFormat,
}
WebCryptoTask*
WebCryptoTask::CreateGenerateKeyTask(JSContext* aCx,
WebCryptoTask::CreateGenerateKeyTask(nsIGlobalObject* aGlobal,
JSContext* aCx,
const ObjectOrString& aAlgorithm,
bool aExtractable,
const Sequence<nsString>& aKeyUsages)
@ -3412,7 +3407,8 @@ WebCryptoTask::CreateGenerateKeyTask(JSContext* aCx,
algName.EqualsASCII(WEBCRYPTO_ALG_AES_GCM) ||
algName.EqualsASCII(WEBCRYPTO_ALG_AES_KW) ||
algName.EqualsASCII(WEBCRYPTO_ALG_HMAC)) {
return new GenerateSymmetricKeyTask(aCx, aAlgorithm, aExtractable, aKeyUsages);
return new GenerateSymmetricKeyTask(aGlobal, aCx, aAlgorithm, aExtractable,
aKeyUsages);
} else if (algName.EqualsASCII(WEBCRYPTO_ALG_RSASSA_PKCS1) ||
algName.EqualsASCII(WEBCRYPTO_ALG_RSA_OAEP) ||
algName.EqualsASCII(WEBCRYPTO_ALG_RSA_PSS) ||

View File

@ -131,7 +131,8 @@ public:
const Sequence<nsString>& aKeyUsages);
static WebCryptoTask* CreateExportKeyTask(const nsAString& aFormat,
CryptoKey& aKey);
static WebCryptoTask* CreateGenerateKeyTask(JSContext* aCx,
static WebCryptoTask* CreateGenerateKeyTask(nsIGlobalObject* aGlobal,
JSContext* aCx,
const ObjectOrString& aAlgorithm,
bool aExtractable,
const Sequence<nsString>& aKeyUsages);