From d33b278940c8e2840213ae59d1c682528980278d Mon Sep 17 00:00:00 2001 From: John Bland Date: Mon, 11 Nov 2024 12:59:10 -0500 Subject: [PATCH 1/2] add rng to the bindings --- addon/wolfcrypt/h/random.h | 32 ++++++++++++++++ addon/wolfcrypt/main.cpp | 6 +++ addon/wolfcrypt/random.cpp | 63 +++++++++++++++++++++++++++++++ binding.gyp | 5 ++- interfaces/random.js | 76 ++++++++++++++++++++++++++++++++++++++ tests/random.js | 41 ++++++++++++++++++++ 6 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 addon/wolfcrypt/h/random.h create mode 100644 addon/wolfcrypt/random.cpp create mode 100644 interfaces/random.js create mode 100644 tests/random.js diff --git a/addon/wolfcrypt/h/random.h b/addon/wolfcrypt/h/random.h new file mode 100644 index 0000000..787268c --- /dev/null +++ b/addon/wolfcrypt/h/random.h @@ -0,0 +1,32 @@ +/* random.h + * + * Copyright (C) 2006-2022 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ +#include +#ifndef WOLFSSL_USER_SETTINGS +#include "wolfssl/options.h" +#endif +#include +#include +#include + +Napi::Number sizeof_WC_RNG(const Napi::CallbackInfo& info); +Napi::Number bind_wc_InitRng(const Napi::CallbackInfo& info); +Napi::Number bind_wc_RNG_GenerateBlock(const Napi::CallbackInfo& info); +Napi::Number bind_wc_FreeRng(const Napi::CallbackInfo& info); diff --git a/addon/wolfcrypt/main.cpp b/addon/wolfcrypt/main.cpp index 5f84450..17704c4 100644 --- a/addon/wolfcrypt/main.cpp +++ b/addon/wolfcrypt/main.cpp @@ -29,6 +29,7 @@ #include "./h/pbkdf2.h" #include "./h/pkcs7.h" #include "./h/pkcs12.h" +#include "./h/random.h" using namespace Napi; @@ -175,6 +176,11 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) exports.Set(Napi::String::New(env, "nodejsPKCS12InternalToDer"), Napi::Function::New(env, nodejsPKCS12InternalToDer)); exports.Set(Napi::String::New(env, "wc_PKCS12_free"), Napi::Function::New(env, bind_wc_PKCS12_free)); + exports.Set(Napi::String::New(env, "sizeof_WC_RNG"), Napi::Function::New(env, sizeof_WC_RNG)); + exports.Set(Napi::String::New(env, "wc_InitRng"), Napi::Function::New(env, bind_wc_InitRng)); + exports.Set(Napi::String::New(env, "wc_RNG_GenerateBlock"), Napi::Function::New(env, bind_wc_RNG_GenerateBlock)); + exports.Set(Napi::String::New(env, "wc_FreeRng"), Napi::Function::New(env, bind_wc_FreeRng)); + return exports; } diff --git a/addon/wolfcrypt/random.cpp b/addon/wolfcrypt/random.cpp new file mode 100644 index 0000000..a35437a --- /dev/null +++ b/addon/wolfcrypt/random.cpp @@ -0,0 +1,63 @@ +/* random.cpp + * + * Copyright (C) 2006-2022 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ +#include "./h/random.h" + +Napi::Number sizeof_WC_RNG(const Napi::CallbackInfo& info) +{ + Napi::Env env = info.Env(); + + return Napi::Number::New(env, sizeof(WC_RNG)); +} + +Napi::Number bind_wc_InitRng(const Napi::CallbackInfo& info) +{ + Napi::Env env = info.Env(); + int ret; + WC_RNG* rng = (WC_RNG*)(info[0].As().Data()); + + ret = wc_InitRng(rng); + + return Napi::Number::New(env, ret); +} + +Napi::Number bind_wc_RNG_GenerateBlock(const Napi::CallbackInfo& info) +{ + Napi::Env env = info.Env(); + int ret; + WC_RNG* rng = (WC_RNG*)(info[0].As().Data()); + uint8_t* out = (uint8_t*)(info[1].As().Data()); + word32 outLen = (word32)(info[2].As().Int32Value()); + + ret = wc_RNG_GenerateBlock(rng, out, outLen); + + return Napi::Number::New(env, ret); +} + +Napi::Number bind_wc_FreeRng(const Napi::CallbackInfo& info) +{ + Napi::Env env = info.Env(); + int ret; + WC_RNG* rng = (WC_RNG*)(info[0].As().Data()); + + ret = wc_FreeRng(rng); + + return Napi::Number::New(env, ret); +} diff --git a/binding.gyp b/binding.gyp index 20ac163..e9068f9 100644 --- a/binding.gyp +++ b/binding.gyp @@ -12,7 +12,8 @@ "addon/wolfcrypt/ecc.cpp", "addon/wolfcrypt/pbkdf2.cpp", "addon/wolfcrypt/pkcs7.cpp", - "addon/wolfcrypt/pkcs12.cpp" + "addon/wolfcrypt/pkcs12.cpp", + "addon/wolfcrypt/random.cpp" ], 'include_dirs': [ " Date: Tue, 12 Nov 2024 17:47:59 -0500 Subject: [PATCH 2/2] update license year on headers, use smaller blocks and check for zeros of output --- addon/wolfcrypt/ecc.cpp | 2 +- addon/wolfcrypt/evp.cpp | 2 +- addon/wolfcrypt/h/ecc.h | 2 +- addon/wolfcrypt/h/evp.h | 2 +- addon/wolfcrypt/h/hmac.h | 2 +- addon/wolfcrypt/h/pbkdf2.h | 2 +- addon/wolfcrypt/h/pkcs12.h | 2 +- addon/wolfcrypt/h/pkcs7.h | 2 +- addon/wolfcrypt/h/random.h | 2 +- addon/wolfcrypt/h/rsa.h | 2 +- addon/wolfcrypt/h/sha.h | 2 +- addon/wolfcrypt/hmac.cpp | 2 +- addon/wolfcrypt/main.cpp | 2 +- addon/wolfcrypt/pbkdf2.cpp | 2 +- addon/wolfcrypt/pkcs12.cpp | 2 +- addon/wolfcrypt/pkcs7.cpp | 2 +- addon/wolfcrypt/random.cpp | 2 +- addon/wolfcrypt/rsa.cpp | 2 +- addon/wolfcrypt/sha.cpp | 2 +- index.js | 2 +- interfaces/ecc.js | 2 +- interfaces/evp.js | 2 +- interfaces/hmac.js | 2 +- interfaces/pbkdf2.js | 2 +- interfaces/pkcs12.js | 2 +- interfaces/pkcs7.js | 2 +- interfaces/random.js | 2 +- interfaces/rsa.js | 2 +- interfaces/sha.js | 2 +- test.js | 2 +- tests/ecc.js | 2 +- tests/evp.js | 2 +- tests/hmac.js | 2 +- tests/index.js | 2 +- tests/pbkdf2.js | 2 +- tests/pkcs12.js | 2 +- tests/pkcs7.js | 2 +- tests/random.js | 19 +++++++++++++++---- tests/rsa.js | 2 +- tests/sha.js | 2 +- 40 files changed, 54 insertions(+), 43 deletions(-) diff --git a/addon/wolfcrypt/ecc.cpp b/addon/wolfcrypt/ecc.cpp index 047a7a4..46a1293 100644 --- a/addon/wolfcrypt/ecc.cpp +++ b/addon/wolfcrypt/ecc.cpp @@ -1,6 +1,6 @@ /* ecc.cpp * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/evp.cpp b/addon/wolfcrypt/evp.cpp index 2991dd8..280c553 100644 --- a/addon/wolfcrypt/evp.cpp +++ b/addon/wolfcrypt/evp.cpp @@ -1,6 +1,6 @@ /* evp.cpp * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/h/ecc.h b/addon/wolfcrypt/h/ecc.h index 7f87d5f..89eddae 100644 --- a/addon/wolfcrypt/h/ecc.h +++ b/addon/wolfcrypt/h/ecc.h @@ -1,6 +1,6 @@ /* ecc.h * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/h/evp.h b/addon/wolfcrypt/h/evp.h index 730daf3..ab62719 100644 --- a/addon/wolfcrypt/h/evp.h +++ b/addon/wolfcrypt/h/evp.h @@ -1,6 +1,6 @@ /* evp.h * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/h/hmac.h b/addon/wolfcrypt/h/hmac.h index df96fd6..cbf493b 100644 --- a/addon/wolfcrypt/h/hmac.h +++ b/addon/wolfcrypt/h/hmac.h @@ -1,6 +1,6 @@ /* hmac.h * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/h/pbkdf2.h b/addon/wolfcrypt/h/pbkdf2.h index 9e30645..2891d15 100644 --- a/addon/wolfcrypt/h/pbkdf2.h +++ b/addon/wolfcrypt/h/pbkdf2.h @@ -1,6 +1,6 @@ /* pbkdf2.h * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/h/pkcs12.h b/addon/wolfcrypt/h/pkcs12.h index 853c8ec..e82912d 100644 --- a/addon/wolfcrypt/h/pkcs12.h +++ b/addon/wolfcrypt/h/pkcs12.h @@ -1,6 +1,6 @@ /* pkcs12.h * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/h/pkcs7.h b/addon/wolfcrypt/h/pkcs7.h index 8c5e5cc..7e4f931 100644 --- a/addon/wolfcrypt/h/pkcs7.h +++ b/addon/wolfcrypt/h/pkcs7.h @@ -1,6 +1,6 @@ /* pkcs7.h * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/h/random.h b/addon/wolfcrypt/h/random.h index 787268c..e7a5786 100644 --- a/addon/wolfcrypt/h/random.h +++ b/addon/wolfcrypt/h/random.h @@ -1,6 +1,6 @@ /* random.h * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/h/rsa.h b/addon/wolfcrypt/h/rsa.h index 962a090..b02dd3e 100644 --- a/addon/wolfcrypt/h/rsa.h +++ b/addon/wolfcrypt/h/rsa.h @@ -1,6 +1,6 @@ /* rsa.h * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/h/sha.h b/addon/wolfcrypt/h/sha.h index d8ab1b0..f730931 100644 --- a/addon/wolfcrypt/h/sha.h +++ b/addon/wolfcrypt/h/sha.h @@ -1,6 +1,6 @@ /* sha.h * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/hmac.cpp b/addon/wolfcrypt/hmac.cpp index ef414e4..3d69123 100644 --- a/addon/wolfcrypt/hmac.cpp +++ b/addon/wolfcrypt/hmac.cpp @@ -1,6 +1,6 @@ /* hmac.cpp * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/main.cpp b/addon/wolfcrypt/main.cpp index 17704c4..21beaa6 100644 --- a/addon/wolfcrypt/main.cpp +++ b/addon/wolfcrypt/main.cpp @@ -1,6 +1,6 @@ /* main.cpp * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/pbkdf2.cpp b/addon/wolfcrypt/pbkdf2.cpp index a30bda6..25d0a9d 100644 --- a/addon/wolfcrypt/pbkdf2.cpp +++ b/addon/wolfcrypt/pbkdf2.cpp @@ -1,6 +1,6 @@ /* pbkdf2.cpp * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/pkcs12.cpp b/addon/wolfcrypt/pkcs12.cpp index 76e15a7..df7db8a 100644 --- a/addon/wolfcrypt/pkcs12.cpp +++ b/addon/wolfcrypt/pkcs12.cpp @@ -1,6 +1,6 @@ /* pkcs12.cpp * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/pkcs7.cpp b/addon/wolfcrypt/pkcs7.cpp index 11c4aff..da242aa 100644 --- a/addon/wolfcrypt/pkcs7.cpp +++ b/addon/wolfcrypt/pkcs7.cpp @@ -1,6 +1,6 @@ /* pkcs7.cpp * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/random.cpp b/addon/wolfcrypt/random.cpp index a35437a..3e8a06d 100644 --- a/addon/wolfcrypt/random.cpp +++ b/addon/wolfcrypt/random.cpp @@ -1,6 +1,6 @@ /* random.cpp * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/rsa.cpp b/addon/wolfcrypt/rsa.cpp index 1d38da3..16e1493 100644 --- a/addon/wolfcrypt/rsa.cpp +++ b/addon/wolfcrypt/rsa.cpp @@ -1,6 +1,6 @@ /* rsa.cpp * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/addon/wolfcrypt/sha.cpp b/addon/wolfcrypt/sha.cpp index 500d5ef..502af8b 100644 --- a/addon/wolfcrypt/sha.cpp +++ b/addon/wolfcrypt/sha.cpp @@ -1,6 +1,6 @@ /* sha.cpp * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/index.js b/index.js index 7568cc3..0cbde11 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ /* index.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/interfaces/ecc.js b/interfaces/ecc.js index 5851f19..a51e3f8 100644 --- a/interfaces/ecc.js +++ b/interfaces/ecc.js @@ -1,6 +1,6 @@ /* ecc.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/interfaces/evp.js b/interfaces/evp.js index ebc1470..e57fc32 100644 --- a/interfaces/evp.js +++ b/interfaces/evp.js @@ -1,6 +1,6 @@ /* evp.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/interfaces/hmac.js b/interfaces/hmac.js index 9b8261e..faaa1d9 100644 --- a/interfaces/hmac.js +++ b/interfaces/hmac.js @@ -1,6 +1,6 @@ /* hmac.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/interfaces/pbkdf2.js b/interfaces/pbkdf2.js index 00e218e..58b0fa5 100644 --- a/interfaces/pbkdf2.js +++ b/interfaces/pbkdf2.js @@ -1,6 +1,6 @@ /* pbkdf2.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/interfaces/pkcs12.js b/interfaces/pkcs12.js index 8e0b529..d187f98 100644 --- a/interfaces/pkcs12.js +++ b/interfaces/pkcs12.js @@ -1,6 +1,6 @@ /* pkcs12.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/interfaces/pkcs7.js b/interfaces/pkcs7.js index e8b1d13..28a2431 100644 --- a/interfaces/pkcs7.js +++ b/interfaces/pkcs7.js @@ -1,6 +1,6 @@ /* pkcs7.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/interfaces/random.js b/interfaces/random.js index 0bb5839..73a1e3f 100644 --- a/interfaces/random.js +++ b/interfaces/random.js @@ -1,6 +1,6 @@ /* random.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/interfaces/rsa.js b/interfaces/rsa.js index 57d7a5b..aeb376e 100644 --- a/interfaces/rsa.js +++ b/interfaces/rsa.js @@ -1,6 +1,6 @@ /* rsa.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/interfaces/sha.js b/interfaces/sha.js index 46bfd90..06cfd98 100644 --- a/interfaces/sha.js +++ b/interfaces/sha.js @@ -1,6 +1,6 @@ /* sha.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/test.js b/test.js index a962490..0ad6f9a 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,6 @@ /* test.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/ecc.js b/tests/ecc.js index 1d9f5f3..c0272ed 100644 --- a/tests/ecc.js +++ b/tests/ecc.js @@ -1,6 +1,6 @@ /* ecc.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/evp.js b/tests/evp.js index 3ee5616..7fa46c4 100644 --- a/tests/evp.js +++ b/tests/evp.js @@ -1,6 +1,6 @@ /* evp.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/hmac.js b/tests/hmac.js index 83f6d12..3f59798 100644 --- a/tests/hmac.js +++ b/tests/hmac.js @@ -1,6 +1,6 @@ /* hmac.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/index.js b/tests/index.js index d3dee26..4c3b407 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,6 +1,6 @@ /* index.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/pbkdf2.js b/tests/pbkdf2.js index 276b77e..6edf681 100644 --- a/tests/pbkdf2.js +++ b/tests/pbkdf2.js @@ -1,6 +1,6 @@ /* pbkdf2.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/pkcs12.js b/tests/pkcs12.js index 77a0985..a55d8bf 100644 --- a/tests/pkcs12.js +++ b/tests/pkcs12.js @@ -1,6 +1,6 @@ /* pkcs12.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/pkcs7.js b/tests/pkcs7.js index bae7084..aab38f8 100644 --- a/tests/pkcs7.js +++ b/tests/pkcs7.js @@ -1,6 +1,6 @@ /* pkcs7.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/random.js b/tests/random.js index 7c3d3bf..e6c361c 100644 --- a/tests/random.js +++ b/tests/random.js @@ -1,6 +1,6 @@ /* random.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -25,15 +25,26 @@ const rng_tests = generateBlock: async function() { let rng = new WolfSSLRandom() - let rngOne = rng.GenerateBlock(1000) - let rngTwo = rng.GenerateBlock(1000) + let rngOne = rng.GenerateBlock(256) + let rngTwo = rng.GenerateBlock(256) rng.free() if (rngOne.equals(rngTwo)) { console.log('FAIL RNG generateBlock') } else { - console.log('PASS RNG generateBlock') + let i; + for (i = 0; i < rngOne.length; i++) { + if (rngOne[i] != 0) { + break + } + } + if (i >= rngOne.length) { + console.log('FAIL RNG generateBlock') + } + else { + console.log('PASS RNG generateBlock') + } } } } diff --git a/tests/rsa.js b/tests/rsa.js index 412eea6..b73f75c 100644 --- a/tests/rsa.js +++ b/tests/rsa.js @@ -1,6 +1,6 @@ /* rsa.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/tests/sha.js b/tests/sha.js index fbdd75b..5f11da2 100644 --- a/tests/sha.js +++ b/tests/sha.js @@ -1,6 +1,6 @@ /* sha.js * - * Copyright (C) 2006-2022 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. *