// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. "use strict";
// Checks that RSA certs with key sizes below 1024 bits are rejected. // Checks that ECC certs using curves other than the NIST P-256, P-384 or P-521 // curves are rejected.
do_get_profile(); // must be called before getting nsIX509CertDB const certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
Ci.nsIX509CertDB
);
let intFullName = intName + "-" + rootName;
let eeFullName = eeName + "-" + intName + "-" + rootName;
addCertFromFile(certdb, `test_keysize/${rootName}.pem`, "CTu,CTu,CTu");
addCertFromFile(certdb, `test_keysize/${intFullName}.pem`, ",,");
let eeCert = constructCertFromFile(`test_keysize/${eeFullName}.pem`);
if (makeRootBuiltIn) {
let root = constructCertFromFile(`test_keysize/${rootName}.pem`);
Services.prefs.setCharPref( "security.test.built_in_root_hash",
root.sha256Fingerprint
);
}
info("end-entity: " + eeCert.commonName);
info("issuer: " + eeCert.issuerCommonName);
let result = await checkCertErrorGeneric(
certdb,
eeCert,
eeExpectedError,
Ci.nsIX509CertDB.verifyUsageTLSServer
);
if (makeRootBuiltIn) {
Services.prefs.clearUserPref("security.test.built_in_root_hash");
}
return result;
}
/** *TestsvariousRSAchains. * *@param{number}inadequateKeySize *@param{number}adequateKeySize *@param{bool}makeRootBuiltIn
*/
async function checkRSAChains(
inadequateKeySize,
adequateKeySize,
makeRootBuiltIn
) { // Chain with certs that have adequate sizes for DV
await checkChain( "rsa",
adequateKeySize, "rsa",
adequateKeySize, "rsa",
adequateKeySize,
PRErrorCodeSuccess,
makeRootBuiltIn
);
// Chain with a root cert that has an inadequate size for DV
await checkChain( "rsa",
inadequateKeySize, "rsa",
adequateKeySize, "rsa",
adequateKeySize,
MOZILLA_PKIX_ERROR_INADEQUATE_KEY_SIZE,
makeRootBuiltIn
);
// Chain with an intermediate cert that has an inadequate size for DV
await checkChain( "rsa",
adequateKeySize, "rsa",
inadequateKeySize, "rsa",
adequateKeySize,
MOZILLA_PKIX_ERROR_INADEQUATE_KEY_SIZE,
makeRootBuiltIn
);
// Chain with an end entity cert that has an inadequate size for DV
await checkChain( "rsa",
adequateKeySize, "rsa",
adequateKeySize, "rsa",
inadequateKeySize,
MOZILLA_PKIX_ERROR_INADEQUATE_KEY_SIZE,
makeRootBuiltIn
);
}
add_task(async function () { // When the root is not a built-in, 1024 bits is accepted.
await checkRSAChains(1016, 1024, false); // When the root is a built-in, 2048 bits is the minimum. // Unfortunately, this can currently only be tested in debug builds. if (gIsDebugBuild) {
await checkRSAChains(1024, 2048, true);
}
await checkECCChains();
await checkCombinationChains();
});
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.27 Sekunden
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.