Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/security/manager/ssl/nsPKCS12Blob.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#ifndef nsPKCS12Blob_h
8
#define nsPKCS12Blob_h
9
10
#include "nsCOMPtr.h"
11
#include "nsIMutableArray.h"
12
#include "nsString.h"
13
#include "p12.h"
14
#include "seccomon.h"
15
16
class nsIFile;
17
class nsIX509Cert;
18
19
// Class for importing/exporting PKCS#12 blobs
20
class nsPKCS12Blob
21
{
22
public:
23
  nsPKCS12Blob();
24
0
  ~nsPKCS12Blob() {}
25
26
  // PKCS#12 Import
27
  nsresult ImportFromFile(nsIFile* file, const nsAString& password,
28
                          uint32_t& error);
29
30
  // PKCS#12 Export
31
  nsresult ExportToFile(nsIFile* file, nsIX509Cert** certs, int numCerts,
32
                        const nsAString& password, uint32_t& error);
33
34
private:
35
  nsCOMPtr<nsIInterfaceRequestor> mUIContext;
36
37
  // local helper functions
38
  nsresult inputToDecoder(mozilla::UniqueSEC_PKCS12DecoderContext& dcx,
39
                          nsIFile* file,
40
                          PRErrorCode& nssError);
41
  mozilla::UniquePtr<uint8_t[]> stringToBigEndianBytes(const nsAString& uni,
42
                                                       uint32_t& bytesLength);
43
  uint32_t handlePRErrorCode(PRErrorCode prerr);
44
45
  static SECItem* nicknameCollision(SECItem* oldNick, PRBool* cancel,
46
                                    void* wincx);
47
  static void writeExportFile(void* arg, const char* buf, unsigned long len);
48
};
49
50
#endif // nsPKCS12Blob_h