summaryrefslogtreecommitdiffstats
path: root/security/manager/ssl/nsPKCS12Blob.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /security/manager/ssl/nsPKCS12Blob.h
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--security/manager/ssl/nsPKCS12Blob.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/security/manager/ssl/nsPKCS12Blob.h b/security/manager/ssl/nsPKCS12Blob.h
new file mode 100644
index 0000000000..e764481999
--- /dev/null
+++ b/security/manager/ssl/nsPKCS12Blob.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=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 nsPKCS12Blob_h
+#define nsPKCS12Blob_h
+
+#include "mozilla/RefPtr.h"
+#include "mozilla/UniquePtr.h"
+#include "nsCOMPtr.h"
+#include "nsIInterfaceRequestor.h"
+#include "nsString.h"
+#include "nsTArray.h"
+#include "p12.h"
+#include "prerror.h"
+#include "ScopedNSSTypes.h"
+#include "seccomon.h"
+
+class nsIFile;
+class nsIX509Cert;
+
+// Class for importing/exporting PKCS#12 blobs
+class nsPKCS12Blob {
+ public:
+ nsPKCS12Blob();
+ ~nsPKCS12Blob() = default;
+
+ // PKCS#12 Import
+ nsresult ImportFromFile(nsIFile* file, const nsAString& password,
+ uint32_t& error);
+
+ // PKCS#12 Export
+ nsresult ExportToFile(nsIFile* file,
+ const nsTArray<RefPtr<nsIX509Cert>>& certs,
+ const nsAString& password, uint32_t& error);
+
+ private:
+ nsCOMPtr<nsIInterfaceRequestor> mUIContext;
+
+ // local helper functions
+ nsresult inputToDecoder(mozilla::UniqueSEC_PKCS12DecoderContext& dcx,
+ nsIFile* file, PRErrorCode& nssError);
+ mozilla::UniquePtr<uint8_t[]> stringToBigEndianBytes(const nsAString& uni,
+ uint32_t& bytesLength);
+ uint32_t handlePRErrorCode(PRErrorCode prerr);
+
+ static SECItem* nicknameCollision(SECItem* oldNick, PRBool* cancel,
+ void* wincx);
+ static void writeExportFile(void* arg, const char* buf, unsigned long len);
+};
+
+#endif // nsPKCS12Blob_h