From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- security/nss/gtests/certhigh_gtest/Makefile | 43 ++++++++++++++++ .../nss/gtests/certhigh_gtest/certhigh_gtest.gyp | 29 +++++++++++ .../nss/gtests/certhigh_gtest/certhigh_unittest.cc | 59 ++++++++++++++++++++++ security/nss/gtests/certhigh_gtest/manifest.mn | 22 ++++++++ 4 files changed, 153 insertions(+) create mode 100644 security/nss/gtests/certhigh_gtest/Makefile create mode 100644 security/nss/gtests/certhigh_gtest/certhigh_gtest.gyp create mode 100644 security/nss/gtests/certhigh_gtest/certhigh_unittest.cc create mode 100644 security/nss/gtests/certhigh_gtest/manifest.mn (limited to 'security/nss/gtests/certhigh_gtest') diff --git a/security/nss/gtests/certhigh_gtest/Makefile b/security/nss/gtests/certhigh_gtest/Makefile new file mode 100644 index 0000000000..0d547e0803 --- /dev/null +++ b/security/nss/gtests/certhigh_gtest/Makefile @@ -0,0 +1,43 @@ +#! gmake +# +# 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/. + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include ../common/gtest.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### diff --git a/security/nss/gtests/certhigh_gtest/certhigh_gtest.gyp b/security/nss/gtests/certhigh_gtest/certhigh_gtest.gyp new file mode 100644 index 0000000000..29bd0e00da --- /dev/null +++ b/security/nss/gtests/certhigh_gtest/certhigh_gtest.gyp @@ -0,0 +1,29 @@ +# 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/. +{ + 'includes': [ + '../../coreconf/config.gypi', + '../common/gtest.gypi', + ], + 'targets': [ + { + 'target_name': 'certhigh_gtest', + 'type': 'executable', + 'sources': [ + 'certhigh_unittest.cc', + '<(DEPTH)/gtests/common/gtests.cc' + ], + 'dependencies': [ + '<(DEPTH)/exports.gyp:nss_exports', + '<(DEPTH)/gtests/google_test/google_test.gyp:gtest', + '<(DEPTH)/lib/util/util.gyp:nssutil3', + '<(DEPTH)/lib/ssl/ssl.gyp:ssl3', + '<(DEPTH)/lib/nss/nss.gyp:nss3', + ] + } + ], + 'variables': { + 'module': 'nss' + } +} diff --git a/security/nss/gtests/certhigh_gtest/certhigh_unittest.cc b/security/nss/gtests/certhigh_gtest/certhigh_unittest.cc new file mode 100644 index 0000000000..734ac1200b --- /dev/null +++ b/security/nss/gtests/certhigh_gtest/certhigh_unittest.cc @@ -0,0 +1,59 @@ +/* -*- 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 + +#include "gtest/gtest.h" + +#include "cert.h" +#include "certt.h" +#include "secitem.h" + +namespace nss_test { + +class CERT_FormatNameUnitTest : public ::testing::Test {}; + +TEST_F(CERT_FormatNameUnitTest, Overflow) { + // Construct a CERTName consisting of a single RDN with 20 organizational unit + // AVAs and 20 domain component AVAs. The actual contents don't matter, just + // the types. + + uint8_t oidValueBytes[] = {0x0c, 0x02, 0x58, 0x58}; // utf8String "XX" + SECItem oidValue = {siBuffer, oidValueBytes, sizeof(oidValueBytes)}; + uint8_t oidTypeOUBytes[] = {0x55, 0x04, 0x0b}; // organizationalUnit + SECItem oidTypeOU = {siBuffer, oidTypeOUBytes, sizeof(oidTypeOUBytes)}; + CERTAVA ouAVA = {oidTypeOU, oidValue}; + uint8_t oidTypeDCBytes[] = {0x09, 0x92, 0x26, 0x89, 0x93, + 0xf2, 0x2c, 0x64, 0x1, 0x19}; // domainComponent + SECItem oidTypeDC = {siBuffer, oidTypeDCBytes, sizeof(oidTypeDCBytes)}; + CERTAVA dcAVA = {oidTypeDC, oidValue}; + + const int kNumEachAVA = 20; + CERTAVA* avas[(2 * kNumEachAVA) + 1]; + for (int i = 0; i < kNumEachAVA; i++) { + avas[2 * i] = &ouAVA; + avas[(2 * i) + 1] = &dcAVA; + } + avas[2 * kNumEachAVA] = nullptr; + + CERTRDN rdn = {avas}; + CERTRDN* rdns[2]; + rdns[0] = &rdn; + rdns[1] = nullptr; + + std::string expectedResult = + "XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
" + "XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
" + "XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
XX
" + "XX
XX
XX
XX
"; + + CERTName name = {nullptr, rdns}; + char* result = CERT_FormatName(&name); + EXPECT_EQ(expectedResult, result); + PORT_Free(result); +} + +} // namespace nss_test diff --git a/security/nss/gtests/certhigh_gtest/manifest.mn b/security/nss/gtests/certhigh_gtest/manifest.mn new file mode 100644 index 0000000000..998f7a363c --- /dev/null +++ b/security/nss/gtests/certhigh_gtest/manifest.mn @@ -0,0 +1,22 @@ +# +# 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/. +CORE_DEPTH = ../.. +DEPTH = ../.. +MODULE = nss + +CPPSRCS = \ + certhigh_unittest.cc \ + $(NULL) + +INCLUDES += -I$(CORE_DEPTH)/gtests/google_test/gtest/include \ + -I$(CORE_DEPTH)/gtests/common \ + -I$(CORE_DEPTH)/cpputil + +REQUIRES = nspr gtest + +PROGRAM = certhigh_gtest + +EXTRA_LIBS = $(DIST)/lib/$(LIB_PREFIX)gtest.$(LIB_SUFFIX) $(EXTRA_OBJS) \ + $(DIST)/lib/$(LIB_PREFIX)gtestutil.$(LIB_SUFFIX) -- cgit v1.2.3