From 74cabf7948b2597f5b6a67d6910c844fd1a88ff6 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 15 Dec 2018 01:42:53 +0100 Subject: Update NSS to 3.41 --- security/nss/cpputil/databuffer.h | 2 +- security/nss/cpputil/dummy_io.h | 2 +- security/nss/cpputil/nss_scoped_ptrs.h | 85 +++++++++++++++++++++++++++++++++ security/nss/cpputil/scoped_ptrs.h | 86 ---------------------------------- security/nss/cpputil/scoped_ptrs_ssl.h | 35 ++++++++++++++ security/nss/cpputil/tls_parser.h | 11 ++--- 6 files changed, 125 insertions(+), 96 deletions(-) create mode 100644 security/nss/cpputil/nss_scoped_ptrs.h delete mode 100644 security/nss/cpputil/scoped_ptrs.h create mode 100644 security/nss/cpputil/scoped_ptrs_ssl.h (limited to 'security/nss/cpputil') diff --git a/security/nss/cpputil/databuffer.h b/security/nss/cpputil/databuffer.h index 5ec035098..e981a7c22 100644 --- a/security/nss/cpputil/databuffer.h +++ b/security/nss/cpputil/databuffer.h @@ -34,7 +34,7 @@ class DataBuffer { void Allocate(size_t l) { delete[] data_; - data_ = new uint8_t[l ? l : 1]; // Don't depend on new [0]. + data_ = new uint8_t[l ? l : 1](); // Don't depend on new [0]. len_ = l; } diff --git a/security/nss/cpputil/dummy_io.h b/security/nss/cpputil/dummy_io.h index 797ac6113..e10ee1eee 100644 --- a/security/nss/cpputil/dummy_io.h +++ b/security/nss/cpputil/dummy_io.h @@ -8,7 +8,7 @@ #include "prerror.h" #include "prio.h" -#include "scoped_ptrs.h" +#include "nss_scoped_ptrs.h" class DummyIOLayerMethods { public: diff --git a/security/nss/cpputil/nss_scoped_ptrs.h b/security/nss/cpputil/nss_scoped_ptrs.h new file mode 100644 index 000000000..03979f2c5 --- /dev/null +++ b/security/nss/cpputil/nss_scoped_ptrs.h @@ -0,0 +1,85 @@ +/* -*- 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/. */ + +#ifndef nss_scoped_ptrs_h__ +#define nss_scoped_ptrs_h__ + +#include +#include "cert.h" +#include "keyhi.h" +#include "p12.h" +#include "pk11pub.h" +#include "pkcs11uri.h" + +struct ScopedDelete { + void operator()(CERTCertificate* cert) { CERT_DestroyCertificate(cert); } + void operator()(CERTCertificateList* list) { + CERT_DestroyCertificateList(list); + } + void operator()(CERTName* name) { CERT_DestroyName(name); } + void operator()(CERTCertList* list) { CERT_DestroyCertList(list); } + void operator()(CERTSubjectPublicKeyInfo* spki) { + SECKEY_DestroySubjectPublicKeyInfo(spki); + } + void operator()(PK11SlotInfo* slot) { PK11_FreeSlot(slot); } + void operator()(PK11SymKey* key) { PK11_FreeSymKey(key); } + void operator()(PRFileDesc* fd) { PR_Close(fd); } + void operator()(SECAlgorithmID* id) { SECOID_DestroyAlgorithmID(id, true); } + void operator()(SECKEYEncryptedPrivateKeyInfo* e) { + SECKEY_DestroyEncryptedPrivateKeyInfo(e, true); + } + void operator()(SECItem* item) { SECITEM_FreeItem(item, true); } + void operator()(SECKEYPublicKey* key) { SECKEY_DestroyPublicKey(key); } + void operator()(SECKEYPrivateKey* key) { SECKEY_DestroyPrivateKey(key); } + void operator()(SECKEYPrivateKeyList* list) { + SECKEY_DestroyPrivateKeyList(list); + } + void operator()(PK11URI* uri) { PK11URI_DestroyURI(uri); } + void operator()(PLArenaPool* arena) { PORT_FreeArena(arena, PR_FALSE); } + void operator()(PK11Context* context) { PK11_DestroyContext(context, true); } + void operator()(PK11GenericObject* obj) { PK11_DestroyGenericObject(obj); } + void operator()(SEC_PKCS12DecoderContext* dcx) { + SEC_PKCS12DecoderFinish(dcx); + } + void operator()(CERTDistNames* names) { CERT_FreeDistNames(names); } +}; + +template +struct ScopedMaybeDelete { + void operator()(T* ptr) { + if (ptr) { + ScopedDelete del; + del(ptr); + } + } +}; + +#define SCOPED(x) typedef std::unique_ptr > Scoped##x + +SCOPED(CERTCertificate); +SCOPED(CERTCertificateList); +SCOPED(CERTCertList); +SCOPED(CERTName); +SCOPED(CERTSubjectPublicKeyInfo); +SCOPED(PK11SlotInfo); +SCOPED(PK11SymKey); +SCOPED(PRFileDesc); +SCOPED(SECAlgorithmID); +SCOPED(SECKEYEncryptedPrivateKeyInfo); +SCOPED(SECItem); +SCOPED(SECKEYPublicKey); +SCOPED(SECKEYPrivateKey); +SCOPED(SECKEYPrivateKeyList); +SCOPED(PK11URI); +SCOPED(PLArenaPool); +SCOPED(PK11Context); +SCOPED(PK11GenericObject); +SCOPED(SEC_PKCS12DecoderContext); +SCOPED(CERTDistNames); + +#undef SCOPED + +#endif // nss_scoped_ptrs_h__ diff --git a/security/nss/cpputil/scoped_ptrs.h b/security/nss/cpputil/scoped_ptrs.h deleted file mode 100644 index 6ffef4dd3..000000000 --- a/security/nss/cpputil/scoped_ptrs.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- 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/. */ - -#ifndef scoped_ptrs_h__ -#define scoped_ptrs_h__ - -#include -#include "cert.h" -#include "keyhi.h" -#include "p12.h" -#include "pk11pub.h" -#include "pkcs11uri.h" -#include "sslexp.h" - -struct ScopedDelete { - void operator()(CERTCertificate* cert) { CERT_DestroyCertificate(cert); } - void operator()(CERTCertificateList* list) { - CERT_DestroyCertificateList(list); - } - void operator()(CERTName* name) { CERT_DestroyName(name); } - void operator()(CERTCertList* list) { CERT_DestroyCertList(list); } - void operator()(CERTSubjectPublicKeyInfo* spki) { - SECKEY_DestroySubjectPublicKeyInfo(spki); - } - void operator()(PK11SlotInfo* slot) { PK11_FreeSlot(slot); } - void operator()(PK11SymKey* key) { PK11_FreeSymKey(key); } - void operator()(PRFileDesc* fd) { PR_Close(fd); } - void operator()(SECAlgorithmID* id) { SECOID_DestroyAlgorithmID(id, true); } - void operator()(SECItem* item) { SECITEM_FreeItem(item, true); } - void operator()(SECKEYPublicKey* key) { SECKEY_DestroyPublicKey(key); } - void operator()(SECKEYPrivateKey* key) { SECKEY_DestroyPrivateKey(key); } - void operator()(SECKEYPrivateKeyList* list) { - SECKEY_DestroyPrivateKeyList(list); - } - void operator()(PK11URI* uri) { PK11URI_DestroyURI(uri); } - void operator()(PLArenaPool* arena) { PORT_FreeArena(arena, PR_FALSE); } - void operator()(PK11Context* context) { PK11_DestroyContext(context, true); } - void operator()(PK11GenericObject* obj) { PK11_DestroyGenericObject(obj); } - void operator()(SSLResumptionTokenInfo* token) { - SSL_DestroyResumptionTokenInfo(token); - } - void operator()(SEC_PKCS12DecoderContext* dcx) { - SEC_PKCS12DecoderFinish(dcx); - } - void operator()(CERTDistNames* names) { CERT_FreeDistNames(names); } -}; - -template -struct ScopedMaybeDelete { - void operator()(T* ptr) { - if (ptr) { - ScopedDelete del; - del(ptr); - } - } -}; - -#define SCOPED(x) typedef std::unique_ptr > Scoped##x - -SCOPED(CERTCertificate); -SCOPED(CERTCertificateList); -SCOPED(CERTCertList); -SCOPED(CERTName); -SCOPED(CERTSubjectPublicKeyInfo); -SCOPED(PK11SlotInfo); -SCOPED(PK11SymKey); -SCOPED(PRFileDesc); -SCOPED(SECAlgorithmID); -SCOPED(SECItem); -SCOPED(SECKEYPublicKey); -SCOPED(SECKEYPrivateKey); -SCOPED(SECKEYPrivateKeyList); -SCOPED(PK11URI); -SCOPED(PLArenaPool); -SCOPED(PK11Context); -SCOPED(PK11GenericObject); -SCOPED(SSLResumptionTokenInfo); -SCOPED(SEC_PKCS12DecoderContext); -SCOPED(CERTDistNames); - -#undef SCOPED - -#endif // scoped_ptrs_h__ diff --git a/security/nss/cpputil/scoped_ptrs_ssl.h b/security/nss/cpputil/scoped_ptrs_ssl.h new file mode 100644 index 000000000..7eeae8f8f --- /dev/null +++ b/security/nss/cpputil/scoped_ptrs_ssl.h @@ -0,0 +1,35 @@ +/* -*- 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/. */ + +#ifndef scoped_ptrs_ssl_h__ +#define scoped_ptrs_ssl_h__ + +#include +#include "sslexp.h" + +struct ScopedDeleteSSL { + void operator()(SSLResumptionTokenInfo* token) { + SSL_DestroyResumptionTokenInfo(token); + } +}; + +template +struct ScopedMaybeDeleteSSL { + void operator()(T* ptr) { + if (ptr) { + ScopedDeleteSSL del; + del(ptr); + } + } +}; + +#define SCOPED(x) typedef std::unique_ptr > Scoped##x + +SCOPED(SSLResumptionTokenInfo); + +#undef SCOPED + +#endif // scoped_ptrs_ssl_h__ diff --git a/security/nss/cpputil/tls_parser.h b/security/nss/cpputil/tls_parser.h index 56f562e07..cd9e28fc3 100644 --- a/security/nss/cpputil/tls_parser.h +++ b/security/nss/cpputil/tls_parser.h @@ -20,13 +20,6 @@ namespace nss_test { -const uint8_t kTlsChangeCipherSpecType = 20; -const uint8_t kTlsAlertType = 21; -const uint8_t kTlsHandshakeType = 22; -const uint8_t kTlsApplicationDataType = 23; -const uint8_t kTlsAltHandshakeType = 24; -const uint8_t kTlsAckType = 25; - const uint8_t kTlsHandshakeClientHello = 1; const uint8_t kTlsHandshakeServerHello = 2; const uint8_t kTlsHandshakeNewSessionTicket = 4; @@ -48,6 +41,8 @@ const uint8_t kTlsAlertBadRecordMac = 20; const uint8_t kTlsAlertRecordOverflow = 22; const uint8_t kTlsAlertHandshakeFailure = 40; const uint8_t kTlsAlertBadCertificate = 42; +const uint8_t kTlsAlertCertificateRevoked = 44; +const uint8_t kTlsAlertCertificateExpired = 45; const uint8_t kTlsAlertIllegalParameter = 47; const uint8_t kTlsAlertDecodeError = 50; const uint8_t kTlsAlertDecryptError = 51; @@ -60,7 +55,7 @@ const uint8_t kTlsAlertUnrecognizedName = 112; const uint8_t kTlsAlertNoApplicationProtocol = 120; const uint8_t kTlsFakeChangeCipherSpec[] = { - kTlsChangeCipherSpecType, // Type + ssl_ct_change_cipher_spec, // Type 0xfe, 0xff, // Version 0x00, -- cgit v1.2.3