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/. */
10 #include "mozilla/RefPtr.h"
11 #include "mozilla/UniquePtr.h"
13 #include "nsIInterfaceRequestor.h"
18 #include "ScopedNSSTypes.h"
24 // Class for importing/exporting PKCS#12 blobs
28 ~nsPKCS12Blob() = default;
31 nsresult
ImportFromFile(nsIFile
* file
, const nsAString
& password
,
35 nsresult
ExportToFile(nsIFile
* file
,
36 const nsTArray
<RefPtr
<nsIX509Cert
>>& certs
,
37 const nsAString
& password
, uint32_t& error
);
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
,
51 static void writeExportFile(void* arg
, const char* buf
, unsigned long len
);
54 #endif // nsPKCS12Blob_h