mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1050785 - RSA-OAEP encrypt/decrypt should accept strings as AlgorithmIdentifiers r=rbarnes
This commit is contained in:
parent
12e0c48603
commit
e7329e4114
@ -863,15 +863,19 @@ public:
|
||||
mStrength = PK11_GetPrivateModulusLen(mPrivKey);
|
||||
}
|
||||
|
||||
RootedDictionary<RsaOaepParams> params(aCx);
|
||||
mEarlyRv = Coerce(aCx, params, aAlgorithm);
|
||||
if (NS_FAILED(mEarlyRv)) {
|
||||
mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR;
|
||||
return;
|
||||
}
|
||||
// The algorithm could just be given as a string
|
||||
// in which case there would be no label specified.
|
||||
if (!aAlgorithm.IsString()) {
|
||||
RootedDictionary<RsaOaepParams> params(aCx);
|
||||
mEarlyRv = Coerce(aCx, params, aAlgorithm);
|
||||
if (NS_FAILED(mEarlyRv)) {
|
||||
mEarlyRv = NS_ERROR_DOM_SYNTAX_ERR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.mLabel.WasPassed() && !params.mLabel.Value().IsNull()) {
|
||||
ATTEMPT_BUFFER_INIT(mLabel, params.mLabel.Value().Value());
|
||||
if (params.mLabel.WasPassed() && !params.mLabel.Value().IsNull()) {
|
||||
ATTEMPT_BUFFER_INIT(mLabel, params.mLabel.Value().Value());
|
||||
}
|
||||
}
|
||||
// Otherwise mLabel remains the empty octet string, as intended
|
||||
|
||||
|
@ -1323,6 +1323,35 @@ TestArray.addTest(
|
||||
}
|
||||
);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
TestArray.addTest(
|
||||
"Test that RSA-OAEP encrypt/decrypt accepts strings as AlgorithmIdentifiers",
|
||||
function () {
|
||||
var that = this;
|
||||
var alg = {
|
||||
name: "RSA-OAEP",
|
||||
hash: "SHA-256",
|
||||
modulusLength: 2048,
|
||||
publicExponent: new Uint8Array([0x01, 0x00, 0x01])
|
||||
};
|
||||
|
||||
var privKey, pubKey, data = crypto.getRandomValues(new Uint8Array(128));
|
||||
function setKey(x) { pubKey = x.publicKey; privKey = x.privateKey; }
|
||||
function doEncrypt() {
|
||||
return crypto.subtle.encrypt("RSA-OAEP", pubKey, data);
|
||||
}
|
||||
function doDecrypt(x) {
|
||||
return crypto.subtle.decrypt("RSA-OAEP", privKey, x);
|
||||
}
|
||||
|
||||
crypto.subtle.generateKey(alg, false, ["encrypt", "decrypt"])
|
||||
.then(setKey)
|
||||
.then(doEncrypt)
|
||||
.then(doDecrypt)
|
||||
.then(memcmp_complete(that, data), error(that));
|
||||
}
|
||||
);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
TestArray.addTest(
|
||||
"Key wrap known answer, using AES-GCM",
|
||||
|
Loading…
Reference in New Issue
Block a user