mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
[DOM] WebCrypto: Check decoded key type before using it.
Just in case someone forces the wrong key type and misuses WebCrypto. It won't be usable anyway so better to throw.
This commit is contained in:
parent
db89c5a05d
commit
0b9698c80a
1 changed files with 8 additions and 0 deletions
|
|
@ -1741,6 +1741,10 @@ private:
|
|||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
}
|
||||
|
||||
if (pubKey->keyType != rsaKey) {
|
||||
return NS_ERROR_DOM_DATA_ERR;
|
||||
}
|
||||
|
||||
// Extract relevant information from the public key
|
||||
mModulusLength = 8 * pubKey->u.rsa.modulus.len;
|
||||
if (!mPublicExponent.Assign(&pubKey->u.rsa.publicExponent)) {
|
||||
|
|
@ -1874,6 +1878,10 @@ private:
|
|||
}
|
||||
|
||||
if (mFormat.EqualsLiteral(WEBCRYPTO_KEY_FORMAT_SPKI)) {
|
||||
if (pubKey->keyType != ecKey) {
|
||||
return NS_ERROR_DOM_DATA_ERR;
|
||||
}
|
||||
|
||||
if (!CheckEncodedECParameters(&pubKey->u.ec.DEREncodedParams)) {
|
||||
return NS_ERROR_DOM_OPERATION_ERR;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue