Replace NSS with Pale Moon's

This commit is contained in:
wuggy 2026-06-29 21:29:25 +01:00
commit 8c2e376f94
2870 changed files with 1762232 additions and 1374220 deletions

View file

@ -12,6 +12,8 @@ CPPSRCS = \
util_gtests.cc \
util_memcmpzero_unittest.cc \
util_pkcs11uri_unittest.cc \
util_secasn1d_unittest.cc \
util_select_unittest.cc \
util_utf8_unittest.cc \
$(NULL)

View file

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
@ -73,9 +74,9 @@ TEST_P(AlignedMallocTestBadSize, TestAlloc) {
static const size_t kSizes[] = {1, 2, 4, 8, 16, 32, 64};
static const size_t kBadSizes[] = {0, 7, 17, 24, 56};
INSTANTIATE_TEST_CASE_P(AllAligned, AlignedMallocTest,
::testing::ValuesIn(kSizes));
INSTANTIATE_TEST_CASE_P(AllAlignedBadSize, AlignedMallocTestBadSize,
::testing::ValuesIn(kBadSizes));
INSTANTIATE_TEST_SUITE_P(AllAligned, AlignedMallocTest,
::testing::ValuesIn(kSizes));
INSTANTIATE_TEST_SUITE_P(AllAlignedBadSize, AlignedMallocTestBadSize,
::testing::ValuesIn(kBadSizes));
} // namespace nss_test

View file

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */

View file

@ -16,6 +16,8 @@
'util_gtests.cc',
'util_memcmpzero_unittest.cc',
'util_pkcs11uri_unittest.cc',
'util_secasn1d_unittest.cc',
'util_select_unittest.cc',
'util_utf8_unittest.cc',
],
'dependencies': [

View file

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */

View file

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */

View file

@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
#include "secasn1.h"
#include "gtest/gtest.h"
namespace nss_test {
class SECASN1DTest : public ::testing::Test {};
struct InnerSequenceItem {
SECItem value;
};
struct OuterSequence {
InnerSequenceItem *item;
};
static const SEC_ASN1Template InnerSequenceTemplate[] = {
{SEC_ASN1_SEQUENCE, 0, NULL, sizeof(InnerSequenceItem)},
{SEC_ASN1_ANY, offsetof(InnerSequenceItem, value)},
{0}};
static const SEC_ASN1Template OuterSequenceTemplate[] = {
{SEC_ASN1_SEQUENCE_OF, offsetof(OuterSequence, item), InnerSequenceTemplate,
sizeof(OuterSequence)}};
TEST_F(SECASN1DTest, IndefiniteSequenceInIndefiniteGroup) {
PLArenaPool *arena = PORT_NewArena(4096);
OuterSequence *outer = nullptr;
SECStatus rv;
// echo "SEQUENCE indefinite {
// SEQUENCE indefinite {
// PrintableString { \"Test for Bug 1387919\" }
// }
// }" | ascii2der | xxd -i
unsigned char ber[] = {0x30, 0x80, 0x30, 0x80, 0x13, 0x14, 0x54, 0x65,
0x73, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x42,
0x75, 0x67, 0x20, 0x31, 0x33, 0x38, 0x37, 0x39,
0x31, 0x39, 0x00, 0x00, 0x00, 0x00};
// Decoding should fail if the trailing EOC is omitted (Bug 1387919)
SECItem missingEOC = {siBuffer, ber, sizeof(ber) - 2};
rv = SEC_ASN1DecodeItem(arena, &outer, OuterSequenceTemplate, &missingEOC);
EXPECT_EQ(SECFailure, rv);
// With the trailing EOC, this is well-formed BER.
SECItem goodEncoding = {siBuffer, ber, sizeof(ber)};
rv = SEC_ASN1DecodeItem(arena, &outer, OuterSequenceTemplate, &goodEncoding);
EXPECT_EQ(SECSuccess, rv);
// |outer| should now be a null terminated array of InnerSequenceItems
// The first item is PrintableString { \"Test for Bug 1387919\" }
EXPECT_EQ(outer[0].item->value.len, 22U);
EXPECT_EQ(0, memcmp(outer[0].item->value.data, ber + 4, 22));
// The second item is the null terminator
EXPECT_EQ(outer[1].item, nullptr);
PORT_FreeArena(arena, PR_FALSE);
}
} // namespace nss_test

View file

@ -0,0 +1,55 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
#include "gtest/gtest.h"
#include "scoped_ptrs_util.h"
namespace nss_test {
class SelectTest : public ::testing::Test {
protected:
void test_select(std::vector<uint8_t> &dest, const std::vector<uint8_t> &src0,
const std::vector<uint8_t> &src1, unsigned char b) {
EXPECT_EQ(src0.size(), src1.size());
EXPECT_GE(dest.size(), src0.size());
return NSS_SecureSelect(dest.data(), src0.data(), src1.data(), src0.size(),
b);
};
};
TEST_F(SelectTest, TestSelectZero) {
std::vector<uint8_t> dest(32, 255);
std::vector<uint8_t> src0(32, 0);
std::vector<uint8_t> src1(32, 1);
test_select(dest, src0, src1, 0);
EXPECT_EQ(dest, src0);
}
TEST_F(SelectTest, TestSelectOne) {
std::vector<uint8_t> dest(32, 255);
std::vector<uint8_t> src0(32, 0);
std::vector<uint8_t> src1(32, 1);
test_select(dest, src0, src1, 1);
EXPECT_EQ(dest, src1);
}
TEST_F(SelectTest, TestSelect170) {
std::vector<uint8_t> dest(32, 255);
std::vector<uint8_t> src0(32, 0);
std::vector<uint8_t> src1(32, 1);
test_select(dest, src0, src1, 170);
EXPECT_EQ(dest, src1);
}
TEST_F(SelectTest, TestSelect255) {
std::vector<uint8_t> dest(32, 255);
std::vector<uint8_t> src0(32, 0);
std::vector<uint8_t> src1(32, 1);
test_select(dest, src0, src1, 255);
EXPECT_EQ(dest, src1);
}
} // namespace nss_test

View file

@ -1,4 +1,5 @@
// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vim: set ts=2 et sw=2 tw=80:
// 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/.
@ -960,26 +961,26 @@ const Utf16BadCase kUtf16BadCases[] = {
// Parameterized test instantiations:
INSTANTIATE_TEST_CASE_P(Ucs4TestCases, Ucs4Test,
::testing::ValuesIn(kUcs4Cases));
INSTANTIATE_TEST_SUITE_P(Ucs4TestCases, Ucs4Test,
::testing::ValuesIn(kUcs4Cases));
INSTANTIATE_TEST_CASE_P(Iso88591TestCases, Ucs2Test,
::testing::ValuesIn(kIso88591Cases));
INSTANTIATE_TEST_SUITE_P(Iso88591TestCases, Ucs2Test,
::testing::ValuesIn(kIso88591Cases));
INSTANTIATE_TEST_CASE_P(Ucs2TestCases, Ucs2Test,
::testing::ValuesIn(kUcs2Cases));
INSTANTIATE_TEST_SUITE_P(Ucs2TestCases, Ucs2Test,
::testing::ValuesIn(kUcs2Cases));
INSTANTIATE_TEST_CASE_P(Utf16TestCases, Utf16Test,
::testing::ValuesIn(kUtf16Cases));
INSTANTIATE_TEST_SUITE_P(Utf16TestCases, Utf16Test,
::testing::ValuesIn(kUtf16Cases));
INSTANTIATE_TEST_CASE_P(BadUtf8TestCases, BadUtf8Test,
::testing::ValuesIn(kUtf8BadCases));
INSTANTIATE_TEST_SUITE_P(BadUtf8TestCases, BadUtf8Test,
::testing::ValuesIn(kUtf8BadCases));
INSTANTIATE_TEST_CASE_P(BadUtf16TestCases, BadUtf16Test,
::testing::ValuesIn(kUtf16BadCases));
INSTANTIATE_TEST_SUITE_P(BadUtf16TestCases, BadUtf16Test,
::testing::ValuesIn(kUtf16BadCases));
INSTANTIATE_TEST_CASE_P(Iso88591TestCases, Iso88591Test,
::testing::ValuesIn(kIso88591Cases));
INSTANTIATE_TEST_SUITE_P(Iso88591TestCases, Iso88591Test,
::testing::ValuesIn(kIso88591Cases));
;
} // namespace nss_test