re-introduce old nss im too tired for this

This commit is contained in:
wuggy 2026-06-30 06:37:32 +01:00
commit 3a838106b9
2871 changed files with 1374431 additions and 1762417 deletions

View file

@ -26,6 +26,8 @@ include $(CORE_DEPTH)/coreconf/config.mk
# (4) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
-include config.mk
#######################################################################
# (5) Execute "global" rules. (OPTIONAL) #
#######################################################################
@ -42,4 +44,5 @@ include $(CORE_DEPTH)/coreconf/rules.mk
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################
export:: private_export

View file

@ -1035,7 +1035,7 @@ CERT_CertChainFromCert(CERTCertificate *cert, SECCertUsage usage,
NSSCertificate *stanCert;
PLArenaPool *arena;
NSSUsage nssUsage;
int i = 0, len;
int i, len;
NSSTrustDomain *td = STAN_GetDefaultTrustDomain();
NSSCryptoContext *cc = STAN_GetDefaultCryptoContext();
@ -1072,6 +1072,7 @@ CERT_CertChainFromCert(CERTCertificate *cert, SECCertUsage usage,
chain->certs = (SECItem *)PORT_ArenaAlloc(arena, len * sizeof(SECItem));
if (!chain->certs)
goto loser;
i = 0;
stanCert = stanChain[i];
while (stanCert) {
SECItem derCert;
@ -1083,7 +1084,7 @@ CERT_CertChainFromCert(CERTCertificate *cert, SECCertUsage usage,
derCert.data = (unsigned char *)stanCert->encoding.data;
derCert.type = siBuffer;
if (SECITEM_CopyItem(arena, &chain->certs[i], &derCert) != SECSuccess) {
/* loser: will release stanChain[i]; don't release it here too. */
CERT_DestroyCertificate(cCert);
goto loser;
}
stanCert = stanChain[++i];
@ -1105,9 +1106,7 @@ CERT_CertChainFromCert(CERTCertificate *cert, SECCertUsage usage,
nss_ZFreeIf(stanChain);
return chain;
loser:
/* Release only the chain entries not already released by the copy
* loop above; entries 0..i-1 have already had their BuildChain
* reference dropped, so start at i to avoid an over-release. */
i = 0;
stanCert = stanChain[i];
while (stanCert) {
CERTCertificate *cCert = STAN_GetCERTCertificate(stanCert);

View file

@ -65,11 +65,14 @@ checkKeyParams(const SECAlgorithmID *sigAlgorithm, const SECKEYPublicKey *key)
!(policyFlags & NSS_USE_ALG_IN_CERT_SIGNATURE)) {
PORT_SetError(SEC_ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED);
return SECFailure;
} else {
return SECSuccess;
}
return SECSuccess;
} else {
PORT_SetError(SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE);
return SECFailure;
}
PORT_SetError(SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE);
return SECFailure;
return SECSuccess;
case SEC_OID_PKCS1_RSA_PSS_SIGNATURE: {
PORTCheapArenaPool tmpArena;
@ -462,7 +465,7 @@ static const unsigned char CAWoSignRootDN[72] = {
0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x43, 0x41, 0x20, 0x4C, 0x69, 0x6D,
0x69, 0x74, 0x65, 0x64, 0x31, 0x1B, 0x30, 0x19, 0x06, 0x03, 0x55, 0x04, 0x03,
0x0C, 0x12, 0x43, 0x41, 0x20, 0xE6, 0xB2, 0x83, 0xE9, 0x80, 0x9A, 0xE6, 0xA0,
0xB9, 0xE8, 0xAF, 0x81, 0xE4, 0xB9, 0xA6
0xB9, 0xE8, 0xAF, 0x81, 0xE4, 0xB9, 0xA6,
};
/* /C=CN/O=WoSign CA Limited/CN=CA WoSign ECC Root */
@ -472,7 +475,7 @@ static const unsigned char CAWoSignECCRootDN[72] = {
0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x43, 0x41, 0x20, 0x4C, 0x69, 0x6D,
0x69, 0x74, 0x65, 0x64, 0x31, 0x1B, 0x30, 0x19, 0x06, 0x03, 0x55, 0x04, 0x03,
0x13, 0x12, 0x43, 0x41, 0x20, 0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x45,
0x43, 0x43, 0x20, 0x52, 0x6F, 0x6F, 0x74
0x43, 0x43, 0x20, 0x52, 0x6F, 0x6F, 0x74,
};
/* /C=CN/O=WoSign CA Limited/CN=Certification Authority of WoSign */
@ -483,7 +486,7 @@ static const unsigned char CertificationAuthorityofWoSignDN[87] = {
0x69, 0x74, 0x65, 0x64, 0x31, 0x2A, 0x30, 0x28, 0x06, 0x03, 0x55, 0x04, 0x03,
0x13, 0x21, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
0x6F, 0x6E, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79, 0x20,
0x6F, 0x66, 0x20, 0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E
0x6F, 0x66, 0x20, 0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E,
};
/* /C=CN/O=WoSign CA Limited/CN=Certification Authority of WoSign G2 */
@ -494,7 +497,7 @@ static const unsigned char CertificationAuthorityofWoSignG2DN[90] = {
0x69, 0x74, 0x65, 0x64, 0x31, 0x2D, 0x30, 0x2B, 0x06, 0x03, 0x55, 0x04, 0x03,
0x13, 0x24, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
0x6F, 0x6E, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79, 0x20,
0x6F, 0x66, 0x20, 0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x47, 0x32
0x6F, 0x66, 0x20, 0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x47, 0x32,
};
/* /C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Certification Authority */
@ -508,7 +511,7 @@ static const unsigned char StartComCertificationAuthorityDN[127] = {
0x69, 0x67, 0x6E, 0x69, 0x6E, 0x67, 0x31, 0x29, 0x30, 0x27, 0x06, 0x03, 0x55,
0x04, 0x03, 0x13, 0x20, 0x53, 0x74, 0x61, 0x72, 0x74, 0x43, 0x6F, 0x6D, 0x20,
0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E,
0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79
0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79,
};
/* /C=IL/O=StartCom Ltd./CN=StartCom Certification Authority G2 */
@ -519,7 +522,7 @@ static const unsigned char StartComCertificationAuthorityG2DN[85] = {
0x31, 0x2C, 0x30, 0x2A, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x23, 0x53, 0x74,
0x61, 0x72, 0x74, 0x43, 0x6F, 0x6D, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66,
0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6F,
0x72, 0x69, 0x74, 0x79, 0x20, 0x47, 0x32
0x72, 0x69, 0x74, 0x79, 0x20, 0x47, 0x32,
};
struct DataAndLength {
@ -722,7 +725,7 @@ cert_VerifyCertChainOld(CERTCertDBHandle *handle, CERTCertificate *cert,
certsList = tmpCertsList;
}
for (i = 0; i < subjectNameListLen; i++) {
certsList[namesCount + i] = CERT_DupCertificate(subjectCert);
certsList[namesCount + i] = subjectCert;
}
namesCount += subjectNameListLen;
namesList = cert_CombineNamesLists(namesList, subjectNameList);
@ -734,16 +737,6 @@ cert_VerifyCertChainOld(CERTCertDBHandle *handle, CERTCertificate *cert,
LOG_ERROR_OR_EXIT(log, subjectCert, count, 0);
}
/* check that the signatureAlgorithm field of the certificate
* matches the signature field of the tbsCertificate */
if (SECOID_CompareAlgorithmID(
&subjectCert->signatureWrap.signatureAlgorithm,
&subjectCert->signature)) {
PORT_SetError(SEC_ERROR_ALGORITHM_MISMATCH);
LOG_ERROR(log, subjectCert, count, 0);
goto loser;
}
/* find the certificate of the issuer */
issuerCert = CERT_FindCertIssuer(subjectCert, t, certUsage);
if (!issuerCert) {
@ -979,11 +972,6 @@ loser:
rv = SECFailure;
done:
if (certsList != NULL) {
for (int i = 0; i < namesCount; i++) {
if (certsList[i]) {
CERT_DestroyCertificate(certsList[i]);
}
}
PORT_Free(certsList);
}
if (issuerCert) {
@ -1915,19 +1903,15 @@ CERT_GetCertNicknameWithValidity(PLArenaPool *arena, CERTCertificate *cert,
{
SECCertTimeValidity validity;
char *nickname = NULL, *tmpstr = NULL;
const char *srcNickname = cert->nickname;
if (!srcNickname) {
srcNickname = "{???}";
}
validity = CERT_CheckCertValidTimes(cert, PR_Now(), PR_FALSE);
/* if the cert is good, then just use the nickname directly */
if (validity == secCertTimeValid) {
if (arena == NULL) {
nickname = PORT_Strdup(srcNickname);
nickname = PORT_Strdup(cert->nickname);
} else {
nickname = PORT_ArenaStrdup(arena, srcNickname);
nickname = PORT_ArenaStrdup(arena, cert->nickname);
}
if (nickname == NULL) {
@ -1939,11 +1923,11 @@ CERT_GetCertNicknameWithValidity(PLArenaPool *arena, CERTCertificate *cert,
* end
*/
if (validity == secCertTimeExpired) {
tmpstr = PR_smprintf("%s%s", srcNickname,
tmpstr = PR_smprintf("%s%s", cert->nickname,
expiredString);
} else if (validity == secCertTimeNotValidYet) {
/* not yet valid */
tmpstr = PR_smprintf("%s%s", srcNickname,
tmpstr = PR_smprintf("%s%s", cert->nickname,
notYetGoodString);
} else {
/* undetermined */
@ -2138,7 +2122,6 @@ CERT_GetCertChainFromCert(CERTCertificate *cert, PRTime time, SECCertUsage usage
chain = CERT_NewCertList();
if (NULL == chain) {
CERT_DestroyCertificate(cert);
PORT_SetError(SEC_ERROR_NO_MEMORY);
return NULL;
}
@ -2146,7 +2129,6 @@ CERT_GetCertChainFromCert(CERTCertificate *cert, PRTime time, SECCertUsage usage
while (cert != NULL && ++count <= CERT_MAX_CERT_CHAIN) {
if (SECSuccess != CERT_AddCertToListTail(chain, cert)) {
/* return partial chain */
CERT_DestroyCertificate(cert);
PORT_SetError(SEC_ERROR_NO_MEMORY);
return chain;
}
@ -2160,7 +2142,6 @@ CERT_GetCertChainFromCert(CERTCertificate *cert, PRTime time, SECCertUsage usage
}
/* return partial chain */
CERT_DestroyCertificate(cert);
PORT_SetError(SEC_ERROR_UNKNOWN_ISSUER);
return chain;
}

View file

@ -411,7 +411,7 @@ cleanup:
static PKIX_Error *
cert_CreatePkixProcessingParams(
CERTCertificate *cert,
PRBool checkSig,
PRBool checkSig, /* not used yet. See bug 391476 */
PRTime time,
void *wincx,
PRBool useArena,
@ -441,12 +441,15 @@ cert_CreatePkixProcessingParams(
*pplContext = plContext;
#ifdef PKIX_NOTDEF
/* Functions should be implemented in patch for 390532 */
PKIX_CHECK(
pkix_pl_NssContext_SetCertSignatureCheck(checkSig,
(PKIX_PL_NssContext *)plContext),
PKIX_NSSCONTEXTSETCERTSIGNCHECKFAILED);
#endif /* PKIX_NOTDEF */
PKIX_CHECK(
PKIX_ProcessingParams_Create(&procParams, plContext),
PKIX_PROCESSINGPARAMSCREATEFAILED);
@ -817,8 +820,6 @@ cert_PkixErrorToNssCode(
void *plContext)
{
int errLevel = 0;
(void)errLevel; /* Suppress unused var warning (Bug 1738028) */
PKIX_Int32 nssErr = 0;
PKIX_Error *errPtr = error;
@ -835,9 +836,11 @@ cert_PkixErrorToNssCode(
}
if (pkixLog) {
#ifdef PKIX_ERROR_DESCRIPTION
PR_LOG(pkixLog, 2, ("Error at level %d: %s\n", errLevel, PKIX_ErrorText[errPtr->errCode]));
PR_LOG(pkixLog, 2, ("Error at level %d: %s\n", errLevel,
PKIX_ErrorText[errPtr->errCode]));
#else
PR_LOG(pkixLog, 2, ("Error at level %d: Error code %d\n", errLevel, errPtr->errCode));
PR_LOG(pkixLog, 2, ("Error at level %d: Error code %d\n", errLevel,
errPtr->errCode));
#endif /* PKIX_ERROR_DESCRIPTION */
}
errPtr = errPtr->cause;

View file

@ -0,0 +1,15 @@
#
# 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/.
#
# Override TARGETS variable so that only static libraries
# are specifed as dependencies within rules.mk.
#
TARGETS = $(LIBRARY)
SHARED_LIBRARY =
IMPORT_LIBRARY =
PROGRAM =

View file

@ -29,7 +29,6 @@ CSRCS = \
$(NULL)
LIBRARY_NAME = certhi
SHARED_LIBRARY = $(NULL)
# This part of the code, including all sub-dirs, can be optimized for size
export ALLOW_OPT_CODE_SIZE = 1

View file

@ -146,7 +146,8 @@ cert_DupOCSPCertID(const CERTOCSPCertID *src);
#define OCSP_TRACE_CERT(cert) dumpCertificate(cert)
#define OCSP_TRACE_CERTID(certid) dumpCertID(certid)
#if defined(XP_UNIX) || defined(XP_WIN32) || defined(XP_MACOSX)
#if defined(XP_UNIX) || defined(XP_WIN32) || defined(XP_BEOS) || \
defined(XP_MACOSX)
#define NSS_HAVE_GETENV 1
#endif
@ -2599,7 +2600,7 @@ ocsp_DecodeResponseBytes(PLArenaPool *arena, ocspResponseBytes *rbytes)
rbytes->decodedResponse.basic = basicResponse;
} break;
/*
/*
* Add new/future response types here.
*/