summaryrefslogtreecommitdiff
path: root/modules/libmar
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-05-06 09:24:03 +0000
committerMoonchild <moonchild@palemoon.org>2021-05-06 09:24:03 +0000
commit6f707bde95dab6998ac204f9ee6c925ee230c740 (patch)
tree859f6cf99f2e026b76dcc40b27b211154310d16e /modules/libmar
parentaa0fd3d68c856504646e1d7eb499bc890ef44101 (diff)
downloaduxp-6f707bde95dab6998ac204f9ee6c925ee230c740.tar.gz
Issue #1751 -- Remove XP_MACOSX conditionals from the rest of the tree.
This also removes some PP abuse and takes file entries out of PP when no longer needed without XP_MACOSX conditionals.
Diffstat (limited to 'modules/libmar')
-rw-r--r--modules/libmar/tool/mar.c22
-rw-r--r--modules/libmar/verify/cryptox.h49
2 files changed, 10 insertions, 61 deletions
diff --git a/modules/libmar/tool/mar.c b/modules/libmar/tool/mar.c
index f1dd761367..8c9a05ec4d 100644
--- a/modules/libmar/tool/mar.c
+++ b/modules/libmar/tool/mar.c
@@ -1,5 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
@@ -62,7 +61,7 @@ static void print_usage() {
"signed_input_archive.mar base_64_encoded_signature_file "
"changed_signed_output.mar\n");
printf("(i) is the index of the certificate to extract\n");
-#if defined(XP_MACOSX) || (defined(XP_WIN) && !defined(MAR_NSS))
+#if (defined(XP_WIN) && !defined(MAR_NSS))
printf("Verify a MAR file:\n");
printf(" mar [-C workingDir] -D DERFilePath -v signed_archive.mar\n");
printf("At most %d signature certificate DER files are specified by "
@@ -126,11 +125,10 @@ int main(int argc, char **argv) {
#if !defined(NO_SIGN_VERIFY)
uint32_t fileSizes[MAX_SIGNATURES];
const uint8_t* certBuffers[MAX_SIGNATURES];
-#if ((!defined(MAR_NSS) && defined(XP_WIN)) || defined(XP_MACOSX)) || \
- ((defined(XP_WIN) || defined(XP_MACOSX)) && !defined(MAR_NSS))
+#if defined(XP_WIN) && !defined(MAR_NSS)
char* DERFilePaths[MAX_SIGNATURES];
#endif
-#if (!defined(XP_WIN) && !defined(XP_MACOSX)) || defined(MAR_NSS)
+#if !defined(XP_WIN) || defined(MAR_NSS)
CERTCertificate* certs[MAX_SIGNATURES];
#endif
#endif
@@ -139,8 +137,7 @@ int main(int argc, char **argv) {
#if defined(XP_WIN) && !defined(MAR_NSS) && !defined(NO_SIGN_VERIFY)
memset((void*)certBuffers, 0, sizeof(certBuffers));
#endif
-#if !defined(NO_SIGN_VERIFY) && ((!defined(MAR_NSS) && defined(XP_WIN)) || \
- defined(XP_MACOSX))
+#if !defined(NO_SIGN_VERIFY) && (!defined(MAR_NSS) && defined(XP_WIN))
memset(DERFilePaths, 0, sizeof(DERFilePaths));
memset(fileSizes, 0, sizeof(fileSizes));
#endif
@@ -171,8 +168,7 @@ int main(int argc, char **argv) {
argv += 2;
argc -= 2;
}
-#if !defined(NO_SIGN_VERIFY) && ((!defined(MAR_NSS) && defined(XP_WIN)) || \
- defined(XP_MACOSX))
+#if !defined(NO_SIGN_VERIFY) && (!defined(MAR_NSS) && defined(XP_WIN))
/* -D DERFilePath, also matches -D[index] DERFilePath
We allow an index for verifying to be symmetric
with the import and export command line arguments. */
@@ -330,7 +326,7 @@ int main(int argc, char **argv) {
return -1;
}
-#if (!defined(XP_WIN) && !defined(XP_MACOSX)) || defined(MAR_NSS)
+#if !defined(XP_WIN) || defined(MAR_NSS)
if (!NSSConfigDir || certCount == 0) {
print_usage();
return -1;
@@ -344,7 +340,7 @@ int main(int argc, char **argv) {
rv = 0;
for (k = 0; k < certCount; ++k) {
-#if (defined(XP_WIN) || defined(XP_MACOSX)) && !defined(MAR_NSS)
+#if defined(XP_WIN) && !defined(MAR_NSS)
rv = mar_read_entire_file(DERFilePaths[k], MAR_MAX_CERT_SIZE,
&certBuffers[k], &fileSizes[k]);
@@ -384,7 +380,7 @@ int main(int argc, char **argv) {
}
}
for (k = 0; k < certCount; ++k) {
-#if (defined(XP_WIN) || defined(XP_MACOSX)) && !defined(MAR_NSS)
+#if defined(XP_WIN) && !defined(MAR_NSS)
free((void*)certBuffers[k]);
#else
/* certBuffers[k] is owned by certs[k] so don't free it */
@@ -402,7 +398,7 @@ int main(int argc, char **argv) {
" no signature to verify.\n");
}
}
-#if (!defined(XP_WIN) && !defined(XP_MACOSX)) || defined(MAR_NSS)
+#if !defined(XP_WIN) || defined(MAR_NSS)
(void) NSS_Shutdown();
#endif
return rv ? -1 : 0;
diff --git a/modules/libmar/verify/cryptox.h b/modules/libmar/verify/cryptox.h
index 2296b815f4..d6dceb366c 100644
--- a/modules/libmar/verify/cryptox.h
+++ b/modules/libmar/verify/cryptox.h
@@ -57,54 +57,7 @@ CryptoX_Result NSS_VerifySignature(VFYContext * const *ctx ,
#define CryptoX_FreeCertificate(cert) \
CERT_DestroyCertificate(*cert)
-#elif XP_MACOSX
-
-#define CryptoX_InvalidHandleValue NULL
-#define CryptoX_ProviderHandle void*
-#define CryptoX_SignatureHandle void*
-#define CryptoX_PublicKey void*
-#define CryptoX_Certificate void*
-
-// Forward-declare Objective-C functions implemented in MacVerifyCrypto.mm.
-#ifdef __cplusplus
-extern "C" {
-#endif
-CryptoX_Result CryptoMac_InitCryptoProvider();
-CryptoX_Result CryptoMac_VerifyBegin(CryptoX_SignatureHandle* aInputData);
-CryptoX_Result CryptoMac_VerifyUpdate(CryptoX_SignatureHandle* aInputData,
- void* aBuf, unsigned int aLen);
-CryptoX_Result CryptoMac_LoadPublicKey(const unsigned char* aCertData,
- unsigned int aDataSize,
- CryptoX_PublicKey* aPublicKey);
-CryptoX_Result CryptoMac_VerifySignature(CryptoX_SignatureHandle* aInputData,
- CryptoX_PublicKey* aPublicKey,
- const unsigned char* aSignature,
- unsigned int aSignatureLen);
-void CryptoMac_FreeSignatureHandle(CryptoX_SignatureHandle* aInputData);
-void CryptoMac_FreePublicKey(CryptoX_PublicKey* aPublicKey);
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#define CryptoX_InitCryptoProvider(aProviderHandle) \
- CryptoMac_InitCryptoProvider()
-#define CryptoX_VerifyBegin(aCryptoHandle, aInputData, aPublicKey) \
- CryptoMac_VerifyBegin(aInputData)
-#define CryptoX_VerifyUpdate(aInputData, aBuf, aLen) \
- CryptoMac_VerifyUpdate(aInputData, aBuf, aLen)
-#define CryptoX_LoadPublicKey(aProviderHandle, aCertData, aDataSize, \
- aPublicKey) \
- CryptoMac_LoadPublicKey(aCertData, aDataSize, aPublicKey)
-#define CryptoX_VerifySignature(aInputData, aPublicKey, aSignature, \
- aSignatureLen) \
- CryptoMac_VerifySignature(aInputData, aPublicKey, aSignature, aSignatureLen)
-#define CryptoX_FreeSignatureHandle(aInputData) \
- CryptoMac_FreeSignatureHandle(aInputData)
-#define CryptoX_FreePublicKey(aPublicKey) \
- CryptoMac_FreePublicKey(aPublicKey)
-#define CryptoX_FreeCertificate(aCertificate)
-
-#elif defined(XP_WIN)
+#if defined(XP_WIN)
#include <windows.h>
#include <wincrypt.h>