зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1250930 - Use correct global when creating a key in GenerateAsymmetricKeyTask r=bz
This commit is contained in:
Родитель
1551754c99
Коммит
0d2f5760da
|
@ -2311,16 +2311,10 @@ private:
|
|||
};
|
||||
|
||||
GenerateAsymmetricKeyTask::GenerateAsymmetricKeyTask(
|
||||
JSContext* aCx, const ObjectOrString& aAlgorithm, bool aExtractable,
|
||||
const Sequence<nsString>& aKeyUsages)
|
||||
nsIGlobalObject* aGlobal, JSContext* aCx, const ObjectOrString& aAlgorithm,
|
||||
bool aExtractable, const Sequence<nsString>& aKeyUsages)
|
||||
: mKeyPair(new CryptoKeyPair())
|
||||
{
|
||||
nsIGlobalObject* global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
if (!global) {
|
||||
mEarlyRv = NS_ERROR_DOM_UNKNOWN_ERR;
|
||||
return;
|
||||
}
|
||||
|
||||
mArena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
|
||||
if (!mArena) {
|
||||
mEarlyRv = NS_ERROR_DOM_UNKNOWN_ERR;
|
||||
|
@ -2328,8 +2322,8 @@ GenerateAsymmetricKeyTask::GenerateAsymmetricKeyTask(
|
|||
}
|
||||
|
||||
// Create an empty key pair and set easy attributes
|
||||
mKeyPair->mPrivateKey = new CryptoKey(global);
|
||||
mKeyPair->mPublicKey = new CryptoKey(global);
|
||||
mKeyPair->mPrivateKey = new CryptoKey(aGlobal);
|
||||
mKeyPair->mPublicKey = new CryptoKey(aGlobal);
|
||||
|
||||
// Extract algorithm name
|
||||
mEarlyRv = GetAlgorithmName(aCx, aAlgorithm, mAlgName);
|
||||
|
@ -3415,7 +3409,8 @@ WebCryptoTask::CreateGenerateKeyTask(nsIGlobalObject* aGlobal,
|
|||
algName.EqualsASCII(WEBCRYPTO_ALG_ECDH) ||
|
||||
algName.EqualsASCII(WEBCRYPTO_ALG_ECDSA) ||
|
||||
algName.EqualsASCII(WEBCRYPTO_ALG_DH)) {
|
||||
return new GenerateAsymmetricKeyTask(aCx, aAlgorithm, aExtractable, aKeyUsages);
|
||||
return new GenerateAsymmetricKeyTask(aGlobal, aCx, aAlgorithm, aExtractable,
|
||||
aKeyUsages);
|
||||
} else {
|
||||
return new FailureTask(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ private:
|
|||
class GenerateAsymmetricKeyTask : public WebCryptoTask
|
||||
{
|
||||
public:
|
||||
GenerateAsymmetricKeyTask(JSContext* aCx,
|
||||
GenerateAsymmetricKeyTask(nsIGlobalObject* aGlobal, JSContext* aCx,
|
||||
const ObjectOrString& aAlgorithm, bool aExtractable,
|
||||
const Sequence<nsString>& aKeyUsages);
|
||||
protected:
|
||||
|
|
|
@ -44,9 +44,10 @@ const size_t RTCCertificateMinRsaSize = 1024;
|
|||
class GenerateRTCCertificateTask : public GenerateAsymmetricKeyTask
|
||||
{
|
||||
public:
|
||||
GenerateRTCCertificateTask(JSContext* aCx, const ObjectOrString& aAlgorithm,
|
||||
const Sequence<nsString>& aKeyUsages)
|
||||
: GenerateAsymmetricKeyTask(aCx, aAlgorithm, true, aKeyUsages),
|
||||
GenerateRTCCertificateTask(nsIGlobalObject* aGlobal, JSContext* aCx,
|
||||
const ObjectOrString& aAlgorithm,
|
||||
const Sequence<nsString>& aKeyUsages)
|
||||
: GenerateAsymmetricKeyTask(aGlobal, aCx, aAlgorithm, true, aKeyUsages),
|
||||
mExpires(0),
|
||||
mAuthType(ssl_kea_null),
|
||||
mCertificate(nullptr),
|
||||
|
@ -263,7 +264,7 @@ RTCCertificate::GenerateCertificate(
|
|||
return nullptr;
|
||||
}
|
||||
RefPtr<WebCryptoTask> task =
|
||||
new GenerateRTCCertificateTask(aGlobal.Context(),
|
||||
new GenerateRTCCertificateTask(global, aGlobal.Context(),
|
||||
aKeygenAlgorithm, usages);
|
||||
task->DispatchWithPromise(p);
|
||||
return p.forget();
|
||||
|
|
Загрузка…
Ссылка в новой задаче