|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Interface which handles RSA signing operations. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef WIMRSASIGNER_H |
|
21 #define WIMRSASIGNER_H |
|
22 |
|
23 |
|
24 //INCLUDES |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <e32std.h> |
|
28 |
|
29 |
|
30 //FORWARD DECLARATIONS |
|
31 |
|
32 class CMessageDigest; |
|
33 class CWimKeyStore; |
|
34 |
|
35 |
|
36 /** |
|
37 * RSA signer object. Handles RSA signing. |
|
38 * |
|
39 * @lib WimPlugin |
|
40 * @since Series60 2.6 |
|
41 */ |
|
42 class CWimRSASigner: public CBase, public MRSASigner |
|
43 { |
|
44 |
|
45 public: |
|
46 |
|
47 /** |
|
48 * Creates new Instance of CWimRSASigner |
|
49 * @param aClient -Reference to keystore |
|
50 * @return An instance of this class |
|
51 */ |
|
52 static CWimRSASigner* NewL( CWimKeyStore& aClient ); |
|
53 |
|
54 /** |
|
55 * Destructor |
|
56 */ |
|
57 ~CWimRSASigner(); |
|
58 |
|
59 /** |
|
60 * Returns the object's human-readable label |
|
61 * @return TDesC& |
|
62 */ |
|
63 const TDesC& Label() const; |
|
64 |
|
65 /** |
|
66 * Returns a reference to the associated token |
|
67 * @return MCTToken& |
|
68 */ |
|
69 MCTToken& Token() const; |
|
70 |
|
71 /** |
|
72 * Returns a UID representing the type of the token object. The |
|
73 * meanings of possible UIDs should be documented in the |
|
74 * documentation for the interface that returns them. |
|
75 * @return TUid |
|
76 */ |
|
77 TUid Type() const; |
|
78 |
|
79 /** |
|
80 * Returns a handle for the object. The primary purpose of the |
|
81 * handle is to allow token objects to be 'passed' between |
|
82 * processes. See TCTTokenObjectHandle for more details. |
|
83 * @return TCTTokenObjectHandle |
|
84 */ |
|
85 TCTTokenObjectHandle Handle() const; |
|
86 |
|
87 /** |
|
88 * Sign some data. |
|
89 * The data is hashed before the signature is created using the SHA-1 |
|
90 * algorithm. |
|
91 * @param aPlaintext The string to be signed. |
|
92 * @param aSignature The returned signature. This remains owned |
|
93 * by the signer, and is valid until the signer is released or |
|
94 * until the next Sign. |
|
95 * @param aStatus Async status notification |
|
96 * @return void |
|
97 */ |
|
98 void SignMessage( const TDesC8& aPlaintext, |
|
99 CRSASignature*& aSignature, |
|
100 TRequestStatus& aStatus ); |
|
101 |
|
102 /** |
|
103 * Perform a raw signing operation. |
|
104 * @param aData The data to be signed - this should be some form of hash |
|
105 * of the actual message to be signed. If the data is too long, |
|
106 * this method will return KErrOverflow through aStatus. |
|
107 * @param aSignature The returned signature. This remains owned |
|
108 * by the signer, and is valid until the signer is released or |
|
109 * until the next Sign. |
|
110 * @param aStatus Async status notification |
|
111 * @return void |
|
112 */ |
|
113 void Sign( const TDesC8& aData, |
|
114 CRSASignature*& aSignature, |
|
115 TRequestStatus& aStatus ); |
|
116 |
|
117 /** |
|
118 * Cancel an ongoing sign |
|
119 * @return void |
|
120 */ |
|
121 void CancelSign(); |
|
122 |
|
123 /** |
|
124 * Release object |
|
125 * @return void |
|
126 */ |
|
127 void Release(); |
|
128 |
|
129 /** |
|
130 * Sets label for signin key object. |
|
131 * @param aLabel -label to be set. |
|
132 * @return void |
|
133 */ |
|
134 void SetLabelL( const TDesC& aLabel ); |
|
135 |
|
136 /** |
|
137 * Sets objectId for this object. |
|
138 * @param aObjectID -points to a certain key |
|
139 * @return void |
|
140 */ |
|
141 void SetObjectId( const TInt aObjectId ); |
|
142 |
|
143 protected: |
|
144 |
|
145 /** |
|
146 * Releases the object once the base-class framework work has |
|
147 * been done. The default implementation simply does a 'delete |
|
148 * this', but derived classes can substitute their own behaviour, |
|
149 * for instance to implement reference counting of the token |
|
150 * objects themselves. |
|
151 * @return void |
|
152 */ |
|
153 void DoRelease(); |
|
154 |
|
155 private: |
|
156 |
|
157 /** |
|
158 * Default constructor |
|
159 * @param aClient pointer to caller. |
|
160 */ |
|
161 CWimRSASigner( CWimKeyStore& aClient ); |
|
162 |
|
163 private: |
|
164 |
|
165 //Handles hashing. Owned |
|
166 CMessageDigest* iDigest; |
|
167 |
|
168 //Objects handle |
|
169 TCTTokenObjectHandle iHandle; |
|
170 |
|
171 //Reference to keystore |
|
172 CWimKeyStore& iClient; |
|
173 |
|
174 //holds key label. Owned. |
|
175 HBufC* iLabel; |
|
176 |
|
177 //buffer for hash result |
|
178 HBufC8* iDigestBuf; |
|
179 |
|
180 }; |
|
181 |
|
182 #endif // WIMRSASIGNER_H |
|
183 |
|
184 // end of file |