mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1171820 - Convert test_bug483440.html mochitest to an xpcshell test. r=keeler
This commit is contained in:
parent
1bf808e34f
commit
b81b757b1e
@ -4,5 +4,3 @@ skip-if = buildapp == 'b2g' || e10s
|
||||
|
||||
[test_bug480509.html]
|
||||
skip-if = toolkit == 'android'
|
||||
[test_bug483440.html]
|
||||
skip-if = toolkit == 'android'
|
||||
|
@ -1,62 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Test bug 483437 and bug 480509</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var certdb = SpecialPowers.Cc["@mozilla.org/security/x509certdb;1"]
|
||||
.getService(SpecialPowers.Ci.nsIX509CertDB);
|
||||
|
||||
function test(certNick, expected)
|
||||
{
|
||||
var cert1 = certdb.findCertByNickname(null, certNick);
|
||||
var certDumpTree1 = SpecialPowers.Cc["@mozilla.org/security/nsASN1Tree;1"]
|
||||
.createInstance(SpecialPowers.Ci.nsIASN1Tree);
|
||||
certDumpTree1.loadASN1Structure(cert1.ASN1Structure);
|
||||
var value1 = certDumpTree1.getDisplayData(9);
|
||||
|
||||
is(value1, expected, "Incorrect OID recognized");
|
||||
}
|
||||
|
||||
test("bug483440-attack2b",
|
||||
"Object Identifier (2 5 4 Unknown) = www.bank.com\n"+
|
||||
"OU = Hacking Division\n"+
|
||||
"CN = www.badguy.com\nO = Badguy Inc\n");
|
||||
|
||||
test("bug483440-pk10oflo",
|
||||
"Object Identifier (2 5 4 Unknown) = www.bank.com\n"+
|
||||
"OU = Hacking Division\n"+
|
||||
"CN = www.badguy.com\nO = Badguy Inc\n");
|
||||
|
||||
test("bug483440-attack7",
|
||||
|
||||
// Check 88 80 80 80 01, not leading, have to pass
|
||||
"Object Identifier (2 5 4 2147483649) = attack1\n"+
|
||||
|
||||
// Check 90 80 80 80 01, not leading, have to fail
|
||||
"Object Identifier (2 5 4 Unknown) = attack2\n"+
|
||||
|
||||
// Check 80 80 80 80 80, not leading, have to fail
|
||||
"Object Identifier (2 5 4 Unknown) = attack3\n"+
|
||||
|
||||
// Check 81 81, trailing, have to fail
|
||||
"Object Identifier (2 5 4 3 Unknown) = attack4\n"+
|
||||
|
||||
// Check FF FF FF 7F, not leading, have to pass
|
||||
"Object Identifier (2 5 4 268435455) = attack5\n"+
|
||||
|
||||
// Check 80 leading, have to fail
|
||||
"Object Identifier (Unknown 3) = attack6\n"+
|
||||
|
||||
// Check 14757 = 2*40 + 14677 leading single byle encoded as F325,
|
||||
// have to pass
|
||||
"Object Identifier (2 14677 4 3) = attack7\n");
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,62 @@
|
||||
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
|
||||
// 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 invalid OID encodings are detected in the Cert Viewer Details tab.
|
||||
|
||||
do_get_profile(); // Must be called before getting nsIX509CertDB
|
||||
const certDB = Cc["@mozilla.org/security/x509certdb;1"]
|
||||
.getService(Ci.nsIX509CertDB);
|
||||
|
||||
function certFromFile(filename) {
|
||||
return constructCertFromFile(`test_certviewer_invalid_oids/${filename}.pem`);
|
||||
}
|
||||
|
||||
function test(certFilename, expectedOIDText) {
|
||||
let cert = certFromFile(certFilename);
|
||||
let certDumpTree = Cc["@mozilla.org/security/nsASN1Tree;1"]
|
||||
.createInstance(Ci.nsIASN1Tree);
|
||||
certDumpTree.loadASN1Structure(cert.ASN1Structure);
|
||||
let actualOIDText = certDumpTree.getDisplayData(9);
|
||||
|
||||
equal(actualOIDText, expectedOIDText,
|
||||
"Actual and expected OID text should match");
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
test("bug483440-attack2b",
|
||||
"Object Identifier (2 5 4 Unknown) = www.bank.com\n" +
|
||||
"OU = Hacking Division\n" +
|
||||
"CN = www.badguy.com\nO = Badguy Inc\n");
|
||||
|
||||
test("bug483440-pk10oflo",
|
||||
"Object Identifier (2 5 4 Unknown) = www.bank.com\n" +
|
||||
"OU = Hacking Division\n" +
|
||||
"CN = www.badguy.com\nO = Badguy Inc\n");
|
||||
|
||||
test("bug483440-attack7",
|
||||
|
||||
// Check 88 80 80 80 01, not leading, have to pass
|
||||
"Object Identifier (2 5 4 2147483649) = attack1\n" +
|
||||
|
||||
// Check 90 80 80 80 01, not leading, have to fail
|
||||
"Object Identifier (2 5 4 Unknown) = attack2\n" +
|
||||
|
||||
// Check 80 80 80 80 80, not leading, have to fail
|
||||
"Object Identifier (2 5 4 Unknown) = attack3\n" +
|
||||
|
||||
// Check 81 81, trailing, have to fail
|
||||
"Object Identifier (2 5 4 3 Unknown) = attack4\n" +
|
||||
|
||||
// Check FF FF FF 7F, not leading, have to pass
|
||||
"Object Identifier (2 5 4 268435455) = attack5\n" +
|
||||
|
||||
// Check 80 leading, have to fail
|
||||
"Object Identifier (Unknown 3) = attack6\n" +
|
||||
|
||||
// Check 14757 = 2*40 + 14677 leading single byte encoded as F325,
|
||||
// have to pass
|
||||
"Object Identifier (2 14677 4 3) = attack7\n");
|
||||
}
|
@ -7,6 +7,7 @@ support-files =
|
||||
test_signed_apps/**
|
||||
tlsserver/**
|
||||
test_cert_signatures/**
|
||||
test_certviewer_invalid_oids/**
|
||||
test_client_cert/**
|
||||
test_ev_certs/**
|
||||
test_getchain/**
|
||||
@ -129,3 +130,5 @@ run-sequentially = hardcoded ports
|
||||
run-sequentially = hardcoded ports
|
||||
[test_nsIX509Cert_utf8.js]
|
||||
[test_constructX509FromBase64.js]
|
||||
[test_certviewer_invalid_oids.js]
|
||||
skip-if = toolkit == 'android' || buildapp == 'b2g'
|
||||
|
Loading…
Reference in New Issue
Block a user