Replace NSS with Pale Moon's

This commit is contained in:
wuggy 2026-06-29 21:29:25 +01:00
commit 8c2e376f94
2870 changed files with 1762232 additions and 1374220 deletions

0
security/nss/cmd/signver/examples/1/form.pl Normal file → Executable file
View file

0
security/nss/cmd/signver/examples/1/signedForm.pl Normal file → Executable file
View file

View file

@ -156,7 +156,7 @@ sv_PrintAttribute(FILE *out, SEC_PKCS7Attribute *attr, char *m)
if (attr->values != NULL) {
i = 0;
while ((value = attr->values[i]) != NULL) {
sprintf(om, "%svalue[%d]=%s", m, i++, attr->encoded ? "(encoded)" : "");
snprintf(om, sizeof(om), "%svalue[%d]=%s", m, i++, attr->encoded ? "(encoded)" : "");
if (attr->encoded || attr->typeTag == NULL) {
sv_PrintAsHex(out, value, om);
} else {
@ -263,7 +263,7 @@ sv_PrintSignerInfo(FILE *out, SEC_PKCS7SignerInfo *info, char *m)
fprintf(out, "%sauthenticatedAttributes=%d\n", m, iv);
iv = 0;
while ((attr = info->authAttr[iv]) != NULL) {
sprintf(mm, "%sattribute[%d].", m, iv++);
snprintf(mm, sizeof(mm), "%sattribute[%d].", m, iv++);
sv_PrintAttribute(out, attr, mm);
}
}
@ -283,7 +283,7 @@ sv_PrintSignerInfo(FILE *out, SEC_PKCS7SignerInfo *info, char *m)
fprintf(out, "%sunauthenticatedAttributes=%d\n", m, iv);
iv = 0;
while ((attr = info->unAuthAttr[iv]) != NULL) {
sprintf(mm, "%sattribute[%d].", m, iv++);
snprintf(mm, sizeof(mm), "%sattribute[%d].", m, iv++);
sv_PrintAttribute(out, attr, mm);
}
}
@ -311,40 +311,75 @@ sv_PrintDSAPublicKey(FILE *out, SECKEYPublicKey *pk, char *m)
sv_PrintInteger(out, &pk->u.dsa.publicValue, "publicValue=");
}
void
sv_PrintECDSAPublicKey(FILE *out, SECKEYPublicKey *pk, char *m)
{
SECItem curve = { siBuffer, NULL, 0 };
if ((pk->u.ec.DEREncodedParams.len > 2) &&
(pk->u.ec.DEREncodedParams.data[0] == 0x06)) {
/* strip to just the oid for the curve */
curve.len = pk->u.ec.DEREncodedParams.data[1];
curve.data = pk->u.ec.DEREncodedParams.data + 2;
/* don't overflow the buffer */
curve.len = PR_MIN(curve.len, pk->u.ec.DEREncodedParams.len - 2);
fprintf(out, "%s", m);
sv_PrintObjectID(out, &curve, "curve=");
}
fprintf(out, "%s", m);
sv_PrintInteger(out, &pk->u.ec.publicValue, "publicValue=");
}
int
sv_PrintSubjectPublicKeyInfo(FILE *out, PLArenaPool *arena,
CERTSubjectPublicKeyInfo *i, char *msg)
{
SECKEYPublicKey *pk;
SECKEYPublicKey pk;
int rv;
char mm[200];
sprintf(mm, "%s.publicKeyAlgorithm=", msg);
snprintf(mm, sizeof(mm), "%s.publicKeyAlgorithm=", msg);
sv_PrintAlgorithmID(out, &i->algorithm, mm);
pk = (SECKEYPublicKey *)PORT_ZAlloc(sizeof(SECKEYPublicKey));
if (!pk)
return PORT_GetError();
DER_ConvertBitString(&i->subjectPublicKey);
switch (SECOID_FindOIDTag(&i->algorithm.algorithm)) {
case SEC_OID_PKCS1_RSA_ENCRYPTION:
rv = SEC_ASN1DecodeItem(arena, pk,
case SEC_OID_PKCS1_RSA_PSS_SIGNATURE:
rv = SEC_ASN1DecodeItem(arena, &pk,
SEC_ASN1_GET(SECKEY_RSAPublicKeyTemplate),
&i->subjectPublicKey);
if (rv)
return rv;
sprintf(mm, "%s.rsaPublicKey.", msg);
sv_PrintRSAPublicKey(out, pk, mm);
snprintf(mm, sizeof(mm), "%s.rsaPublicKey.", msg);
sv_PrintRSAPublicKey(out, &pk, mm);
break;
case SEC_OID_ANSIX9_DSA_SIGNATURE:
rv = SEC_ASN1DecodeItem(arena, pk,
rv = SEC_ASN1DecodeItem(arena, &pk,
SEC_ASN1_GET(SECKEY_DSAPublicKeyTemplate),
&i->subjectPublicKey);
if (rv)
return rv;
sprintf(mm, "%s.dsaPublicKey.", msg);
sv_PrintDSAPublicKey(out, pk, mm);
#ifdef notdef
/* SECKEY_PQGParamsTemplate is not yet exported form NSS */
rv = SEC_ASN1DecodeItem(arena, &pk.u.dsa.params,
SEC_ASN1_GET(SECKEY_PQGParamsTemplate),
&i->algorithm.parameters);
if (rv)
return rv;
#endif
snprintf(mm, sizeof(mm), "%s.dsaPublicKey.", msg);
sv_PrintDSAPublicKey(out, &pk, mm);
break;
case SEC_OID_ANSIX962_EC_PUBLIC_KEY:
rv = SECITEM_CopyItem(arena, &pk.u.ec.DEREncodedParams,
&i->algorithm.parameters);
if (rv)
return rv;
rv = SECITEM_CopyItem(arena, &pk.u.ec.publicValue,
&i->subjectPublicKey);
if (rv)
return rv;
snprintf(mm, sizeof(mm), "%s.ecdsaPublicKey.", msg);
sv_PrintECDSAPublicKey(out, &pk, mm);
break;
default:
fprintf(out, "%s=bad SPKI algorithm type\n", msg);
@ -443,11 +478,11 @@ sv_PrintCRLInfo(FILE *out, CERTCrl *crl, char *m)
sv_PrintInteger(out, &(entry->serialNumber), "serialNumber=");
fprintf(out, "%sentry[%d].", m, iv);
sv_PrintTime(out, &(entry->revocationDate), "revocationDate=");
sprintf(om, "%sentry[%d].signedCRLEntriesExtensions.", m, iv++);
snprintf(om, sizeof(om), "%sentry[%d].signedCRLEntriesExtensions.", m, iv++);
sv_PrintExtensions(out, entry->extensions, om);
}
}
sprintf(om, "%ssignedCRLEntriesExtensions.", m);
snprintf(om, sizeof(om), "%ssignedCRLEntriesExtensions.", m);
sv_PrintExtensions(out, crl->extensions, om);
}
@ -479,23 +514,23 @@ sv_PrintCertificate(FILE *out, SECItem *der, char *m, int level)
/* Pretty print it out */
iv = DER_GetInteger(&c->version);
fprintf(out, "%sversion=%d (0x%x)\n", m, iv + 1, iv);
sprintf(mm, "%sserialNumber=", m);
snprintf(mm, sizeof(mm), "%sserialNumber=", m);
sv_PrintInteger(out, &c->serialNumber, mm);
sprintf(mm, "%ssignatureAlgorithm=", m);
snprintf(mm, sizeof(mm), "%ssignatureAlgorithm=", m);
sv_PrintAlgorithmID(out, &c->signature, mm);
sprintf(mm, "%sissuerName=", m);
snprintf(mm, sizeof(mm), "%sissuerName=", m);
sv_PrintName(out, &c->issuer, mm);
sprintf(mm, "%svalidity.", m);
snprintf(mm, sizeof(mm), "%svalidity.", m);
sv_PrintValidity(out, &c->validity, mm);
sprintf(mm, "%ssubject=", m);
snprintf(mm, sizeof(mm), "%ssubject=", m);
sv_PrintName(out, &c->subject, mm);
sprintf(mm, "%ssubjectPublicKeyInfo", m);
snprintf(mm, sizeof(mm), "%ssubjectPublicKeyInfo", m);
rv = sv_PrintSubjectPublicKeyInfo(out, arena, &c->subjectPublicKeyInfo, mm);
if (rv) {
PORT_FreeArena(arena, PR_FALSE);
return rv;
}
sprintf(mm, "%ssignedExtensions.", m);
snprintf(mm, sizeof(mm), "%ssignedExtensions.", m);
sv_PrintExtensions(out, c->extensions, mm);
PORT_FreeArena(arena, PR_FALSE);
@ -569,7 +604,7 @@ sv_PrintPKCS7Signed(FILE *out, SEC_PKCS7SignedData *src)
fprintf(out, "pkcs7.digestAlgorithmListLength=%d\n", iv);
iv = 0;
while ((digAlg = src->digestAlgorithms[iv]) != NULL) {
sprintf(om, "pkcs7.digestAlgorithm[%d]=", iv++);
snprintf(om, sizeof(om), "pkcs7.digestAlgorithm[%d]=", iv++);
sv_PrintAlgorithmID(out, digAlg, om);
}
}
@ -589,7 +624,7 @@ sv_PrintPKCS7Signed(FILE *out, SEC_PKCS7SignedData *src)
iv = 0;
while ((aCert = src->rawCerts[iv]) != NULL) {
sprintf(om, "certificate[%d].", iv++);
snprintf(om, sizeof(om), "certificate[%d].", iv++);
rv = sv_PrintSignedData(out, aCert, om, sv_PrintCertificate);
if (rv)
return rv;
@ -604,14 +639,14 @@ sv_PrintPKCS7Signed(FILE *out, SEC_PKCS7SignedData *src)
fprintf(out, "pkcs7.signedRevocationLists=%d\n", iv);
iv = 0;
while ((aCrl = src->crls[iv]) != NULL) {
sprintf(om, "signedRevocationList[%d].", iv);
snprintf(om, sizeof(om), "signedRevocationList[%d].", iv);
fprintf(out, "%s", om);
sv_PrintAlgorithmID(out, &aCrl->signatureWrap.signatureAlgorithm,
"signatureAlgorithm=");
DER_ConvertBitString(&aCrl->signatureWrap.signature);
fprintf(out, "%s", om);
sv_PrintAsHex(out, &aCrl->signatureWrap.signature, "signature=");
sprintf(om, "certificateRevocationList[%d].", iv);
snprintf(om, sizeof(om), "certificateRevocationList[%d].", iv);
sv_PrintCRLInfo(out, &aCrl->crl, om);
iv++;
}
@ -625,7 +660,7 @@ sv_PrintPKCS7Signed(FILE *out, SEC_PKCS7SignedData *src)
fprintf(out, "pkcs7.signerInformationListLength=%d\n", iv);
iv = 0;
while ((sigInfo = src->signerInfos[iv]) != NULL) {
sprintf(om, "signerInformation[%d].", iv++);
snprintf(om, sizeof(om), "signerInformation[%d].", iv++);
sv_PrintSignerInfo(out, sigInfo, om);
}
}
@ -655,7 +690,7 @@ secu_PrintPKCS7Enveloped(FILE *out, SEC_PKCS7EnvelopedData *src,
fprintf(out, "Recipient Information List:\n");
iv = 0;
while ((recInfo = src->recipientInfos[iv++]) != NULL) {
sprintf(om, "Recipient Information (%x)", iv);
snprintf(om, sizeof(om), "Recipient Information (%x)", iv);
secu_PrintRecipientInfo(out, recInfo, om, level + 2);
}
}
@ -690,7 +725,7 @@ secu_PrintPKCS7SignedAndEnveloped(FILE *out,
fprintf(out, "Recipient Information List:\n");
iv = 0;
while ((recInfo = src->recipientInfos[iv++]) != NULL) {
sprintf(om, "Recipient Information (%x)", iv);
snprintf(om, sizeof(om), "Recipient Information (%x)", iv);
secu_PrintRecipientInfo(out, recInfo, om, level + 2);
}
}
@ -700,7 +735,7 @@ secu_PrintPKCS7SignedAndEnveloped(FILE *out,
secu_Indent(out, level + 1); fprintf(out, "Digest Algorithm List:\n");
iv = 0;
while ((digAlg = src->digestAlgorithms[iv++]) != NULL) {
sprintf(om, "Digest Algorithm (%x)", iv);
snprintf(om, sizeof(om), "Digest Algorithm (%x)", iv);
sv_PrintAlgorithmID(out, digAlg, om);
}
}
@ -713,7 +748,7 @@ secu_PrintPKCS7SignedAndEnveloped(FILE *out,
secu_Indent(out, level + 1); fprintf(out, "Certificate List:\n");
iv = 0;
while ((aCert = src->rawCerts[iv++]) != NULL) {
sprintf(om, "Certificate (%x)", iv);
snprintf(om, sizeof(om), "Certificate (%x)", iv);
rv = SECU_PrintSignedData(out, aCert, om, level + 2,
SECU_PrintCertificate);
if (rv)
@ -727,7 +762,7 @@ secu_PrintPKCS7SignedAndEnveloped(FILE *out,
fprintf(out, "Signed Revocation Lists:\n");
iv = 0;
while ((aCrl = src->crls[iv++]) != NULL) {
sprintf(om, "Signed Revocation List (%x)", iv);
snprintf(om, sizeof(om), "Signed Revocation List (%x)", iv);
secu_Indent(out, level + 2); fprintf(out, "%s:\n", om);
sv_PrintAlgorithmID(out, &aCrl->signatureWrap.signatureAlgorithm,
"Signature Algorithm");
@ -745,7 +780,7 @@ secu_PrintPKCS7SignedAndEnveloped(FILE *out,
fprintf(out, "Signer Information List:\n");
iv = 0;
while ((sigInfo = src->signerInfos[iv++]) != NULL) {
sprintf(om, "Signer Information (%x)", iv);
snprintf(om, sizeof(om), "Signer Information (%x)", iv);
secu_PrintSignerInfo(out, sigInfo, om, level + 2);
}
}

View file

@ -90,22 +90,20 @@ enum {
opt_DebugInfo
};
static secuCommandFlag signver_commands[] =
{
{ /* cmd_DisplayAllPCKS7Info*/ 'A', PR_FALSE, 0, PR_FALSE },
{ /* cmd_VerifySignedObj */ 'V', PR_FALSE, 0, PR_FALSE }
};
static secuCommandFlag signver_commands[] = {
{ /* cmd_DisplayAllPCKS7Info*/ 'A', PR_FALSE, 0, PR_FALSE },
{ /* cmd_VerifySignedObj */ 'V', PR_FALSE, 0, PR_FALSE }
};
static secuCommandFlag signver_options[] =
{
{ /* opt_ASCII */ 'a', PR_FALSE, 0, PR_FALSE },
{ /* opt_CertDir */ 'd', PR_TRUE, 0, PR_FALSE },
{ /* opt_InputDataFile */ 'i', PR_TRUE, 0, PR_FALSE },
{ /* opt_OutputFile */ 'o', PR_TRUE, 0, PR_FALSE },
{ /* opt_InputSigFile */ 's', PR_TRUE, 0, PR_FALSE },
{ /* opt_PrintWhyFailure */ 'v', PR_FALSE, 0, PR_FALSE },
{ /* opt_DebugInfo */ 0, PR_FALSE, 0, PR_FALSE, "debug" }
};
static secuCommandFlag signver_options[] = {
{ /* opt_ASCII */ 'a', PR_FALSE, 0, PR_FALSE },
{ /* opt_CertDir */ 'd', PR_TRUE, 0, PR_FALSE },
{ /* opt_InputDataFile */ 'i', PR_TRUE, 0, PR_FALSE },
{ /* opt_OutputFile */ 'o', PR_TRUE, 0, PR_FALSE },
{ /* opt_InputSigFile */ 's', PR_TRUE, 0, PR_FALSE },
{ /* opt_PrintWhyFailure */ 'v', PR_FALSE, 0, PR_FALSE },
{ /* opt_DebugInfo */ 0, PR_FALSE, 0, PR_FALSE, "debug" }
};
int
main(int argc, char **argv)