Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / security / manager / ssl / nsPKCS12Blob.h
blobe7644819995dd97b41369bb4e5bd45490ef60422
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsPKCS12Blob_h
8 #define nsPKCS12Blob_h
10 #include "mozilla/RefPtr.h"
11 #include "mozilla/UniquePtr.h"
12 #include "nsCOMPtr.h"
13 #include "nsIInterfaceRequestor.h"
14 #include "nsString.h"
15 #include "nsTArray.h"
16 #include "p12.h"
17 #include "prerror.h"
18 #include "ScopedNSSTypes.h"
19 #include "seccomon.h"
21 class nsIFile;
22 class nsIX509Cert;
24 // Class for importing/exporting PKCS#12 blobs
25 class nsPKCS12Blob {
26 public:
27 nsPKCS12Blob();
28 ~nsPKCS12Blob() = default;
30 // PKCS#12 Import
31 nsresult ImportFromFile(nsIFile* file, const nsAString& password,
32 uint32_t& error);
34 // PKCS#12 Export
35 nsresult ExportToFile(nsIFile* file,
36 const nsTArray<RefPtr<nsIX509Cert>>& certs,
37 const nsAString& password, uint32_t& error);
39 private:
40 nsCOMPtr<nsIInterfaceRequestor> mUIContext;
42 // local helper functions
43 nsresult inputToDecoder(mozilla::UniqueSEC_PKCS12DecoderContext& dcx,
44 nsIFile* file, PRErrorCode& nssError);
45 mozilla::UniquePtr<uint8_t[]> stringToBigEndianBytes(const nsAString& uni,
46 uint32_t& bytesLength);
47 uint32_t handlePRErrorCode(PRErrorCode prerr);
49 static SECItem* nicknameCollision(SECItem* oldNick, PRBool* cancel,
50 void* wincx);
51 static void writeExportFile(void* arg, const char* buf, unsigned long len);
54 #endif // nsPKCS12Blob_h