Skip to content

Commit

Permalink
Bug 1479787 - build mozpkix as part of NSS, r=mt,keeler
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D2719
Differential Revision: https://phabricator.services.mozilla.com/D2720
Differential Revision: https://phabricator.services.mozilla.com/D2861

--HG--
rename : cpputil/scoped_ptrs.h => cpputil/nss_scoped_ptrs.h
rename : lib/mozpkix/test/gtest/README.txt => gtests/mozpkix_gtest/README.txt
rename : lib/mozpkix/test/gtest/pkixbuild_tests.cpp => gtests/mozpkix_gtest/pkixbuild_tests.cpp
rename : lib/mozpkix/test/gtest/pkixcert_extension_tests.cpp => gtests/mozpkix_gtest/pkixcert_extension_tests.cpp
rename : lib/mozpkix/test/gtest/pkixcert_signature_algorithm_tests.cpp => gtests/mozpkix_gtest/pkixcert_signature_algorithm_tests.cpp
rename : lib/mozpkix/test/gtest/pkixcheck_CheckExtendedKeyUsage_tests.cpp => gtests/mozpkix_gtest/pkixcheck_CheckExtendedKeyUsage_tests.cpp
rename : lib/mozpkix/test/gtest/pkixcheck_CheckIssuer_tests.cpp => gtests/mozpkix_gtest/pkixcheck_CheckIssuer_tests.cpp
rename : lib/mozpkix/test/gtest/pkixcheck_CheckKeyUsage_tests.cpp => gtests/mozpkix_gtest/pkixcheck_CheckKeyUsage_tests.cpp
rename : lib/mozpkix/test/gtest/pkixcheck_CheckSignatureAlgorithm_tests.cpp => gtests/mozpkix_gtest/pkixcheck_CheckSignatureAlgorithm_tests.cpp
rename : lib/mozpkix/test/gtest/pkixcheck_CheckValidity_tests.cpp => gtests/mozpkix_gtest/pkixcheck_CheckValidity_tests.cpp
rename : lib/mozpkix/test/gtest/pkixcheck_ParseValidity_tests.cpp => gtests/mozpkix_gtest/pkixcheck_ParseValidity_tests.cpp
rename : lib/mozpkix/test/gtest/pkixcheck_TLSFeaturesSatisfiedInternal_tests.cpp => gtests/mozpkix_gtest/pkixcheck_TLSFeaturesSatisfiedInternal_tests.cpp
rename : lib/mozpkix/test/gtest/pkixder_input_tests.cpp => gtests/mozpkix_gtest/pkixder_input_tests.cpp
rename : lib/mozpkix/test/gtest/pkixder_pki_types_tests.cpp => gtests/mozpkix_gtest/pkixder_pki_types_tests.cpp
rename : lib/mozpkix/test/gtest/pkixder_universal_types_tests.cpp => gtests/mozpkix_gtest/pkixder_universal_types_tests.cpp
rename : lib/mozpkix/test/gtest/pkixgtest.cpp => gtests/mozpkix_gtest/pkixgtest.cpp
rename : lib/mozpkix/test/gtest/pkixgtest.h => gtests/mozpkix_gtest/pkixgtest.h
rename : lib/mozpkix/test/gtest/pkixnames_tests.cpp => gtests/mozpkix_gtest/pkixnames_tests.cpp
rename : lib/mozpkix/test/gtest/pkixocsp_CreateEncodedOCSPRequest_tests.cpp => gtests/mozpkix_gtest/pkixocsp_CreateEncodedOCSPRequest_tests.cpp
rename : lib/mozpkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp => gtests/mozpkix_gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp
rename : lib/mozpkix/test/lib/pkixtestnss.h => lib/mozpkix/include/pkix-test/pkixtestnss.h
rename : lib/mozpkix/test/lib/pkixtestutil.h => lib/mozpkix/include/pkix-test/pkixtestutil.h
rename : lib/mozpkix/lib/pkixcheck.h => lib/mozpkix/include/pkix/pkixcheck.h
rename : lib/mozpkix/lib/pkixder.h => lib/mozpkix/include/pkix/pkixder.h
rename : lib/mozpkix/lib/pkixutil.h => lib/mozpkix/include/pkix/pkixutil.h
rename : lib/mozpkix/test/lib/pkixtestalg.cpp => lib/mozpkix/test-lib/pkixtestalg.cpp
rename : lib/mozpkix/test/lib/pkixtestnss.cpp => lib/mozpkix/test-lib/pkixtestnss.cpp
rename : lib/mozpkix/test/lib/pkixtestutil.cpp => lib/mozpkix/test-lib/pkixtestutil.cpp
extra : rebase_source : 7b1375fef0c8e0c361f44d16f69c31d0bd6d0b41
  • Loading branch information
franziskuskiefer committed Aug 3, 2018
1 parent bac4358 commit 53850b9
Show file tree
Hide file tree
Showing 105 changed files with 608 additions and 624 deletions.
1 change: 1 addition & 0 deletions build.sh
Expand Up @@ -99,6 +99,7 @@ while [ $# -gt 0 ]; do
--system-nspr) set_nspr_path "/usr/include/nspr/:"; no_local_nspr=1 ;;
--enable-libpkix) gyp_params+=(-Ddisable_libpkix=0) ;;
--enable-fips) gyp_params+=(-Ddisable_fips=0) ;;
--mozpkix-only) gyp_params+=(-Dmozpkix_only=1 -Ddisable_tests=1 -Dsign_libs=0) ;;
*) show_help; exit 2 ;;
esac
shift
Expand Down
9 changes: 9 additions & 0 deletions coreconf/config.gypi
Expand Up @@ -108,8 +108,12 @@
'emit_llvm%': 0,
'nss_public_dist_dir%': '<(nss_dist_dir)/public',
'nss_private_dist_dir%': '<(nss_dist_dir)/private',
# This is only needed when building with --mozpkix-only and might not work
# on all machines.
'nss_include_dir%': '/usr/include/nss',
'only_dev_random%': 1,
'disable_fips%': 1,
'mozpkix_only%': 0,
},
'target_defaults': {
# Settings specific to targets should go here.
Expand All @@ -126,6 +130,11 @@
'<(nss_dist_dir)/private/<(module)',
],
'conditions': [
[ 'mozpkix_only==1 and OS=="linux"', {
'include_dirs': [
'<(nss_include_dir)',
],
}],
[ 'disable_fips==1', {
'defines': [
'NSS_FIPS_DISABLED',
Expand Down
2 changes: 1 addition & 1 deletion cpputil/dummy_io.h
Expand Up @@ -8,7 +8,7 @@
#include "prerror.h"
#include "prio.h"

#include "scoped_ptrs.h"
#include "nss_scoped_ptrs.h"

class DummyIOLayerMethods {
public:
Expand Down
15 changes: 7 additions & 8 deletions cpputil/scoped_ptrs.h → cpputil/nss_scoped_ptrs.h
Expand Up @@ -4,16 +4,15 @@
* 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__
#ifndef nss_scoped_ptrs_h__
#define nss_scoped_ptrs_h__

#include <memory>
#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); }
Expand All @@ -29,6 +28,9 @@ struct ScopedDelete {
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); }
Expand All @@ -39,9 +41,6 @@ struct ScopedDelete {
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);
}
Expand Down Expand Up @@ -69,6 +68,7 @@ SCOPED(PK11SlotInfo);
SCOPED(PK11SymKey);
SCOPED(PRFileDesc);
SCOPED(SECAlgorithmID);
SCOPED(SECKEYEncryptedPrivateKeyInfo);
SCOPED(SECItem);
SCOPED(SECKEYPublicKey);
SCOPED(SECKEYPrivateKey);
Expand All @@ -77,10 +77,9 @@ SCOPED(PK11URI);
SCOPED(PLArenaPool);
SCOPED(PK11Context);
SCOPED(PK11GenericObject);
SCOPED(SSLResumptionTokenInfo);
SCOPED(SEC_PKCS12DecoderContext);
SCOPED(CERTDistNames);

#undef SCOPED

#endif // scoped_ptrs_h__
#endif // nss_scoped_ptrs_h__
35 changes: 35 additions & 0 deletions 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 <memory>
#include "sslexp.h"

struct ScopedDeleteSSL {
void operator()(SSLResumptionTokenInfo* token) {
SSL_DestroyResumptionTokenInfo(token);
}
};

template <class T>
struct ScopedMaybeDeleteSSL {
void operator()(T* ptr) {
if (ptr) {
ScopedDeleteSSL del;
del(ptr);
}
}
};

#define SCOPED(x) typedef std::unique_ptr<x, ScopedMaybeDeleteSSL<x> > Scoped##x

SCOPED(SSLResumptionTokenInfo);

#undef SCOPED

#endif // scoped_ptrs_ssl_h__
135 changes: 77 additions & 58 deletions exports.gyp
Expand Up @@ -5,73 +5,92 @@
'includes': [
'coreconf/config.gypi'
],
'conditions': [
[ 'mozpkix_only==0', {
'targets': [
{
'target_name': 'nss_exports',
'type': 'none',
'direct_dependent_settings': {
'include_dirs': [
'<(nss_public_dist_dir)/nss',
]
},
'dependencies': [
'cmd/lib/exports.gyp:cmd_lib_exports',
'lib/base/exports.gyp:lib_base_exports',
'lib/certdb/exports.gyp:lib_certdb_exports',
'lib/certhigh/exports.gyp:lib_certhigh_exports',
'lib/ckfw/builtins/exports.gyp:lib_ckfw_builtins_exports',
'lib/ckfw/exports.gyp:lib_ckfw_exports',
'lib/crmf/exports.gyp:lib_crmf_exports',
'lib/cryptohi/exports.gyp:lib_cryptohi_exports',
'lib/dev/exports.gyp:lib_dev_exports',
'lib/freebl/exports.gyp:lib_freebl_exports',
'lib/jar/exports.gyp:lib_jar_exports',
'lib/nss/exports.gyp:lib_nss_exports',
'lib/pk11wrap/exports.gyp:lib_pk11wrap_exports',
'lib/pkcs12/exports.gyp:lib_pkcs12_exports',
'lib/pkcs7/exports.gyp:lib_pkcs7_exports',
'lib/pki/exports.gyp:lib_pki_exports',
'lib/smime/exports.gyp:lib_smime_exports',
'lib/softoken/exports.gyp:lib_softoken_exports',
'lib/sqlite/exports.gyp:lib_sqlite_exports',
'lib/ssl/exports.gyp:lib_ssl_exports',
'lib/util/exports.gyp:lib_util_exports',
'lib/zlib/exports.gyp:lib_zlib_exports',
],
'conditions': [
[ 'disable_libpkix==0', {
'dependencies': [
'lib/libpkix/include/exports.gyp:lib_libpkix_include_exports',
'lib/libpkix/pkix/certsel/exports.gyp:lib_libpkix_pkix_certsel_exports',
'lib/libpkix/pkix/checker/exports.gyp:lib_libpkix_pkix_checker_exports',
'lib/libpkix/pkix/crlsel/exports.gyp:lib_libpkix_pkix_crlsel_exports',
'lib/libpkix/pkix/params/exports.gyp:lib_libpkix_pkix_params_exports',
'lib/libpkix/pkix/results/exports.gyp:lib_libpkix_pkix_results_exports',
'lib/libpkix/pkix/store/exports.gyp:lib_libpkix_pkix_store_exports',
'lib/libpkix/pkix/top/exports.gyp:lib_libpkix_pkix_top_exports',
'lib/libpkix/pkix/util/exports.gyp:lib_libpkix_pkix_util_exports',
'lib/libpkix/pkix_pl_nss/module/exports.gyp:lib_libpkix_pkix_pl_nss_module_exports',
'lib/libpkix/pkix_pl_nss/pki/exports.gyp:lib_libpkix_pkix_pl_nss_pki_exports',
'lib/libpkix/pkix_pl_nss/system/exports.gyp:lib_libpkix_pkix_pl_nss_system_exports',
],
}],
],
},
{
'target_name': 'dbm_exports',
'type': 'none',
'conditions': [
['disable_dbm==0', {
'direct_dependent_settings': {
'include_dirs': [
'<(nss_public_dist_dir)/dbm'
]
},
'dependencies': [
'lib/dbm/include/exports.gyp:lib_dbm_include_exports'
],
}],
],
}
],
}],
],
'targets': [
{
'target_name': 'nss_exports',
'target_name': 'nss_mozpkix_exports',
'type': 'none',
'direct_dependent_settings': {
'include_dirs': [
'<(nss_public_dist_dir)/nss'
]
},
'dependencies': [
'cmd/lib/exports.gyp:cmd_lib_exports',
'lib/base/exports.gyp:lib_base_exports',
'lib/certdb/exports.gyp:lib_certdb_exports',
'lib/certhigh/exports.gyp:lib_certhigh_exports',
'lib/ckfw/builtins/exports.gyp:lib_ckfw_builtins_exports',
'lib/ckfw/exports.gyp:lib_ckfw_exports',
'lib/crmf/exports.gyp:lib_crmf_exports',
'lib/cryptohi/exports.gyp:lib_cryptohi_exports',
'lib/dev/exports.gyp:lib_dev_exports',
'lib/freebl/exports.gyp:lib_freebl_exports',
'lib/jar/exports.gyp:lib_jar_exports',
'lib/nss/exports.gyp:lib_nss_exports',
'lib/pk11wrap/exports.gyp:lib_pk11wrap_exports',
'lib/pkcs12/exports.gyp:lib_pkcs12_exports',
'lib/pkcs7/exports.gyp:lib_pkcs7_exports',
'lib/pki/exports.gyp:lib_pki_exports',
'lib/smime/exports.gyp:lib_smime_exports',
'lib/softoken/exports.gyp:lib_softoken_exports',
'lib/sqlite/exports.gyp:lib_sqlite_exports',
'lib/ssl/exports.gyp:lib_ssl_exports',
'lib/util/exports.gyp:lib_util_exports',
'lib/zlib/exports.gyp:lib_zlib_exports'
],
'conditions': [
[ 'disable_libpkix==0', {
'dependencies': [
'lib/libpkix/include/exports.gyp:lib_libpkix_include_exports',
'lib/libpkix/pkix/certsel/exports.gyp:lib_libpkix_pkix_certsel_exports',
'lib/libpkix/pkix/checker/exports.gyp:lib_libpkix_pkix_checker_exports',
'lib/libpkix/pkix/crlsel/exports.gyp:lib_libpkix_pkix_crlsel_exports',
'lib/libpkix/pkix/params/exports.gyp:lib_libpkix_pkix_params_exports',
'lib/libpkix/pkix/results/exports.gyp:lib_libpkix_pkix_results_exports',
'lib/libpkix/pkix/store/exports.gyp:lib_libpkix_pkix_store_exports',
'lib/libpkix/pkix/top/exports.gyp:lib_libpkix_pkix_top_exports',
'lib/libpkix/pkix/util/exports.gyp:lib_libpkix_pkix_util_exports',
'lib/libpkix/pkix_pl_nss/module/exports.gyp:lib_libpkix_pkix_pl_nss_module_exports',
'lib/libpkix/pkix_pl_nss/pki/exports.gyp:lib_libpkix_pkix_pl_nss_pki_exports',
'lib/libpkix/pkix_pl_nss/system/exports.gyp:lib_libpkix_pkix_pl_nss_system_exports',
],
}],
'lib/mozpkix/exports.gyp:lib_mozpkix_exports',
'lib/mozpkix/exports.gyp:lib_mozpkix_test_exports',
],
},
{
'target_name': 'dbm_exports',
'type': 'none',
'conditions': [
['disable_dbm==0', {
'direct_dependent_settings': {
'include_dirs': [
'<(nss_public_dist_dir)/dbm'
]
},
'dependencies': [
'lib/dbm/include/exports.gyp:lib_dbm_include_exports'
],
}],
],
}
]
],
}
2 changes: 1 addition & 1 deletion fuzz/tls_server_certs.cc
Expand Up @@ -8,7 +8,7 @@
#include "ssl.h"

#include "cpputil.h"
#include "scoped_ptrs.h"
#include "nss_scoped_ptrs.h"
#include "tls_server_certs.h"

const uint8_t kP256ServerCert[] = {
Expand Down
2 changes: 1 addition & 1 deletion gtests/certdb_gtest/alg1485_unittest.cc
Expand Up @@ -9,7 +9,7 @@
#include "gtest/gtest.h"

#include "nss.h"
#include "scoped_ptrs.h"
#include "nss_scoped_ptrs.h"
#include "prprf.h"

namespace nss_test {
Expand Down
2 changes: 1 addition & 1 deletion gtests/cryptohi_gtest/cryptohi_unittest.cc
Expand Up @@ -8,7 +8,7 @@

#include "gtest/gtest.h"

#include "scoped_ptrs.h"
#include "nss_scoped_ptrs.h"
#include "cryptohi.h"
#include "secitem.h"
#include "secerr.h"
Expand Down
2 changes: 1 addition & 1 deletion gtests/der_gtest/der_private_key_import_unittest.cc
Expand Up @@ -11,7 +11,7 @@
#include "secutil.h"

#include "gtest/gtest.h"
#include "scoped_ptrs.h"
#include "nss_scoped_ptrs.h"

namespace nss_test {

Expand Down
2 changes: 1 addition & 1 deletion gtests/der_gtest/p12_import_unittest.cc
Expand Up @@ -8,7 +8,7 @@
#include "p12.h"

#include "gtest/gtest.h"
#include "scoped_ptrs.h"
#include "nss_scoped_ptrs.h"

namespace nss_test {

Expand Down
2 changes: 1 addition & 1 deletion gtests/freebl_gtest/ecl_unittest.cc
Expand Up @@ -7,7 +7,7 @@
#include <stdint.h>

#include "blapi.h"
#include "scoped_ptrs.h"
#include "nss_scoped_ptrs.h"
#include "secerr.h"

namespace nss_test {
Expand Down
File renamed without changes.

0 comments on commit 53850b9

Please sign in to comment.