mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-28 03:17:31 +09:00
Replace NSS with Pale Moon's
This commit is contained in:
parent
ff1e5e48bf
commit
8c2e376f94
2870 changed files with 1762232 additions and 1374220 deletions
|
|
@ -15,9 +15,11 @@
|
|||
|
||||
#include "blapi.h"
|
||||
|
||||
extern std::string g_source_dir;
|
||||
|
||||
namespace nss_test {
|
||||
|
||||
typedef struct PRNGTestValuesStr {
|
||||
struct PRNGTestValues {
|
||||
std::vector<uint8_t> entropy;
|
||||
std::vector<uint8_t> nonce;
|
||||
std::vector<uint8_t> personal;
|
||||
|
|
@ -25,9 +27,7 @@ typedef struct PRNGTestValuesStr {
|
|||
std::vector<uint8_t> additional_entropy;
|
||||
std::vector<uint8_t> additional_input_reseed;
|
||||
std::vector<std::vector<uint8_t>> additional_input;
|
||||
} PRNGTestValues;
|
||||
|
||||
std::vector<PRNGTestValues> test_vector;
|
||||
};
|
||||
|
||||
bool contains(std::string& s, const char* to_find) {
|
||||
return s.find(to_find) != std::string::npos;
|
||||
|
|
@ -59,8 +59,10 @@ void print_bytes(std::vector<uint8_t> bytes, std::string name) {
|
|||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
static void ReadFile(const std::string file_name) {
|
||||
static std::vector<PRNGTestValues> ReadFile(const std::string file_name) {
|
||||
std::vector<PRNGTestValues> test_vector;
|
||||
std::ifstream infile(file_name);
|
||||
EXPECT_FALSE(infile.fail()) << "kat file: " << file_name;
|
||||
std::string line;
|
||||
|
||||
// Variables holding the input for each test.
|
||||
|
|
@ -123,11 +125,17 @@ static void ReadFile(const std::string file_name) {
|
|||
test = {};
|
||||
infile.seekg(pos);
|
||||
}
|
||||
return test_vector;
|
||||
}
|
||||
|
||||
class PRNGTest : public ::testing::TestWithParam<PRNGTestValues> {
|
||||
class PRNGTest : public ::testing::Test {
|
||||
protected:
|
||||
void RunTest(PRNGTestValues test) {
|
||||
void SetUp() override {
|
||||
test_vector_ = ReadFile(::g_source_dir + "/kat/Hash_DRBG.rsp");
|
||||
ASSERT_FALSE(test_vector_.empty());
|
||||
}
|
||||
|
||||
void RunTest(PRNGTestValues& test) {
|
||||
ASSERT_EQ(2U, test.additional_input.size());
|
||||
SECStatus rv = PRNGTEST_Instantiate_Kat(
|
||||
test.entropy.data(), test.entropy.size(), test.nonce.data(),
|
||||
|
|
@ -154,34 +162,15 @@ class PRNGTest : public ::testing::TestWithParam<PRNGTestValues> {
|
|||
rv = PRNGTEST_Uninstantiate();
|
||||
ASSERT_EQ(SECSuccess, rv);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<PRNGTestValues> test_vector_;
|
||||
};
|
||||
|
||||
TEST_P(PRNGTest, HashDRBG) { RunTest(GetParam()); }
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(NISTTestVector, PRNGTest,
|
||||
::testing::ValuesIn(test_vector));
|
||||
|
||||
} // nss_test
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc < 2) {
|
||||
std::cout << "usage: prng_gtest <.rsp file>" << std::endl;
|
||||
return 1;
|
||||
TEST_F(PRNGTest, HashDRBG) {
|
||||
for (auto& v : test_vector_) {
|
||||
RunTest(v);
|
||||
}
|
||||
|
||||
nss_test::ReadFile(argv[1]);
|
||||
assert(!nss_test::test_vector.empty());
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
if (NSS_NoDB_Init(nullptr) != SECSuccess) {
|
||||
return 1;
|
||||
}
|
||||
int rv = RUN_ALL_TESTS();
|
||||
|
||||
if (NSS_Shutdown() != SECSuccess) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
} // namespace nss_test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue