Re-land: C++ readability review
[chromium-blink-merge.git] / net / third_party / mozilla_security_manager / nsPKCS12Blob.h
bloba2f2a490ab606ba8f016ff2588f759780f87d9c1
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is the Netscape security libraries.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2000
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Ian McGreer <mcgreer@netscape.com>
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef NET_THIRD_PARTY_MOZILLA_SECURITY_MANAGER_NSPKCS12BLOB_H_
39 #define NET_THIRD_PARTY_MOZILLA_SECURITY_MANAGER_NSPKCS12BLOB_H_
41 #include <string>
42 #include <vector>
44 #include "base/memory/ref_counted.h"
45 #include "base/strings/string16.h"
47 typedef struct CERTCertificateStr CERTCertificate;
48 typedef struct PK11SlotInfoStr PK11SlotInfo;
49 namespace net {
50 class X509Certificate;
51 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList;
52 } // namespace net
54 namespace mozilla_security_manager {
56 // Initialize NSS PKCS#12 libs.
57 void EnsurePKCS12Init();
59 // Import the private key and certificate from a PKCS#12 blob into the slot.
60 // If |is_extractable| is false, mark the private key as non-extractable.
61 // Returns a net error code. |imported_certs|, if non-NULL, returns a list of
62 // certs that were imported.
63 int nsPKCS12Blob_Import(PK11SlotInfo* slot,
64 const char* pkcs12_data,
65 size_t pkcs12_len,
66 const base::string16& password,
67 bool is_extractable,
68 net::CertificateList* imported_certs);
70 // Export the given certificates into a PKCS#12 blob, storing into output.
71 // Returns the number of certificates exported.
72 // TODO(mattm): provide better error return status?
73 int nsPKCS12Blob_Export(std::string* output,
74 const net::CertificateList& certs,
75 const base::string16& password);
77 } // namespace mozilla_security_manager
79 #endif // NET_THIRD_PARTY_MOZILLA_SECURITY_MANAGER_NSPKCS12BLOB_H_