mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 23:37:33 +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
|
|
@ -1,4 +1,5 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
|
@ -7,9 +8,59 @@
|
|||
#include "libssl_internals.h"
|
||||
|
||||
#include "nss.h"
|
||||
#include "pk11hpke.h"
|
||||
#include "pk11pub.h"
|
||||
#include "pk11priv.h"
|
||||
#include "tls13ech.h"
|
||||
#include "seccomon.h"
|
||||
#include "selfencrypt.h"
|
||||
#include "secmodti.h"
|
||||
#include "sslproto.h"
|
||||
|
||||
SECStatus SSLInt_RemoveServerCertificates(PRFileDesc *fd) {
|
||||
if (!fd) {
|
||||
return SECFailure;
|
||||
}
|
||||
sslSocket *ss = ssl_FindSocket(fd);
|
||||
if (!ss) {
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
PRCList *cursor;
|
||||
while (!PR_CLIST_IS_EMPTY(&ss->serverCerts)) {
|
||||
cursor = PR_LIST_TAIL(&ss->serverCerts);
|
||||
PR_REMOVE_LINK(cursor);
|
||||
ssl_FreeServerCert((sslServerCert *)cursor);
|
||||
}
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
SECStatus SSLInt_SetDCAdvertisedSigSchemes(PRFileDesc *fd,
|
||||
const SSLSignatureScheme *schemes,
|
||||
uint32_t num_sig_schemes) {
|
||||
if (!fd) {
|
||||
return SECFailure;
|
||||
}
|
||||
sslSocket *ss = ssl_FindSocket(fd);
|
||||
if (!ss) {
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
// Alloc and copy, libssl will free.
|
||||
SSLSignatureScheme *dc_schemes =
|
||||
PORT_ZNewArray(SSLSignatureScheme, num_sig_schemes);
|
||||
if (!dc_schemes) {
|
||||
return SECFailure;
|
||||
}
|
||||
memcpy(dc_schemes, schemes, sizeof(SSLSignatureScheme) * num_sig_schemes);
|
||||
|
||||
if (ss->xtnData.delegCredSigSchemesAdvertised) {
|
||||
PORT_Free(ss->xtnData.delegCredSigSchemesAdvertised);
|
||||
}
|
||||
ss->xtnData.delegCredSigSchemesAdvertised = dc_schemes;
|
||||
ss->xtnData.numDelegCredSigSchemesAdvertised = num_sig_schemes;
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
SECStatus SSLInt_TweakChannelInfoForDC(PRFileDesc *fd, PRBool changeAuthKeyBits,
|
||||
PRBool changeScheme) {
|
||||
|
|
@ -96,6 +147,8 @@ PRBool SSLInt_ExtensionNegotiated(PRFileDesc *fd, PRUint16 ext) {
|
|||
return (PRBool)(ss && ssl3_ExtensionNegotiated(ss, ext));
|
||||
}
|
||||
|
||||
// Tests should not use this function directly, because the keys may
|
||||
// still be in cache. Instead, use TlsConnectTestBase::ClearServerCache.
|
||||
void SSLInt_ClearSelfEncryptKey() { ssl_ResetSelfEncryptKeys(); }
|
||||
|
||||
sslSelfEncryptKeys *ssl_GetSelfEncryptKeysInt();
|
||||
|
|
@ -303,6 +356,9 @@ SECStatus SSLInt_AdvanceReadSeqNum(PRFileDesc *fd, PRUint64 to) {
|
|||
|
||||
SECStatus SSLInt_AdvanceWriteSeqNum(PRFileDesc *fd, PRUint64 to) {
|
||||
sslSocket *ss;
|
||||
ssl3CipherSpec *spec;
|
||||
PK11Context *pk11ctxt;
|
||||
const ssl3BulkCipherDef *cipher_def;
|
||||
|
||||
ss = ssl_FindSocket(fd);
|
||||
if (!ss) {
|
||||
|
|
@ -313,7 +369,43 @@ SECStatus SSLInt_AdvanceWriteSeqNum(PRFileDesc *fd, PRUint64 to) {
|
|||
return SECFailure;
|
||||
}
|
||||
ssl_GetSpecWriteLock(ss);
|
||||
ss->ssl3.cwSpec->nextSeqNum = to;
|
||||
spec = ss->ssl3.cwSpec;
|
||||
cipher_def = spec->cipherDef;
|
||||
spec->nextSeqNum = to;
|
||||
if (cipher_def->type != type_aead) {
|
||||
ssl_ReleaseSpecWriteLock(ss);
|
||||
return SECSuccess;
|
||||
}
|
||||
/* If we are using aead, we need to advance the counter in the
|
||||
* internal IV generator as well.
|
||||
* This could be in the token or software. */
|
||||
pk11ctxt = spec->cipherContext;
|
||||
/* If counter is in the token, we need to switch it to software,
|
||||
* since we don't have access to the internal state of the token. We do
|
||||
* that by turning on the simulated message interface, then setting up the
|
||||
* software IV generator */
|
||||
if (pk11ctxt->ivCounter == 0) {
|
||||
_PK11_ContextSetAEADSimulation(pk11ctxt);
|
||||
pk11ctxt->ivLen = cipher_def->iv_size + cipher_def->explicit_nonce_size;
|
||||
pk11ctxt->ivMaxCount = PR_UINT64(0xffffffffffffffff);
|
||||
if ((cipher_def->explicit_nonce_size == 0) ||
|
||||
(spec->version >= SSL_LIBRARY_VERSION_TLS_1_3)) {
|
||||
pk11ctxt->ivFixedBits =
|
||||
(pk11ctxt->ivLen - sizeof(sslSequenceNumber)) * BPB;
|
||||
pk11ctxt->ivGen = CKG_GENERATE_COUNTER_XOR;
|
||||
} else {
|
||||
pk11ctxt->ivFixedBits = cipher_def->iv_size * BPB;
|
||||
pk11ctxt->ivGen = CKG_GENERATE_COUNTER;
|
||||
}
|
||||
/* DTLS included the epoch in the fixed portion of the IV */
|
||||
if (IS_DTLS(ss)) {
|
||||
pk11ctxt->ivFixedBits += 2 * BPB;
|
||||
}
|
||||
}
|
||||
/* now we can update the internal counter (either we are already using
|
||||
* the software IV generator, or we just switched to it above */
|
||||
pk11ctxt->ivCounter = to;
|
||||
|
||||
ssl_ReleaseSpecWriteLock(ss);
|
||||
return SECSuccess;
|
||||
}
|
||||
|
|
@ -332,6 +424,24 @@ SECStatus SSLInt_AdvanceWriteSeqByAWindow(PRFileDesc *fd, PRInt32 extra) {
|
|||
return SSLInt_AdvanceWriteSeqNum(fd, to);
|
||||
}
|
||||
|
||||
SECStatus SSLInt_AdvanceDtls13DecryptFailures(PRFileDesc *fd, PRUint64 to) {
|
||||
sslSocket *ss = ssl_FindSocket(fd);
|
||||
if (!ss) {
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
ssl_GetSpecWriteLock(ss);
|
||||
ssl3CipherSpec *spec = ss->ssl3.crSpec;
|
||||
if (spec->cipherDef->type != type_aead) {
|
||||
ssl_ReleaseSpecWriteLock(ss);
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
spec->deprotectionFailures = to;
|
||||
ssl_ReleaseSpecWriteLock(ss);
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
SSLKEAType SSLInt_GetKEAType(SSLNamedGroup group) {
|
||||
const sslNamedGroupDef *groupDef = ssl_LookupNamedGroup(group);
|
||||
if (!groupDef) return ssl_kea_null;
|
||||
|
|
@ -373,3 +483,19 @@ SECStatus SSLInt_HasPendingHandshakeData(PRFileDesc *fd, PRBool *pending) {
|
|||
ssl_ReleaseSSL3HandshakeLock(ss);
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
SECStatus SSLInt_SetRawEchConfigForRetry(PRFileDesc *fd, const uint8_t *buf,
|
||||
size_t len) {
|
||||
sslSocket *ss = ssl_FindSocket(fd);
|
||||
if (!ss) {
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
sslEchConfig *cfg = (sslEchConfig *)PR_LIST_HEAD(&ss->echConfigs);
|
||||
SECITEM_FreeItem(&cfg->raw, PR_FALSE);
|
||||
SECITEM_AllocItem(NULL, &cfg->raw, len);
|
||||
PORT_Memcpy(cfg->raw.data, buf, len);
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
PRBool SSLInt_IsIp(PRUint8 *s, unsigned int len) { return tls13_IsIp(s, len); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue