mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 18:04:46 +00:00
Bug 1289330 - Check for success when calling ToKeyAlgorithm() r=bz
This commit is contained in:
parent
b18a29d071
commit
77edbd02e0
@ -204,8 +204,10 @@ CryptoKey::GetAlgorithm(JSContext* cx, JS::MutableHandle<JSObject*> aRetVal,
|
||||
break;
|
||||
case KeyAlgorithmProxy::RSA: {
|
||||
RootedDictionary<RsaHashedKeyAlgorithm> rsa(cx);
|
||||
mAlgorithm.mRsa.ToKeyAlgorithm(cx, rsa);
|
||||
converted = ToJSValue(cx, rsa, &val);
|
||||
converted = mAlgorithm.mRsa.ToKeyAlgorithm(cx, rsa);
|
||||
if (converted) {
|
||||
converted = ToJSValue(cx, rsa, &val);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KeyAlgorithmProxy::EC:
|
||||
@ -213,8 +215,10 @@ CryptoKey::GetAlgorithm(JSContext* cx, JS::MutableHandle<JSObject*> aRetVal,
|
||||
break;
|
||||
case KeyAlgorithmProxy::DH: {
|
||||
RootedDictionary<DhKeyAlgorithm> dh(cx);
|
||||
mAlgorithm.mDh.ToKeyAlgorithm(cx, dh);
|
||||
converted = ToJSValue(cx, dh, &val);
|
||||
converted = mAlgorithm.mDh.ToKeyAlgorithm(cx, dh);
|
||||
if (converted) {
|
||||
converted = ToJSValue(cx, dh, &val);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -25,14 +25,21 @@ struct RsaHashedKeyAlgorithmStorage {
|
||||
uint16_t mModulusLength;
|
||||
CryptoBuffer mPublicExponent;
|
||||
|
||||
void
|
||||
bool
|
||||
ToKeyAlgorithm(JSContext* aCx, RsaHashedKeyAlgorithm& aRsa) const
|
||||
{
|
||||
JS::Rooted<JSObject*> exponent(aCx, mPublicExponent.ToUint8Array(aCx));
|
||||
if (!exponent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aRsa.mName = mName;
|
||||
aRsa.mModulusLength = mModulusLength;
|
||||
aRsa.mHash.mName = mHash.mName;
|
||||
aRsa.mPublicExponent.Init(mPublicExponent.ToUint8Array(aCx));
|
||||
aRsa.mPublicExponent.Init(exponent);
|
||||
aRsa.mPublicExponent.ComputeLengthAndData();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@ -43,14 +50,26 @@ struct DhKeyAlgorithmStorage {
|
||||
CryptoBuffer mPrime;
|
||||
CryptoBuffer mGenerator;
|
||||
|
||||
void
|
||||
bool
|
||||
ToKeyAlgorithm(JSContext* aCx, DhKeyAlgorithm& aDh) const
|
||||
{
|
||||
JS::Rooted<JSObject*> prime(aCx, mPrime.ToUint8Array(aCx));
|
||||
if (!prime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> generator(aCx, mGenerator.ToUint8Array(aCx));
|
||||
if (!generator) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aDh.mName = mName;
|
||||
aDh.mPrime.Init(mPrime.ToUint8Array(aCx));
|
||||
aDh.mPrime.Init(prime);
|
||||
aDh.mPrime.ComputeLengthAndData();
|
||||
aDh.mGenerator.Init(mGenerator.ToUint8Array(aCx));
|
||||
aDh.mGenerator.Init(generator);
|
||||
aDh.mGenerator.ComputeLengthAndData();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user