2 Commits

Author SHA256 Message Date
13c0b799c0 Bump to 3.112.2 2025-10-22 13:54:42 +02:00
d18f9c1bef Sync changes to SLFO-1.2 branch 2025-08-20 09:52:46 +02:00
8 changed files with 1110 additions and 594 deletions

81
bmo1956754.patch Normal file
View File

@@ -0,0 +1,81 @@
# HG changeset patch
# User Nikolas Wipper <nwipper@mozilla.com>
# Date 1759164988 0
# Node ID 6b0a460d27cdbd71a9e6cb191571b54715538b99
# Parent 57bda5fa146eca15680b0416e340df8426ce928f
Bug 1956754 - don't flush base64 when buffer is null. r=jschanck
Differential Revision: https://phabricator.services.mozilla.com/D263261
diff --git a/gtests/util_gtest/util_b64_unittest.cc b/gtests/util_gtest/util_b64_unittest.cc
--- a/gtests/util_gtest/util_b64_unittest.cc
+++ b/gtests/util_gtest/util_b64_unittest.cc
@@ -56,16 +56,25 @@ class B64EncodeDecodeTest : public ::tes
TEST_F(B64EncodeDecodeTest, DecEncTest) { TestDecodeStr("VGhpcyBpcyBOU1Mh"); }
TEST_F(B64EncodeDecodeTest, EncDecTest) {
uint8_t data[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
SECItem tmp = {siBuffer, data, sizeof(data)};
TestEncodeItem(&tmp);
}
+TEST_F(B64EncodeDecodeTest, IncompleteData) {
+ NSSBase64Decoder *context = NSSBase64Decoder_Create(
+ [](void *, const unsigned char *, PRInt32) { return 0; }, nullptr);
+ EXPECT_TRUE(!!context);
+ char data = 'A';
+ EXPECT_EQ(SECSuccess, NSSBase64Decoder_Update(context, &data, 1));
+ EXPECT_EQ(SECFailure, NSSBase64Decoder_Destroy(context, false));
+}
+
TEST_F(B64EncodeDecodeTest, FakeDecTest) { EXPECT_TRUE(TestFakeDecode(100)); }
TEST_F(B64EncodeDecodeTest, FakeEncDecTest) {
EXPECT_TRUE(TestFakeEncode(100));
}
// These takes a while ...
TEST_F(B64EncodeDecodeTest, DISABLED_LongFakeDecTest1) {
diff --git a/lib/util/nssb64d.c b/lib/util/nssb64d.c
--- a/lib/util/nssb64d.c
+++ b/lib/util/nssb64d.c
@@ -352,16 +352,19 @@ pl_base64_decode_flush(PLBase64Decoder *
/*
* If no remaining characters, or all are padding (also not well-formed
* input, but again, be tolerant), then nothing more to do. (And, that
* is considered successful.)
*/
if (data->token_size == 0 || data->token[0] == B64_PAD)
return PR_SUCCESS;
+ if (!data->output_buffer)
+ return PR_FAILURE;
+
/*
* Assume we have all the interesting input except for some expected
* padding characters. Add them and decode the resulting token.
*/
while (data->token_size < 4)
data->token[data->token_size++] = B64_PAD;
data->token_size = 0; /* so a subsequent flush call is a no-op */
@@ -394,17 +397,17 @@ pl_base64_decode_flush(PLBase64Decoder *
/*
* The maximum space needed to hold the output of the decoder given
* input data of length "size".
*/
static PRUint32
PL_Base64MaxDecodedLength(PRUint32 size)
{
- return size * 0.75;
+ return (((PRUint64)size) * 3) / 4;
}
/*
* A distinct internal creation function for the buffer version to use.
* (It does not want to specify an output_fn, and we want the normal
* Create function to require that.) If more common initialization
* of the decoding context needs to be done, it should be done *here*.
*/

104
bmo1980465.patch Normal file
View File

@@ -0,0 +1,104 @@
# HG changeset patch
# User Alexander Sosedkin <asosedkin@redhat.com>
# Date 1758314824 0
# Node ID 5cd6a78cccd3e47d5097d1266bc809bb910fa019
# Parent 08d99cad107fb6686c58b8659036b82c88d7681e
Bug 1980465 - Fix a big-endian-problematic cast in zlib calls. r=nkulatova
Differential Revision: https://phabricator.services.mozilla.com/D259453
diff --git a/cmd/selfserv/selfserv.c b/cmd/selfserv/selfserv.c
--- a/cmd/selfserv/selfserv.c
+++ b/cmd/selfserv/selfserv.c
@@ -2112,19 +2112,19 @@ zlibCertificateDecode(const SECItem *inp
unsigned char *output, size_t outputLen,
size_t *usedLen)
{
if (!input || !input->data || input->len == 0 || !output || outputLen == 0) {
PR_SetError(SEC_ERROR_INVALID_ARGS, 0);
return SECFailure;
}
- *usedLen = outputLen;
-
- int ret = uncompress(output, (unsigned long *)usedLen, input->data, input->len);
+ unsigned long outputLenUL = outputLen;
+ int ret = uncompress(output, &outputLenUL, input->data, input->len);
+ *usedLen = outputLenUL;
if (ret != Z_OK) {
PR_SetError(SEC_ERROR_BAD_DATA, 0);
return SECFailure;
}
return SECSuccess;
}
@@ -2134,17 +2134,19 @@ zlibCertificateEncode(const SECItem *inp
if (!input || !input->data || input->len == 0 || !output) {
PR_SetError(SEC_ERROR_INVALID_ARGS, 0);
return SECFailure;
}
unsigned long maxCompressedLen = compressBound(input->len);
SECITEM_AllocItem(NULL, output, maxCompressedLen);
- int ret = compress(output->data, (unsigned long *)&output->len, input->data, input->len);
+ unsigned long outputLenUL = output->len;
+ int ret = compress(output->data, &outputLenUL, input->data, input->len);
+ output->len = outputLenUL;
if (ret != Z_OK) {
PR_SetError(SEC_ERROR_LIBRARY_FAILURE, 0);
return SECFailure;
}
return SECSuccess;
}
diff --git a/cmd/tstclnt/tstclnt.c b/cmd/tstclnt/tstclnt.c
--- a/cmd/tstclnt/tstclnt.c
+++ b/cmd/tstclnt/tstclnt.c
@@ -1366,17 +1366,19 @@ zlibCertificateEncode(const SECItem *inp
if (!input || !input->data || input->len == 0 || !output) {
PR_SetError(SEC_ERROR_INVALID_ARGS, 0);
return SECFailure;
}
unsigned long maxCompressedLen = compressBound(input->len);
SECITEM_AllocItem(NULL, output, maxCompressedLen);
- int ret = compress(output->data, (unsigned long *)&output->len, input->data, input->len);
+ unsigned long outputLenUL = output->len;
+ int ret = compress(output->data, &outputLenUL, input->data, input->len);
+ output->len = outputLenUL;
if (ret != Z_OK) {
PR_SetError(SEC_ERROR_LIBRARY_FAILURE, 0);
return SECFailure;
}
return SECSuccess;
}
@@ -1385,19 +1387,19 @@ zlibCertificateDecode(const SECItem *inp
unsigned char *output, size_t outputLen,
size_t *usedLen)
{
if (!input || !input->data || input->len == 0 || !output || outputLen == 0) {
PR_SetError(SEC_ERROR_INVALID_ARGS, 0);
return SECFailure;
}
- *usedLen = outputLen;
-
- int ret = uncompress(output, (unsigned long *)usedLen, input->data, input->len);
+ unsigned long outputLenUL = outputLen;
+ int ret = uncompress(output, &outputLenUL, input->data, input->len);
+ *usedLen = outputLenUL;
if (ret != Z_OK) {
PR_SetError(SEC_ERROR_BAD_DATA, 0);
return SECFailure;
}
return SECSuccess;
}

103
bmo1990242.patch Normal file
View File

@@ -0,0 +1,103 @@
From 8dc8570390aac6947e6c686d18e3dbf7d7a10999 Mon Sep 17 00:00:00 2001
From: Hans Petter Jansson <hpj@hpjansson.org>
Date: Tue, 23 Sep 2025 17:06:55 +0200
Subject: [PATCH] Bug 1990242 Move NSS DB password hash away from SHA-1
When the database password is set or changed, migrate the database to
a new passwordToKey function using SHA-384.
SHA-1-based databases will still be supported. The hash function to use
is determined by the size of the stored salt.
An empty password will always use SHA-1.
---
lib/softoken/sftkpwd.c | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/lib/softoken/sftkpwd.c b/lib/softoken/sftkpwd.c
index bb5c23084..d719f3b54 100644
--- a/lib/softoken/sftkpwd.c
+++ b/lib/softoken/sftkpwd.c
@@ -93,35 +93,40 @@ static SECStatus
sftkdb_passwordToKey(SFTKDBHandle *keydb, SECItem *salt,
const char *pw, SECItem *key)
{
- SHA1Context *cx = NULL;
+ HASH_HashType hType;
+ const SECHashObject *hashObj;
+ void *ctx = NULL;
SECStatus rv = SECFailure;
+ hType = salt->len == SHA384_LENGTH ? HASH_AlgSHA384 : HASH_AlgSHA1;
+ hashObj = HASH_GetRawHashObject(hType);
+
if (!pw) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return SECFailure;
}
- key->data = PORT_Alloc(SHA1_LENGTH);
+ key->data = PORT_Alloc(hashObj->length);
if (key->data == NULL) {
goto loser;
}
- key->len = SHA1_LENGTH;
+ key->len = hashObj->length;
- cx = SHA1_NewContext();
- if (cx == NULL) {
+ ctx = hashObj->create();
+ if (ctx == NULL) {
goto loser;
}
- SHA1_Begin(cx);
+ hashObj->begin(ctx);
if (salt && salt->data) {
- SHA1_Update(cx, salt->data, salt->len);
+ hashObj->update(ctx, salt->data, salt->len);
}
- SHA1_Update(cx, (unsigned char *)pw, PORT_Strlen(pw));
- SHA1_End(cx, key->data, &key->len, key->len);
+ hashObj->update(ctx, (unsigned char *)pw, PORT_Strlen(pw));
+ hashObj->end(ctx, key->data, &key->len, key->len);
rv = SECSuccess;
loser:
- if (cx) {
- SHA1_DestroyContext(cx, PR_TRUE);
+ if (ctx) {
+ hashObj->destroy(ctx, PR_TRUE);
}
if (rv != SECSuccess) {
if (key->data != NULL) {
@@ -1362,6 +1367,7 @@ sftkdb_ChangePassword(SFTKDBHandle *keydb,
unsigned char saltData[SDB_MAX_META_DATA_LEN];
unsigned char valueData[SDB_MAX_META_DATA_LEN];
int iterationCount = getPBEIterationCount();
+ int preferred_salt_length;
CK_RV crv;
SDB *db;
@@ -1393,7 +1399,18 @@ sftkdb_ChangePassword(SFTKDBHandle *keydb,
goto loser;
}
} else {
- salt.len = SHA1_LENGTH;
+ salt.len = 0;
+ }
+
+ preferred_salt_length = SHA384_LENGTH;
+
+ /* Prefer SHA-1 if the password is NULL */
+ if (!newPin || *newPin == 0) {
+ preferred_salt_length = SHA1_LENGTH;
+ }
+
+ if (salt.len != preferred_salt_length) {
+ salt.len = preferred_salt_length;
RNG_GenerateGlobalRandomBytes(salt.data, salt.len);
}
--
2.47.0

File diff suppressed because it is too large Load Diff

View File

@@ -17,15 +17,14 @@
#
%global nss_softokn_fips_version 3.113
%global nss_softokn_fips_version 3.112
%define NSPR_min_version 4.36
%define nspr_ver %(rpm -q --queryformat '%%{VERSION}' mozilla-nspr)
%define nssdbdir %{_sysconfdir}/pki/nssdb
%global crypto_policies_version 20210218
Name: mozilla-nss
Version: 3.113
Version: 3.112.2
Release: 0
%define underscore_version 3_113
%define underscore_version 3_112_2
Summary: Network Security Services
License: MPL-2.0
Group: System/Libraries
@@ -81,6 +80,10 @@ Patch48: nss-fips-test.patch
Patch49: nss-allow-slow-tests-s390x.patch
Patch50: nss-fips-bsc1223724.patch
Patch51: nss-fips-aes-gcm-restrict.patch
Patch52: bmo1990242.patch
# Backported patches to be removed with next ESR cycle (> 3.112)
Patch60: bmo1980465.patch
Patch61: bmo1956754.patch
%if 0%{?sle_version} >= 120000 && 0%{?sle_version} < 150000
# aarch64 + gcc4.8 fails to build on SLE-12 due to undefined references
BuildRequires: gcc9-c++
@@ -246,6 +249,11 @@ cd nss
%endif
%patch -P 50 -p1
%patch -P 51 -p1
%patch -P 52 -p1
# Backported patches that should be removed with next ESR cycle (> 3.112)
%patch -P 60 -p1
%patch -P 61 -p1
# additional CA certificates
#cd security/nss/lib/ckfw/builtins
@@ -285,13 +293,6 @@ export NSS_ENABLE_FIPS_INDICATORS=1
export NSS_FIPS_MODULE_ID="\"SUSE Linux Enterprise NSS %{version}-%{release}\""
#export SQLITE_LIB_NAME=nsssqlite3
export MAKE_FLAGS="BUILD_OPT=1"
%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150400
# Set the policy file location
# if set NSS will always check for the policy file and load if it exists
#export POLICY_FILE="nss.config"
# location of the policy file
#export POLICY_PATH="/etc/crypto-policies/back-ends"
%endif
EOF
source ../obsenv.sh
@@ -313,30 +314,12 @@ export HOST="localhost"
export DOMSUF="localdomain"
export USE_IP=TRUE
export IP_ADDRESS="127.0.0.1"
%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150400
# This is necessary because the test suite tests algorithms that are
# disabled by the system policy.
export NSS_IGNORE_SYSTEM_POLICY=1
%endif
EOF
source ../obsenv.sh
source ../obstestenv.sh
cd tests
./all.sh
# This file can live at different places when built in OBS or using "osc build":
if [ -s ../../../tests_results/security/localhost.1/output.log ]; then
output_log=../../../tests_results/security/localhost.1/output.log
elif [ -s ../../tests_results/security/localhost.1/output.log ]; then
output_log=../../tests_results/security/localhost.1/output.log
elif [ -s ../tests_results/security/localhost.1/output.log ]; then
output_log=../tests_results/security/localhost.1/output.log
elif [ -s ../security/localhost.1/output.log ]; then
output_log=../security/localhost.1/output.log
else
echo "Cannot find tests_results output.log - Assuming testsuite failed"
exit 1
fi
if grep "FAILED" $output_log ; then
if grep "FAILED" ../../../tests_results/security/localhost.1/output.log ; then
echo "Testsuite FAILED"
exit 1
fi
@@ -495,11 +478,6 @@ fi
%postun sysinit -p /sbin/ldconfig
%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150400
%posttrans
update-crypto-policies &> /dev/null || :
%endif
%files
%{_libdir}/libnss3.so
%{_libdir}/libnssutil3.so

BIN
nss-3.112.2.tar.gz LFS Normal file

Binary file not shown.

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:acef06b512d3bd81c87a63b3c8653d258bb689d2191fc0e64decf5a1efa01c0f
size 76625834

View File

@@ -726,7 +726,9 @@ Index: nss/lib/softoken/fips_algorithms.h
/* ------------------------- Hashing Operations ----------------------- */
{ CKM_SHA224, { 0, 0, CKF_HSH }, 1, SFTKFIPSNone },
{ CKM_SHA224_HMAC, { 112, 224, CKF_SGN }, 1, SFTKFIPSNone },
@@ -141,46 +192,88 @@ SFTKFIPSAlgorithmList sftk_fips_mechs[]
@@ -139,44 +190,86 @@ SFTKFIPSAlgorithmList sftk_fips_mechs[]
{ CKM_SHA512_HMAC, { 256, 512, CKF_SGN }, 1, SFTKFIPSNone },
{ CKM_SHA512_HMAC_GENERAL, { 256, 512, CKF_SGN }, 1, SFTKFIPSNone },
/* --------------------- Secret Key Operations ------------------------ */
- { CKM_GENERIC_SECRET_KEY_GEN, { 8, 256, CKF_GEN }, 1, SFTKFIPSNone },
+ { CKM_GENERIC_SECRET_KEY_GEN, { 112, 512, CKF_GEN }, 1, SFTKFIPSNone },
@@ -803,10 +805,6 @@ Index: nss/lib/softoken/fips_algorithms.h
+ { CKM_NSS_SP800_108_DOUBLE_PIPELINE_KDF_DERIVE_DATA, { 112, CK_MAX, CKF_KDF }, 1, SFTKFIPSChkHashSp800,
+ offsetof(CK_SP800_108_KDF_PARAMS, prfType) },
/* --------------------IPSEC ----------------------- */
{ CKM_IKE2_PRF_PLUS_DERIVE, { 8, 255 * 64, CKF_KDF }, 1, SFTKFIPSNone },
{ CKM_IKE_PRF_DERIVE, { 8, 64, CKF_KDF }, 1, SFTKFIPSNone },
{ CKM_IKE1_PRF_DERIVE, { 8, 64, CKF_KDF }, 1, SFTKFIPSNone },
{ CKM_IKE1_EXTENDED_DERIVE, { 8, 255 * 64, CKF_KDF }, 1, SFTKFIPSNone },
- { CKM_NSS_IKE_PRF_PLUS_DERIVE, { 8, 255 * 64, CKF_KDF }, 1, SFTKFIPSNone },
- { CKM_NSS_IKE_PRF_DERIVE, { 8, 64, CKF_KDF }, 1, SFTKFIPSNone },
- { CKM_NSS_IKE1_PRF_DERIVE, { 8, 64, CKF_KDF }, 1, SFTKFIPSNone },