1 : /* ***** BEGIN LICENSE BLOCK *****
2 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 : *
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/
8 : *
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.
13 : *
14 : * The Original Code is mozilla.org code.
15 : *
16 : * The Initial Developer of the Original Code is Google Inc.
17 : * Portions created by the Initial Developer are Copyright (C) 2006
18 : * the Initial Developer. All Rights Reserved.
19 : *
20 : * Contributor(s):
21 : * Tony Chang <tc@google.com>
22 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 2 or later (the "GPL"), or
25 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 : * in which case the provisions of the GPL or the LGPL are applicable instead
27 : * of those above. If you wish to allow use of your version of this file only
28 : * under the terms of either the GPL or the LGPL, and not to allow others to
29 : * use your version of this file under the terms of the MPL, indicate your
30 : * decision by deleting the provisions above and replace them with the notice
31 : * and other provisions required by the GPL or the LGPL. If you do not delete
32 : * the provisions above, a recipient may use your version of this file under
33 : * the terms of any one of the MPL, the GPL or the LGPL.
34 : *
35 : * ***** END LICENSE BLOCK ***** */
36 :
37 : #ifndef _NS_KEYMODULE_H_
38 : #define _NS_KEYMODULE_H_
39 :
40 : #include "nsIKeyModule.h"
41 : #include "pk11pub.h"
42 :
43 : #define NS_KEYMODULEOBJECT_CLASSNAME "Key Object Component"
44 : /* eae599aa-ecef-49c6-a8af-6ddcc6feb484 */
45 : #define NS_KEYMODULEOBJECT_CID \
46 : { 0xeae599aa, 0xecef, 0x49c6, {0xa8, 0xaf, 0x6d, 0xdc, 0xc6, 0xfe, 0xb4, 0x84} }
47 : #define NS_KEYMODULEOBJECT_CONTRACTID "@mozilla.org/security/keyobject;1"
48 :
49 : #define NS_KEYMODULEOBJECTFACTORY_CLASSNAME "Key Object Factory Component"
50 : /* a39e0e9d-e567-41e3-b12c-5df67f18174d */
51 : #define NS_KEYMODULEOBJECTFACTORY_CID \
52 : { 0xa39e0e9d, 0xe567, 0x41e3, {0xb1, 0x2c, 0x5d, 0xf6, 0x7f, 0x18, 0x17, 0x4d} }
53 : #define NS_KEYMODULEOBJECTFACTORY_CONTRACTID \
54 : "@mozilla.org/security/keyobjectfactory;1"
55 :
56 : class nsKeyObject : public nsIKeyObject
57 : {
58 : public:
59 : nsKeyObject();
60 :
61 : NS_DECL_ISUPPORTS
62 : NS_DECL_NSIKEYOBJECT
63 :
64 : private:
65 : ~nsKeyObject();
66 :
67 : // Disallow copy constructor
68 : nsKeyObject(nsKeyObject&);
69 :
70 : // 0 if not yet set, otherwise one of the nsIKeyObject::*KEY values
71 : PRUint32 mKeyType;
72 :
73 : // A union of our possible key types
74 : PK11SymKey* mSymKey;
75 : SECKEYPrivateKey* mPrivateKey;
76 : SECKEYPublicKey* mPublicKey;
77 :
78 : // Helper method to free memory used by keys.
79 : void CleanUp();
80 : };
81 :
82 :
83 : class nsKeyObjectFactory : public nsIKeyObjectFactory
84 : {
85 : public:
86 : nsKeyObjectFactory();
87 :
88 : NS_DECL_ISUPPORTS
89 : NS_DECL_NSIKEYOBJECTFACTORY
90 :
91 : private:
92 38 : ~nsKeyObjectFactory() {}
93 :
94 : // Disallow copy constructor
95 : nsKeyObjectFactory(nsKeyObjectFactory&);
96 : };
97 :
98 : #endif // _NS_KEYMODULE_H_
|