mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 01:08:39 +09:00
update NSS as-of pm27 rev 7606140ee
This commit is contained in:
parent
eeb44de4a1
commit
8015bb7004
24 changed files with 1005 additions and 1400 deletions
|
|
@ -19,7 +19,7 @@ pushd gyp
|
|||
python -m virtualenv test-env
|
||||
test-env/Scripts/python setup.py install
|
||||
test-env/Scripts/python -m pip install --upgrade pip
|
||||
test-env/Scripts/pip install --upgrade setuptools
|
||||
test-env/Scripts/pip install --upgrade 'setuptools<45.0.0'
|
||||
# Fool GYP.
|
||||
touch "${VSPATH}/VC/vcvarsall.bat"
|
||||
export GYP_MSVS_OVERRIDE_PATH="${VSPATH}"
|
||||
|
|
|
|||
|
|
@ -494,23 +494,30 @@ SECU_ReadDERFromFile(SECItem *der, PRFileDesc *inFile, PRBool ascii,
|
|||
if (ascii) {
|
||||
/* First convert ascii to binary */
|
||||
SECItem filedata;
|
||||
char *asc, *body;
|
||||
|
||||
/* Read in ascii data */
|
||||
rv = SECU_FileToItem(&filedata, inFile);
|
||||
if (rv != SECSuccess)
|
||||
return rv;
|
||||
asc = (char *)filedata.data;
|
||||
if (!asc) {
|
||||
if (!filedata.data) {
|
||||
fprintf(stderr, "unable to read data from input file\n");
|
||||
return SECFailure;
|
||||
}
|
||||
/* need one additional byte for zero terminator */
|
||||
rv = SECITEM_ReallocItemV2(NULL, &filedata, filedata.len + 1);
|
||||
if (rv != SECSuccess) {
|
||||
PORT_Free(filedata.data);
|
||||
return rv;
|
||||
}
|
||||
char *asc = (char *)filedata.data;
|
||||
asc[filedata.len - 1] = '\0';
|
||||
|
||||
if (warnOnPrivateKeyInAsciiFile && strstr(asc, "PRIVATE KEY")) {
|
||||
fprintf(stderr, "Warning: ignoring private key. Consider to use "
|
||||
"pk12util.\n");
|
||||
}
|
||||
|
||||
char *body;
|
||||
/* check for headers and trailers and remove them */
|
||||
if ((body = strstr(asc, "-----BEGIN")) != NULL) {
|
||||
char *trailer = NULL;
|
||||
|
|
@ -528,14 +535,7 @@ SECU_ReadDERFromFile(SECItem *der, PRFileDesc *inFile, PRBool ascii,
|
|||
return SECFailure;
|
||||
}
|
||||
} else {
|
||||
/* need one additional byte for zero terminator */
|
||||
rv = SECITEM_ReallocItemV2(NULL, &filedata, filedata.len + 1);
|
||||
if (rv != SECSuccess) {
|
||||
PORT_Free(filedata.data);
|
||||
return rv;
|
||||
}
|
||||
body = (char *)filedata.data;
|
||||
body[filedata.len - 1] = '\0';
|
||||
body = asc;
|
||||
}
|
||||
|
||||
/* Convert to binary */
|
||||
|
|
|
|||
|
|
@ -88,11 +88,14 @@ endif
|
|||
OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -fno-common -pipe -DDARWIN -DHAVE_STRERROR -DHAVE_BSD_FLOCK $(DARWIN_SDK_CFLAGS)
|
||||
|
||||
ifdef BUILD_OPT
|
||||
ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE))
|
||||
OPTIMIZER = -Oz
|
||||
else
|
||||
OPTIMIZER = -O2
|
||||
endif
|
||||
|
||||
# TenFourFox overrides optimization settings; let it.
|
||||
#ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE))
|
||||
# OPTIMIZER = -Oz
|
||||
#else
|
||||
# OPTIMIZER = -O2
|
||||
#endif
|
||||
|
||||
ifdef MOZ_DEBUG_SYMBOLS
|
||||
ifdef MOZ_DEBUG_FLAGS
|
||||
OPTIMIZER += $(MOZ_DEBUG_FLAGS)
|
||||
|
|
@ -104,6 +107,13 @@ endif
|
|||
|
||||
ARCH = darwin
|
||||
|
||||
#fix missing libmozglue.dylib on TenFourFox Intel build
|
||||
ifeq ($(CPU_ARCH), x86)
|
||||
EXTRA_SHARED_LIBS += \
|
||||
-L$(DIST)/bin \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
DSO_CFLAGS = -fPIC
|
||||
# May override this with different compatibility and current version numbers.
|
||||
DARWIN_DYLIB_VERSIONS = -compatibility_version 1 -current_version 1
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ endif
|
|||
|
||||
RANLIB = echo
|
||||
CPU_ARCH = sparc
|
||||
OS_DEFINES += -DSVR4 -DSYSV -D__svr4 -D__svr4__ -DSOLARIS -D_REENTRANT -D__EXTENSIONS__
|
||||
OS_DEFINES += -DSVR4 -DSYSV -D__svr4 -D__svr4__ -DSOLARIS -D_REENTRANT
|
||||
|
||||
ifeq ($(OS_TEST),i86pc)
|
||||
ifeq ($(USE_64),1)
|
||||
|
|
|
|||
|
|
@ -113,6 +113,18 @@ TEST_F(Blake2BTests, ContextTest2) {
|
|||
<< "BLAKE2B_End failed!";
|
||||
}
|
||||
|
||||
TEST_F(Blake2BTests, NullContextTest) {
|
||||
SECStatus rv = BLAKE2B_Begin(nullptr);
|
||||
ASSERT_EQ(SECFailure, rv);
|
||||
|
||||
rv = BLAKE2B_Update(nullptr, kat_data.data(), 128);
|
||||
ASSERT_EQ(SECFailure, rv);
|
||||
|
||||
std::vector<uint8_t> digest(BLAKE2B512_LENGTH);
|
||||
rv = BLAKE2B_End(nullptr, digest.data(), nullptr, BLAKE2B512_LENGTH);
|
||||
ASSERT_EQ(SECFailure, rv);
|
||||
}
|
||||
|
||||
TEST_F(Blake2BTests, CloneTest) {
|
||||
ScopedBLAKE2BContext ctx(BLAKE2B_NewContext());
|
||||
ScopedBLAKE2BContext cloned_ctx(BLAKE2B_NewContext());
|
||||
|
|
|
|||
|
|
@ -838,7 +838,7 @@ TEST_F(TlsConnectTest, TestTls13ResumptionDuplicateNST) {
|
|||
|
||||
// Clear the session ticket keys to invalidate the old ticket.
|
||||
SSLInt_ClearSelfEncryptKey();
|
||||
SSL_SendSessionTicket(server_->ssl_fd(), NULL, 0);
|
||||
EXPECT_EQ(SECSuccess, SSL_SendSessionTicket(server_->ssl_fd(), NULL, 0));
|
||||
|
||||
SendReceive(); // Need to read so that we absorb the session tickets.
|
||||
CheckKeys();
|
||||
|
|
@ -1005,7 +1005,8 @@ TEST_F(TlsConnectStreamTls13, ExternalResumptionUseSecondTicket) {
|
|||
state->invoked++;
|
||||
return SECSuccess;
|
||||
};
|
||||
SSL_SetResumptionTokenCallback(client_->ssl_fd(), cb, &ticket_state);
|
||||
EXPECT_EQ(SECSuccess, SSL_SetResumptionTokenCallback(client_->ssl_fd(), cb,
|
||||
&ticket_state));
|
||||
|
||||
Connect();
|
||||
EXPECT_EQ(SECSuccess, SSL_SendSessionTicket(server_->ssl_fd(), nullptr, 0));
|
||||
|
|
@ -1446,4 +1447,34 @@ TEST_F(TlsConnectStreamTls13, ExternalTokenAfterHrr) {
|
|||
SendReceive();
|
||||
}
|
||||
|
||||
TEST_F(TlsConnectStreamTls13, ExternalTokenWithPeerId) {
|
||||
ConfigureSessionCache(RESUME_BOTH, RESUME_BOTH);
|
||||
ConfigureVersion(SSL_LIBRARY_VERSION_TLS_1_3);
|
||||
EXPECT_EQ(SECSuccess, SSL_SetSockPeerID(client_->ssl_fd(), "testPeerId"));
|
||||
std::vector<uint8_t> ticket_state;
|
||||
auto cb = [](PRFileDesc* fd, const PRUint8* ticket, unsigned int ticket_len,
|
||||
void* arg) -> SECStatus {
|
||||
EXPECT_NE(0U, ticket_len);
|
||||
EXPECT_NE(nullptr, ticket);
|
||||
auto ticket_state_ = reinterpret_cast<std::vector<uint8_t>*>(arg);
|
||||
ticket_state_->assign(ticket, ticket + ticket_len);
|
||||
return SECSuccess;
|
||||
};
|
||||
EXPECT_EQ(SECSuccess, SSL_SetResumptionTokenCallback(client_->ssl_fd(), cb,
|
||||
&ticket_state));
|
||||
|
||||
Connect();
|
||||
SendReceive();
|
||||
EXPECT_NE(0U, ticket_state.size());
|
||||
|
||||
Reset();
|
||||
ConfigureSessionCache(RESUME_BOTH, RESUME_BOTH);
|
||||
EXPECT_EQ(SECSuccess, SSL_SetSockPeerID(client_->ssl_fd(), "testPeerId"));
|
||||
client_->SetResumptionToken(ticket_state);
|
||||
ASSERT_TRUE(client_->MaybeSetResumptionToken());
|
||||
ExpectResumption(RESUME_TICKET);
|
||||
Connect();
|
||||
SendReceive();
|
||||
}
|
||||
|
||||
} // namespace nss_test
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -46,8 +46,8 @@
|
|||
* It's recommend to switch back to 0 after having reached version 98/99.
|
||||
*/
|
||||
#define NSS_BUILTINS_LIBRARY_VERSION_MAJOR 2
|
||||
#define NSS_BUILTINS_LIBRARY_VERSION_MINOR 40
|
||||
#define NSS_BUILTINS_LIBRARY_VERSION "2.40"
|
||||
#define NSS_BUILTINS_LIBRARY_VERSION_MINOR 42
|
||||
#define NSS_BUILTINS_LIBRARY_VERSION "2.42"
|
||||
|
||||
/* These version numbers detail the semantic changes to the ckfw engine. */
|
||||
#define NSS_BUILTINS_HARDWARE_VERSION_MAJOR 1
|
||||
|
|
|
|||
|
|
@ -155,3 +155,30 @@ rijndael_native_encryptBlock(AESContext *cx,
|
|||
m = _mm_aesenclast_si128(m, cx->k.keySchedule[cx->Nr]);
|
||||
_mm_storeu_si128((__m128i *)output, m);
|
||||
}
|
||||
|
||||
void
|
||||
rijndael_native_decryptBlock(AESContext *cx,
|
||||
unsigned char *output,
|
||||
const unsigned char *input)
|
||||
{
|
||||
int i;
|
||||
pre_align __m128i m post_align = _mm_loadu_si128((__m128i *)input);
|
||||
m = _mm_xor_si128(m, cx->k.keySchedule[cx->Nr]);
|
||||
for (i = cx->Nr - 1; i > 0; --i) {
|
||||
m = _mm_aesdec_si128(m, cx->k.keySchedule[i]);
|
||||
}
|
||||
m = _mm_aesdeclast_si128(m, cx->k.keySchedule[0]);
|
||||
_mm_storeu_si128((__m128i *)output, m);
|
||||
}
|
||||
|
||||
// out = a ^ b
|
||||
void
|
||||
native_xorBlock(unsigned char *out,
|
||||
const unsigned char *a,
|
||||
const unsigned char *b)
|
||||
{
|
||||
pre_align __m128i post_align in1 = _mm_loadu_si128((__m128i *)(a));
|
||||
pre_align __m128i post_align in2 = _mm_loadu_si128((__m128i *)(b));
|
||||
in1 = _mm_xor_si128(in1, in2);
|
||||
_mm_storeu_si128((__m128i *)(out), in1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,9 +147,8 @@ static SECStatus
|
|||
blake2b_Begin(BLAKE2BContext* ctx, uint8_t outlen, const uint8_t* key,
|
||||
size_t keylen)
|
||||
{
|
||||
PORT_Assert(ctx != NULL);
|
||||
if (!ctx) {
|
||||
goto failure;
|
||||
goto failure_noclean;
|
||||
}
|
||||
if (outlen == 0 || outlen > BLAKE2B512_LENGTH) {
|
||||
goto failure;
|
||||
|
|
@ -181,6 +180,7 @@ blake2b_Begin(BLAKE2BContext* ctx, uint8_t outlen, const uint8_t* key,
|
|||
|
||||
failure:
|
||||
PORT_Memset(ctx, 0, sizeof(*ctx));
|
||||
failure_noclean:
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return SECFailure;
|
||||
}
|
||||
|
|
@ -218,17 +218,11 @@ SECStatus
|
|||
BLAKE2B_Update(BLAKE2BContext* ctx, const unsigned char* in,
|
||||
unsigned int inlen)
|
||||
{
|
||||
size_t left = ctx->buflen;
|
||||
size_t fill = BLAKE2B_BLOCK_LENGTH - left;
|
||||
|
||||
/* Nothing to do if there's nothing. */
|
||||
if (inlen == 0) {
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
PORT_Assert(ctx != NULL);
|
||||
PORT_Assert(in != NULL);
|
||||
PORT_Assert(left <= BLAKE2B_BLOCK_LENGTH);
|
||||
if (!ctx || !in) {
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return SECFailure;
|
||||
|
|
@ -240,6 +234,10 @@ BLAKE2B_Update(BLAKE2BContext* ctx, const unsigned char* in,
|
|||
return SECFailure;
|
||||
}
|
||||
|
||||
size_t left = ctx->buflen;
|
||||
PORT_Assert(left <= BLAKE2B_BLOCK_LENGTH);
|
||||
size_t fill = BLAKE2B_BLOCK_LENGTH - left;
|
||||
|
||||
if (inlen > fill) {
|
||||
if (ctx->buflen) {
|
||||
/* There's some remaining data in ctx->buf that we have to prepend
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ struct CMACContextStr {
|
|||
* add a new Context pointer to the cipher union with the correct type. */
|
||||
CMACCipher cipherType;
|
||||
union {
|
||||
AESContext aes;
|
||||
AESContext *aes;
|
||||
} cipher;
|
||||
int blockSize;
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ cmac_Encrypt(CMACContext *ctx, unsigned char *output,
|
|||
{
|
||||
if (ctx->cipherType == CMAC_AES) {
|
||||
unsigned int tmpOutputLen;
|
||||
SECStatus rv = AES_Encrypt(&ctx->cipher.aes, output, &tmpOutputLen,
|
||||
SECStatus rv = AES_Encrypt(ctx->cipher.aes, output, &tmpOutputLen,
|
||||
ctx->blockSize, input, inputLen);
|
||||
|
||||
/* Assumption: AES_Encrypt (when in ECB mode) always returns an
|
||||
|
|
@ -156,8 +156,9 @@ CMAC_Init(CMACContext *ctx, CMACCipher type,
|
|||
|
||||
ctx->blockSize = AES_BLOCK_SIZE;
|
||||
ctx->cipherType = CMAC_AES;
|
||||
if (AES_InitContext(&ctx->cipher.aes, key, key_len, NULL, NSS_AES, 1,
|
||||
ctx->blockSize) != SECSuccess) {
|
||||
ctx->cipher.aes = AES_CreateContext(key, NULL, NSS_AES, 1, key_len,
|
||||
ctx->blockSize);
|
||||
if (ctx->cipher.aes == NULL) {
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
|
|
@ -308,8 +309,8 @@ CMAC_Destroy(CMACContext *ctx, PRBool free_it)
|
|||
return;
|
||||
}
|
||||
|
||||
if (ctx->cipherType == CMAC_AES) {
|
||||
AES_DestroyContext(&ctx->cipher.aes, PR_FALSE);
|
||||
if (ctx->cipherType == CMAC_AES && ctx->cipher.aes != NULL) {
|
||||
AES_DestroyContext(ctx->cipher.aes, PR_TRUE);
|
||||
}
|
||||
|
||||
/* Destroy everything in the context. This includes sensitive data in
|
||||
|
|
|
|||
|
|
@ -37,12 +37,24 @@
|
|||
#include "intel-gcm.h"
|
||||
#endif /* INTEL_GCM */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER < 1900
|
||||
#define inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
void rijndael_native_key_expansion(AESContext *cx, const unsigned char *key,
|
||||
unsigned int Nk);
|
||||
void rijndael_native_encryptBlock(AESContext *cx,
|
||||
unsigned char *output,
|
||||
const unsigned char *input);
|
||||
void rijndael_native_decryptBlock(AESContext *cx,
|
||||
unsigned char *output,
|
||||
const unsigned char *input);
|
||||
void native_xorBlock(unsigned char *out,
|
||||
const unsigned char *a,
|
||||
const unsigned char *b);
|
||||
|
||||
/* Stub definitions for the above rijndael_native_* functions, which
|
||||
* shouldn't be used unless NSS_X86_OR_X64 is defined */
|
||||
|
|
@ -63,6 +75,23 @@ rijndael_native_encryptBlock(AESContext *cx,
|
|||
PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
|
||||
PORT_Assert(0);
|
||||
}
|
||||
|
||||
void
|
||||
rijndael_native_decryptBlock(AESContext *cx,
|
||||
unsigned char *output,
|
||||
const unsigned char *input)
|
||||
{
|
||||
PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
|
||||
PORT_Assert(0);
|
||||
}
|
||||
|
||||
void
|
||||
native_xorBlock(unsigned char *out, const unsigned char *a,
|
||||
const unsigned char *b)
|
||||
{
|
||||
PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
|
||||
PORT_Assert(0);
|
||||
}
|
||||
#endif /* NSS_X86_OR_X64 */
|
||||
|
||||
/*
|
||||
|
|
@ -510,6 +539,15 @@ typedef union {
|
|||
|
||||
#define STATE_BYTE(i) state.b[i]
|
||||
|
||||
// out = a ^ b
|
||||
inline static void
|
||||
xorBlock(unsigned char *out, const unsigned char *a, const unsigned char *b)
|
||||
{
|
||||
for (unsigned int j = 0; j < AES_BLOCK_SIZE; ++j) {
|
||||
(out)[j] = (a)[j] ^ (b)[j];
|
||||
}
|
||||
}
|
||||
|
||||
static void NO_SANITIZE_ALIGNMENT
|
||||
rijndael_encryptBlock128(AESContext *cx,
|
||||
unsigned char *output,
|
||||
|
|
@ -605,7 +643,7 @@ rijndael_encryptBlock128(AESContext *cx,
|
|||
#endif
|
||||
}
|
||||
|
||||
static SECStatus NO_SANITIZE_ALIGNMENT
|
||||
static void NO_SANITIZE_ALIGNMENT
|
||||
rijndael_decryptBlock128(AESContext *cx,
|
||||
unsigned char *output,
|
||||
const unsigned char *input)
|
||||
|
|
@ -694,7 +732,6 @@ rijndael_decryptBlock128(AESContext *cx,
|
|||
memcpy(output, outBuf, sizeof outBuf);
|
||||
}
|
||||
#endif
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
|
@ -708,16 +745,13 @@ rijndael_encryptECB(AESContext *cx, unsigned char *output,
|
|||
unsigned int *outputLen, unsigned int maxOutputLen,
|
||||
const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
AESBlockFunc *encryptor;
|
||||
|
||||
if (aesni_support()) {
|
||||
/* Use hardware acceleration for normal AES parameters. */
|
||||
encryptor = &rijndael_native_encryptBlock;
|
||||
} else {
|
||||
encryptor = &rijndael_encryptBlock128;
|
||||
}
|
||||
PRBool aesni = aesni_support();
|
||||
while (inputLen > 0) {
|
||||
(*encryptor)(cx, output, input);
|
||||
if (aesni) {
|
||||
rijndael_native_encryptBlock(cx, output, input);
|
||||
} else {
|
||||
rijndael_encryptBlock128(cx, output, input);
|
||||
}
|
||||
output += AES_BLOCK_SIZE;
|
||||
input += AES_BLOCK_SIZE;
|
||||
inputLen -= AES_BLOCK_SIZE;
|
||||
|
|
@ -730,20 +764,23 @@ rijndael_encryptCBC(AESContext *cx, unsigned char *output,
|
|||
unsigned int *outputLen, unsigned int maxOutputLen,
|
||||
const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
unsigned int j;
|
||||
unsigned char *lastblock;
|
||||
unsigned char *lastblock = cx->iv;
|
||||
unsigned char inblock[AES_BLOCK_SIZE * 8];
|
||||
PRBool aesni = aesni_support();
|
||||
|
||||
if (!inputLen)
|
||||
return SECSuccess;
|
||||
lastblock = cx->iv;
|
||||
while (inputLen > 0) {
|
||||
/* XOR with the last block (IV if first block) */
|
||||
for (j = 0; j < AES_BLOCK_SIZE; ++j) {
|
||||
inblock[j] = input[j] ^ lastblock[j];
|
||||
if (aesni) {
|
||||
/* XOR with the last block (IV if first block) */
|
||||
native_xorBlock(inblock, input, lastblock);
|
||||
/* encrypt */
|
||||
rijndael_native_encryptBlock(cx, output, inblock);
|
||||
} else {
|
||||
xorBlock(inblock, input, lastblock);
|
||||
rijndael_encryptBlock128(cx, output, inblock);
|
||||
}
|
||||
/* encrypt */
|
||||
rijndael_encryptBlock128(cx, output, inblock);
|
||||
|
||||
/* move to the next block */
|
||||
lastblock = output;
|
||||
output += AES_BLOCK_SIZE;
|
||||
|
|
@ -759,9 +796,12 @@ rijndael_decryptECB(AESContext *cx, unsigned char *output,
|
|||
unsigned int *outputLen, unsigned int maxOutputLen,
|
||||
const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
PRBool aesni = aesni_support();
|
||||
while (inputLen > 0) {
|
||||
if (rijndael_decryptBlock128(cx, output, input) != SECSuccess) {
|
||||
return SECFailure;
|
||||
if (aesni) {
|
||||
rijndael_native_decryptBlock(cx, output, input);
|
||||
} else {
|
||||
rijndael_decryptBlock128(cx, output, input);
|
||||
}
|
||||
output += AES_BLOCK_SIZE;
|
||||
input += AES_BLOCK_SIZE;
|
||||
|
|
@ -777,8 +817,8 @@ rijndael_decryptCBC(AESContext *cx, unsigned char *output,
|
|||
{
|
||||
const unsigned char *in;
|
||||
unsigned char *out;
|
||||
unsigned int j;
|
||||
unsigned char newIV[AES_BLOCK_SIZE];
|
||||
PRBool aesni = aesni_support();
|
||||
|
||||
if (!inputLen)
|
||||
return SECSuccess;
|
||||
|
|
@ -787,21 +827,26 @@ rijndael_decryptCBC(AESContext *cx, unsigned char *output,
|
|||
memcpy(newIV, in, AES_BLOCK_SIZE);
|
||||
out = output + (inputLen - AES_BLOCK_SIZE);
|
||||
while (inputLen > AES_BLOCK_SIZE) {
|
||||
if (rijndael_decryptBlock128(cx, out, in) != SECSuccess) {
|
||||
return SECFailure;
|
||||
if (aesni) {
|
||||
// Use hardware acceleration for normal AES parameters.
|
||||
rijndael_native_decryptBlock(cx, out, in);
|
||||
native_xorBlock(out, out, &in[-AES_BLOCK_SIZE]);
|
||||
} else {
|
||||
rijndael_decryptBlock128(cx, out, in);
|
||||
xorBlock(out, out, &in[-AES_BLOCK_SIZE]);
|
||||
}
|
||||
for (j = 0; j < AES_BLOCK_SIZE; ++j)
|
||||
out[j] ^= in[(int)(j - AES_BLOCK_SIZE)];
|
||||
out -= AES_BLOCK_SIZE;
|
||||
in -= AES_BLOCK_SIZE;
|
||||
inputLen -= AES_BLOCK_SIZE;
|
||||
}
|
||||
if (in == input) {
|
||||
if (rijndael_decryptBlock128(cx, out, in) != SECSuccess) {
|
||||
return SECFailure;
|
||||
if (aesni) {
|
||||
rijndael_native_decryptBlock(cx, out, in);
|
||||
native_xorBlock(out, out, cx->iv);
|
||||
} else {
|
||||
rijndael_decryptBlock128(cx, out, in);
|
||||
xorBlock(out, out, cx->iv);
|
||||
}
|
||||
for (j = 0; j < AES_BLOCK_SIZE; ++j)
|
||||
out[j] ^= cx->iv[j];
|
||||
}
|
||||
memcpy(cx->iv, newIV, AES_BLOCK_SIZE);
|
||||
return SECSuccess;
|
||||
|
|
|
|||
|
|
@ -26,10 +26,6 @@
|
|||
#endif /* NSS_DISABLE_SSE2 */
|
||||
#endif
|
||||
|
||||
typedef void AESBlockFunc(AESContext *cx,
|
||||
unsigned char *output,
|
||||
const unsigned char *input);
|
||||
|
||||
/* RIJNDAEL_NUM_ROUNDS
|
||||
*
|
||||
* Number of rounds per execution
|
||||
|
|
|
|||
|
|
@ -55,16 +55,26 @@ SECU_ReadDERFromFile(SECItem *der, PRFileDesc *inFile, PRBool ascii)
|
|||
if (ascii) {
|
||||
/* First convert ascii to binary */
|
||||
SECItem filedata;
|
||||
char *asc, *body;
|
||||
|
||||
/* Read in ascii data */
|
||||
rv = SECU_FileToItem(&filedata, inFile);
|
||||
asc = (char *)filedata.data;
|
||||
if (!asc) {
|
||||
if (rv != SECSuccess) {
|
||||
return rv;
|
||||
}
|
||||
if (!filedata.data) {
|
||||
fprintf(stderr, "unable to read data from input file\n");
|
||||
return SECFailure;
|
||||
}
|
||||
/* need one additional byte for zero terminator */
|
||||
rv = SECITEM_ReallocItemV2(NULL, &filedata, filedata.len + 1);
|
||||
if (rv != SECSuccess) {
|
||||
PORT_Free(filedata.data);
|
||||
return rv;
|
||||
}
|
||||
char *asc = (char *)filedata.data;
|
||||
asc[filedata.len - 1] = '\0';
|
||||
|
||||
char *body;
|
||||
/* check for headers and trailers and remove them */
|
||||
if ((body = strstr(asc, "-----BEGIN")) != NULL) {
|
||||
char *trailer = NULL;
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ int
|
|||
secmod_GetSystemFIPSEnabled(void)
|
||||
{
|
||||
#ifdef LINUX
|
||||
#ifndef NSS_FIPS_DISABLED
|
||||
FILE *f;
|
||||
char d;
|
||||
size_t size;
|
||||
|
|
@ -116,6 +117,7 @@ secmod_GetSystemFIPSEnabled(void)
|
|||
if (d == '1') {
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,6 +109,10 @@ static ssl3CipherSuiteCfg cipherSuites[ssl_V3_SUITES_IMPLEMENTED] = {
|
|||
{ TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, SSL_ALLOWED, PR_TRUE, PR_FALSE},
|
||||
{ TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, SSL_ALLOWED, PR_FALSE, PR_FALSE},
|
||||
{ TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, SSL_ALLOWED, PR_FALSE, PR_FALSE},
|
||||
{ TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, SSL_ALLOWED, PR_TRUE, PR_FALSE},
|
||||
{ TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, SSL_ALLOWED, PR_TRUE, PR_FALSE},
|
||||
{ TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, SSL_ALLOWED, PR_TRUE, PR_FALSE},
|
||||
{ TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384, SSL_ALLOWED, PR_TRUE, PR_FALSE},
|
||||
{ TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, SSL_ALLOWED, PR_FALSE, PR_FALSE},
|
||||
{ TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_ALLOWED, PR_FALSE, PR_FALSE},
|
||||
{ TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, SSL_ALLOWED, PR_FALSE, PR_FALSE},
|
||||
|
|
@ -303,6 +307,12 @@ static const ssl3CipherSuiteDef cipher_suite_defs[] =
|
|||
{ TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, cipher_aes_256_gcm, ssl_mac_aead, kea_ecdhe_rsa, ssl_hash_sha384 },
|
||||
{ TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, cipher_aes_256, ssl_hmac_sha384, kea_ecdhe_ecdsa, ssl_hash_sha384 },
|
||||
{ TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, cipher_aes_256, ssl_hmac_sha384, kea_ecdhe_rsa, ssl_hash_sha384 },
|
||||
|
||||
{ TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, cipher_camellia_256, ssl_hmac_sha384, kea_ecdhe_ecdsa, ssl_hash_sha384 },
|
||||
{ TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384, cipher_camellia_256, ssl_hmac_sha384, kea_ecdhe_rsa, ssl_hash_sha384 },
|
||||
{ TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, cipher_camellia_128, ssl_hmac_sha256, kea_ecdhe_ecdsa, ssl_hash_sha256 },
|
||||
{ TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, cipher_camellia_128, ssl_hmac_sha256, kea_ecdhe_rsa, ssl_hash_sha256 },
|
||||
|
||||
{ TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, cipher_aes_128_gcm, ssl_mac_aead, kea_dhe_dss, ssl_hash_sha256 },
|
||||
{ TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, cipher_aes_128, ssl_hmac_sha256, kea_dhe_dss, ssl_hash_sha256 },
|
||||
{ TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, cipher_aes_256, ssl_hmac_sha256, kea_dhe_dss, ssl_hash_sha256 },
|
||||
|
|
@ -565,6 +575,10 @@ ssl3_CipherSuiteAllowedForVersionRange(ssl3CipherSuite cipherSuite,
|
|||
case TLS_RSA_WITH_AES_256_CBC_SHA256:
|
||||
case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
|
||||
case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
|
||||
case TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256:
|
||||
case TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384:
|
||||
case TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256:
|
||||
case TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384:
|
||||
case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
|
||||
case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
|
||||
case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
|
||||
|
|
|
|||
|
|
@ -762,18 +762,22 @@ static const ssl3CipherSuite ssl_all_ec_suites[] = {
|
|||
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
|
||||
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
|
||||
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
|
||||
TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
|
||||
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
|
||||
TLS_ECDHE_ECDSA_WITH_NULL_SHA,
|
||||
TLS_ECDHE_ECDSA_WITH_RC4_128_SHA,
|
||||
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
|
||||
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
|
||||
TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
|
||||
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
|
||||
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
|
||||
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
|
||||
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
|
||||
TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
|
||||
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
||||
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
|
||||
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
|
||||
TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384,
|
||||
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
|
||||
TLS_ECDHE_RSA_WITH_NULL_SHA,
|
||||
TLS_ECDHE_RSA_WITH_RC4_128_SHA,
|
||||
|
|
|
|||
|
|
@ -76,6 +76,10 @@ const PRUint16 SSL_ImplementedCiphers[] = {
|
|||
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
|
||||
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
|
||||
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
|
||||
TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
|
||||
TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
|
||||
TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
|
||||
TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384,
|
||||
TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,
|
||||
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
|
||||
TLS_ECDHE_ECDSA_WITH_RC4_128_SHA,
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ typedef struct {
|
|||
#endif
|
||||
} ssl3CipherSuiteCfg;
|
||||
|
||||
#define ssl_V3_SUITES_IMPLEMENTED 71
|
||||
#define ssl_V3_SUITES_IMPLEMENTED 75
|
||||
|
||||
#define MAX_DTLS_SRTP_CIPHER_SUITES 4
|
||||
|
||||
|
|
|
|||
|
|
@ -300,8 +300,10 @@ static const SSLCipherSuiteInfo suiteInfo[] = {
|
|||
{ 0, CS(ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA), S_ECDSA, K_ECDHE, C_3DES, B_3DES, M_SHA, F_FIPS_STD, A_ECDSA, ssl_hash_none },
|
||||
{ 0, CS(ECDHE_ECDSA_WITH_AES_128_CBC_SHA), S_ECDSA, K_ECDHE, C_AES, B_128, M_SHA, F_FIPS_STD, A_ECDSA, ssl_hash_none },
|
||||
{ 0, CS(ECDHE_ECDSA_WITH_AES_128_CBC_SHA256), S_ECDSA, K_ECDHE, C_AES, B_128, M_SHA256, F_FIPS_STD, A_ECDSA, ssl_hash_sha256 },
|
||||
{ 0, CS(ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256), S_ECDSA, K_ECDHE, C_CAMELLIA, B_128, M_SHA256, F_NFIPS_STD, A_ECDSA, ssl_hash_sha256 },
|
||||
{ 0, CS(ECDHE_ECDSA_WITH_AES_256_CBC_SHA), S_ECDSA, K_ECDHE, C_AES, B_256, M_SHA, F_FIPS_STD, A_ECDSA, ssl_hash_none },
|
||||
{ 0, CS(ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256), S_ECDSA, K_ECDHE, C_CHACHA20, B_256, M_AEAD_128, F_NFIPS_STD, A_ECDSA, ssl_hash_sha256 },
|
||||
{ 0, CS(ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384), S_ECDSA, K_ECDHE, C_CAMELLIA, B_256, M_SHA384, F_NFIPS_STD, A_ECDSA, ssl_hash_sha384 },
|
||||
|
||||
{ 0, CS(ECDH_RSA_WITH_NULL_SHA), S_RSA, K_ECDH, C_NULL, B_0, M_SHA, F_NFIPS_STD, A_ECDH_R, ssl_hash_none },
|
||||
{ 0, CS(ECDH_RSA_WITH_RC4_128_SHA), S_RSA, K_ECDH, C_RC4, B_128, M_SHA, F_NFIPS_STD, A_ECDH_R, ssl_hash_none },
|
||||
|
|
@ -314,12 +316,14 @@ static const SSLCipherSuiteInfo suiteInfo[] = {
|
|||
{ 0, CS(ECDHE_RSA_WITH_3DES_EDE_CBC_SHA), S_RSA, K_ECDHE, C_3DES, B_3DES, M_SHA, F_FIPS_STD, A_RSAS, ssl_hash_none },
|
||||
{ 0, CS(ECDHE_RSA_WITH_AES_128_CBC_SHA), S_RSA, K_ECDHE, C_AES, B_128, M_SHA, F_FIPS_STD, A_RSAS, ssl_hash_none },
|
||||
{ 0, CS(ECDHE_RSA_WITH_AES_128_CBC_SHA256), S_RSA, K_ECDHE, C_AES, B_128, M_SHA256, F_FIPS_STD, A_RSAS, ssl_hash_sha256 },
|
||||
{ 0, CS(ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256), S_RSA, K_ECDHE, C_CAMELLIA, B_128, M_SHA256, F_NFIPS_STD, A_RSAS, ssl_hash_sha256 },
|
||||
{ 0, CS(ECDHE_RSA_WITH_AES_256_CBC_SHA), S_RSA, K_ECDHE, C_AES, B_256, M_SHA, F_FIPS_STD, A_RSAS, ssl_hash_none },
|
||||
{ 0, CS(ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256), S_RSA, K_ECDHE, C_CHACHA20, B_256, M_AEAD_128, F_NFIPS_STD, A_RSAS, ssl_hash_sha256 },
|
||||
{ 0, CS(ECDHE_RSA_WITH_AES_256_CBC_SHA384), S_RSA, K_ECDHE, C_AES, B_256, M_SHA384, F_FIPS_STD, A_RSAS, ssl_hash_sha384 },
|
||||
{ 0, CS(ECDHE_ECDSA_WITH_AES_256_CBC_SHA384), S_ECDSA, K_ECDHE, C_AES, B_256, M_SHA384, F_FIPS_STD, A_ECDSA, ssl_hash_sha384 },
|
||||
{ 0, CS(ECDHE_ECDSA_WITH_AES_256_GCM_SHA384), S_ECDSA, K_ECDHE, C_AESGCM, B_256, M_AEAD_128, F_FIPS_STD, A_ECDSA, ssl_hash_sha384 },
|
||||
{ 0, CS(ECDHE_RSA_WITH_AES_256_GCM_SHA384), S_RSA, K_ECDHE, C_AESGCM, B_256, M_AEAD_128, F_FIPS_STD, A_RSAS, ssl_hash_sha384 },
|
||||
{ 0, CS(ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384), S_RSA, K_ECDHE, C_CAMELLIA, B_256, M_SHA384, F_NFIPS_STD, A_RSAS, ssl_hash_sha384 },
|
||||
|
||||
{ 0, CS(DHE_DSS_WITH_AES_256_GCM_SHA384), S_DSA, K_DHE, C_AESGCM, B_256, M_AEAD_128, F_FIPS_STD, A_DSA, ssl_hash_sha384 },
|
||||
{ 0, CS(DHE_RSA_WITH_AES_256_GCM_SHA384), S_RSA, K_DHE, C_AESGCM, B_256, M_AEAD_128, F_FIPS_STD, A_RSAS, ssl_hash_sha384 },
|
||||
|
|
|
|||
|
|
@ -537,6 +537,9 @@ ssl_DecodeResumptionToken(sslSessionID *sid, const PRUint8 *encodedToken,
|
|||
}
|
||||
if (readerBuffer.len) {
|
||||
PORT_Assert(readerBuffer.buf);
|
||||
if (sid->peerID) {
|
||||
PORT_Free((void *)sid->peerID);
|
||||
}
|
||||
sid->peerID = PORT_Strdup((const char *)readerBuffer.buf);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -199,6 +199,12 @@
|
|||
#define TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0xC030
|
||||
#define TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 0xC031
|
||||
|
||||
/* RFC 6367 2.1 HMAC, ephemeral only */
|
||||
#define TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0xC072
|
||||
#define TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0xC073
|
||||
#define TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xC076
|
||||
#define TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 0xC077
|
||||
|
||||
/* draft-ietf-tls-chacha20-poly1305-04 */
|
||||
#define TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 0xCCA8
|
||||
#define TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 0xCCA9
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ userCanModifySystemDB()
|
|||
return (access(NSS_DEFAULT_SYSTEM, W_OK) == 0);
|
||||
}
|
||||
|
||||
#ifndef NSS_FIPS_DISABLED
|
||||
static PRBool
|
||||
getFIPSEnv(void)
|
||||
{
|
||||
|
|
@ -164,10 +165,12 @@ getFIPSEnv(void)
|
|||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
#endif /* NSS_FIPS_DISABLED */
|
||||
|
||||
static PRBool
|
||||
getFIPSMode(void)
|
||||
{
|
||||
#ifndef NSS_FIPS_DISABLED
|
||||
FILE *f;
|
||||
char d;
|
||||
size_t size;
|
||||
|
|
@ -186,6 +189,9 @@ getFIPSMode(void)
|
|||
if (d != '1')
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
#else
|
||||
return PR_FALSE;
|
||||
#endif /* NSS_FIPS_DISABLED */
|
||||
}
|
||||
|
||||
#define NSS_DEFAULT_FLAGS "flags=readonly"
|
||||
|
|
|
|||
|
|
@ -898,8 +898,8 @@ typedef CK_ULONG CK_MECHANISM_TYPE;
|
|||
#define CKM_AES_CCM 0x00001088
|
||||
#define CKM_AES_CTS 0x00001089
|
||||
/* AES-CMAC values copied from v2.40 errata 1 header file */
|
||||
#define CKM_AES_CMAC_GENERAL 0x0000108A
|
||||
#define CKM_AES_CMAC 0x0000108B
|
||||
#define CKM_AES_CMAC 0x0000108A
|
||||
#define CKM_AES_CMAC_GENERAL 0x0000108B
|
||||
#define CKM_AES_XCBC_MAC 0x0000108C
|
||||
#define CKM_AES_XCBC_MAC_96 0x0000108D
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue