mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 07:17:32 +09:00
Update NSS to 3.32.1-RTM
This commit is contained in:
parent
f29876f120
commit
c91ef9012b
512 changed files with 83203 additions and 16839 deletions
|
|
@ -7,13 +7,15 @@ DEPTH = ../..
|
|||
MODULE = nss
|
||||
|
||||
CPPSRCS = \
|
||||
util_b64_unittest.cc \
|
||||
util_utf8_unittest.cc \
|
||||
util_b64_unittest.cc \
|
||||
util_pkcs11uri_unittest.cc \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES += \
|
||||
-I$(CORE_DEPTH)/gtests/google_test/gtest/include \
|
||||
-I$(CORE_DEPTH)/gtests/common \
|
||||
-I$(CORE_DEPTH)/cpputil \
|
||||
$(NULL)
|
||||
|
||||
REQUIRES = nspr gtest
|
||||
|
|
@ -23,5 +25,5 @@ PROGRAM = util_gtest
|
|||
EXTRA_LIBS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)gtest.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)nssutil.$(LIB_SUFFIX) \
|
||||
../common/$(OBJDIR)/gtests$(OBJ_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)gtestutil.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "nssb64.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "scoped_ptrs.h"
|
||||
#include "scoped_ptrs_util.h"
|
||||
|
||||
namespace nss_test {
|
||||
|
||||
|
|
@ -68,11 +68,13 @@ TEST_F(B64EncodeDecodeTest, FakeEncDecTest) {
|
|||
}
|
||||
|
||||
// These takes a while ...
|
||||
TEST_F(B64EncodeDecodeTest, LongFakeDecTest1) {
|
||||
TEST_F(B64EncodeDecodeTest, DISABLED_LongFakeDecTest1) {
|
||||
EXPECT_TRUE(TestFakeDecode(0x66666666));
|
||||
}
|
||||
TEST_F(B64EncodeDecodeTest, LongFakeEncDecTest1) { TestFakeEncode(0x3fffffff); }
|
||||
TEST_F(B64EncodeDecodeTest, LongFakeEncDecTest2) {
|
||||
TEST_F(B64EncodeDecodeTest, DISABLED_LongFakeEncDecTest1) {
|
||||
TestFakeEncode(0x3fffffff);
|
||||
}
|
||||
TEST_F(B64EncodeDecodeTest, DISABLED_LongFakeEncDecTest2) {
|
||||
EXPECT_FALSE(TestFakeEncode(0x40000000));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,21 +11,40 @@
|
|||
'target_name': 'util_gtest',
|
||||
'type': 'executable',
|
||||
'sources': [
|
||||
'util_b64_unittest.cc',
|
||||
'util_utf8_unittest.cc',
|
||||
'<(DEPTH)/gtests/common/gtests.cc'
|
||||
'util_b64_unittest.cc',
|
||||
'util_pkcs11uri_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:nssutil',
|
||||
]
|
||||
'<(DEPTH)/lib/nss/nss.gyp:nss_static',
|
||||
'<(DEPTH)/lib/pk11wrap/pk11wrap.gyp:pk11wrap_static',
|
||||
'<(DEPTH)/lib/cryptohi/cryptohi.gyp:cryptohi',
|
||||
'<(DEPTH)/lib/certhigh/certhigh.gyp:certhi',
|
||||
'<(DEPTH)/lib/certdb/certdb.gyp:certdb',
|
||||
'<(DEPTH)/lib/base/base.gyp:nssb',
|
||||
'<(DEPTH)/lib/dev/dev.gyp:nssdev',
|
||||
'<(DEPTH)/lib/pki/pki.gyp:nsspki',
|
||||
'<(DEPTH)/lib/ssl/ssl.gyp:ssl',
|
||||
'<(DEPTH)/lib/libpkix/libpkix.gyp:libpkix',
|
||||
],
|
||||
'conditions': [
|
||||
[ 'OS=="win"', {
|
||||
'libraries': [
|
||||
'advapi32.lib',
|
||||
],
|
||||
}],
|
||||
],
|
||||
'defines': [
|
||||
'NSS_USE_STATIC_LIBS'
|
||||
],
|
||||
}
|
||||
],
|
||||
'target_defaults': {
|
||||
'include_dirs': [
|
||||
'../../gtests/google_test/gtest/include',
|
||||
'../../gtests/common',
|
||||
'../../lib/util'
|
||||
]
|
||||
},
|
||||
|
|
|
|||
179
security/nss/gtests/util_gtest/util_pkcs11uri_unittest.cc
Normal file
179
security/nss/gtests/util_gtest/util_pkcs11uri_unittest.cc
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
/* -*- 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 <climits>
|
||||
#include <memory>
|
||||
#include "pkcs11uri.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "scoped_ptrs_util.h"
|
||||
|
||||
namespace nss_test {
|
||||
|
||||
class PK11URITest : public ::testing::Test {
|
||||
public:
|
||||
bool TestCreate(const PK11URIAttribute *pattrs, size_t num_pattrs,
|
||||
const PK11URIAttribute *qattrs, size_t num_qattrs) {
|
||||
ScopedPK11URI tmp(
|
||||
PK11URI_CreateURI(pattrs, num_pattrs, qattrs, num_qattrs));
|
||||
return tmp != nullptr;
|
||||
}
|
||||
|
||||
void TestCreateRetrieve(const PK11URIAttribute *pattrs, size_t num_pattrs,
|
||||
const PK11URIAttribute *qattrs, size_t num_qattrs) {
|
||||
ScopedPK11URI tmp(
|
||||
PK11URI_CreateURI(pattrs, num_pattrs, qattrs, num_qattrs));
|
||||
ASSERT_TRUE(tmp);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < num_pattrs; i++) {
|
||||
const char *value = PK11URI_GetPathAttribute(tmp.get(), pattrs[i].name);
|
||||
EXPECT_TRUE(value);
|
||||
if (value) {
|
||||
EXPECT_EQ(std::string(value), std::string(pattrs[i].value));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < num_qattrs; i++) {
|
||||
const char *value = PK11URI_GetQueryAttribute(tmp.get(), qattrs[i].name);
|
||||
EXPECT_TRUE(value);
|
||||
if (value) {
|
||||
EXPECT_EQ(std::string(value), std::string(qattrs[i].value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TestCreateFormat(const PK11URIAttribute *pattrs, size_t num_pattrs,
|
||||
const PK11URIAttribute *qattrs, size_t num_qattrs,
|
||||
const std::string &formatted) {
|
||||
ScopedPK11URI tmp(
|
||||
PK11URI_CreateURI(pattrs, num_pattrs, qattrs, num_qattrs));
|
||||
ASSERT_TRUE(tmp);
|
||||
char *out = PK11URI_FormatURI(nullptr, tmp.get());
|
||||
EXPECT_TRUE(out);
|
||||
if (out) {
|
||||
EXPECT_EQ(std::string(out), formatted);
|
||||
}
|
||||
PORT_Free(out);
|
||||
}
|
||||
|
||||
bool TestParse(const std::string &str) {
|
||||
ScopedPK11URI tmp(PK11URI_ParseURI(str.c_str()));
|
||||
return tmp != nullptr;
|
||||
}
|
||||
|
||||
void TestParseRetrieve(const std::string &str, const PK11URIAttribute *pattrs,
|
||||
size_t num_pattrs, const PK11URIAttribute *qattrs,
|
||||
size_t num_qattrs) {
|
||||
ScopedPK11URI tmp(PK11URI_ParseURI(str.c_str()));
|
||||
ASSERT_TRUE(tmp);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < num_pattrs; i++) {
|
||||
const char *value = PK11URI_GetPathAttribute(tmp.get(), pattrs[i].name);
|
||||
EXPECT_TRUE(value);
|
||||
if (value) {
|
||||
EXPECT_EQ(std::string(value), std::string(pattrs[i].value));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < num_qattrs; i++) {
|
||||
const char *value = PK11URI_GetQueryAttribute(tmp.get(), qattrs[i].name);
|
||||
EXPECT_TRUE(value);
|
||||
if (value) {
|
||||
EXPECT_EQ(std::string(value), std::string(qattrs[i].value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TestParseFormat(const std::string &str, const std::string &formatted) {
|
||||
ScopedPK11URI tmp(PK11URI_ParseURI(str.c_str()));
|
||||
ASSERT_TRUE(tmp);
|
||||
char *out = PK11URI_FormatURI(nullptr, tmp.get());
|
||||
EXPECT_TRUE(out);
|
||||
if (out) {
|
||||
EXPECT_EQ(std::string(out), formatted);
|
||||
PORT_Free(out);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
const PK11URIAttribute pattrs[] = {
|
||||
{"token", "aaa"}, {"manufacturer", "bbb"}, {"vendor", "ccc"}};
|
||||
|
||||
const PK11URIAttribute qattrs[] = {{"pin-source", "|grep foo /etc/passwd"},
|
||||
{"pin-value", "secret"},
|
||||
{"vendor", "ddd"}};
|
||||
|
||||
const PK11URIAttribute pattrs_invalid[] = {{"token", "aaa"},
|
||||
{"manufacturer", "bbb"},
|
||||
{"vendor", "ccc"},
|
||||
{"$%*&", "invalid"},
|
||||
{"", "empty"}};
|
||||
|
||||
const PK11URIAttribute qattrs_invalid[] = {
|
||||
{"pin-source", "|grep foo /etc/passwd"},
|
||||
{"pin-value", "secret"},
|
||||
{"vendor", "ddd"},
|
||||
{"$%*&", "invalid"},
|
||||
{"", "empty"}};
|
||||
|
||||
TEST_F(PK11URITest, CreateTest) {
|
||||
EXPECT_TRUE(
|
||||
TestCreate(pattrs, PR_ARRAY_SIZE(pattrs), qattrs, PR_ARRAY_SIZE(qattrs)));
|
||||
EXPECT_FALSE(TestCreate(pattrs_invalid, PR_ARRAY_SIZE(pattrs_invalid), qattrs,
|
||||
PR_ARRAY_SIZE(qattrs)));
|
||||
EXPECT_FALSE(TestCreate(pattrs, PR_ARRAY_SIZE(pattrs), qattrs_invalid,
|
||||
PR_ARRAY_SIZE(qattrs_invalid)));
|
||||
EXPECT_FALSE(TestCreate(pattrs_invalid, PR_ARRAY_SIZE(pattrs_invalid),
|
||||
qattrs_invalid, PR_ARRAY_SIZE(qattrs_invalid)));
|
||||
}
|
||||
|
||||
TEST_F(PK11URITest, CreateRetrieveTest) {
|
||||
TestCreateRetrieve(pattrs, PR_ARRAY_SIZE(pattrs), qattrs,
|
||||
PR_ARRAY_SIZE(qattrs));
|
||||
}
|
||||
|
||||
TEST_F(PK11URITest, CreateFormatTest) {
|
||||
TestCreateFormat(pattrs, PR_ARRAY_SIZE(pattrs), qattrs, PR_ARRAY_SIZE(qattrs),
|
||||
"pkcs11:token=aaa;manufacturer=bbb;vendor=ccc?pin-source=|"
|
||||
"grep%20foo%20/etc/passwd&pin-value=secret&vendor=ddd");
|
||||
}
|
||||
|
||||
TEST_F(PK11URITest, ParseTest) {
|
||||
EXPECT_FALSE(TestParse("pkcs11:token=aaa;token=bbb"));
|
||||
EXPECT_FALSE(TestParse("pkcs11:dup=aaa;dup=bbb"));
|
||||
EXPECT_FALSE(TestParse("pkcs11:?pin-value=aaa&pin-value=bbb"));
|
||||
EXPECT_FALSE(TestParse("pkcs11:=empty"));
|
||||
EXPECT_FALSE(TestParse("pkcs11:token=%2;manufacturer=aaa"));
|
||||
}
|
||||
|
||||
TEST_F(PK11URITest, ParseRetrieveTest) {
|
||||
TestParseRetrieve(
|
||||
"pkcs11:token=aaa;manufacturer=bbb;vendor=ccc?pin-source=|"
|
||||
"grep%20foo%20/etc/passwd&pin-value=secret&vendor=ddd",
|
||||
pattrs, PR_ARRAY_SIZE(pattrs), qattrs, PR_ARRAY_SIZE(qattrs));
|
||||
}
|
||||
|
||||
TEST_F(PK11URITest, ParseFormatTest) {
|
||||
TestParseFormat("pkcs11:", "pkcs11:");
|
||||
TestParseFormat("pkcs11:token=aaa", "pkcs11:token=aaa");
|
||||
TestParseFormat("pkcs11:token=aaa;manufacturer=bbb",
|
||||
"pkcs11:token=aaa;manufacturer=bbb");
|
||||
TestParseFormat("pkcs11:manufacturer=bbb;token=aaa",
|
||||
"pkcs11:token=aaa;manufacturer=bbb");
|
||||
TestParseFormat("pkcs11:manufacturer=bbb;token=aaa;vendor2=ddd;vendor1=ccc",
|
||||
"pkcs11:token=aaa;manufacturer=bbb;vendor1=ccc;vendor2=ddd");
|
||||
TestParseFormat("pkcs11:?pin-value=secret", "pkcs11:?pin-value=secret");
|
||||
TestParseFormat("pkcs11:?dup=aaa&dup=bbb", "pkcs11:?dup=aaa&dup=bbb");
|
||||
TestParseFormat(
|
||||
"pkcs11:?pin-source=|grep%20foo%20/etc/passwd&pin-value=secret",
|
||||
"pkcs11:?pin-source=|grep%20foo%20/etc/passwd&pin-value=secret");
|
||||
TestParseFormat("pkcs11:token=aaa?pin-value=secret",
|
||||
"pkcs11:token=aaa?pin-value=secret");
|
||||
}
|
||||
|
||||
} // namespace nss_test
|
||||
Loading…
Add table
Add a link
Reference in a new issue