sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* This file contains the classes CPfxHeader,CSafeBagAttribute ,CSafeContentBag ,CSafeBagData.
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@file
|
sl@0
|
22 |
@internalTechnology
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
#ifndef __TPKCS12DATA_H
|
sl@0
|
25 |
#define __TPKCS12DATA_H
|
sl@0
|
26 |
//System Include
|
sl@0
|
27 |
#include <e32base.h>
|
sl@0
|
28 |
#include <pkcs12.h>
|
sl@0
|
29 |
#include <asnpkcs.h>
|
sl@0
|
30 |
|
sl@0
|
31 |
using namespace PKCS12;
|
sl@0
|
32 |
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
To store the PKCS12 file details
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
class CPfxHeader : public CBase
|
sl@0
|
37 |
{
|
sl@0
|
38 |
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
|
sl@0
|
41 |
/** creates a CPfxHeader object*/
|
sl@0
|
42 |
static CPfxHeader* NewL(const CDecPkcs12& aDecPkcs12 , TInt aError);
|
sl@0
|
43 |
/** creates a CPfxHeader object, push it on Cleanupstack*/
|
sl@0
|
44 |
static CPfxHeader* NewLC(const CDecPkcs12& aDecPkcs12 , TInt aError);
|
sl@0
|
45 |
/** destructor*/
|
sl@0
|
46 |
~CPfxHeader();
|
sl@0
|
47 |
/** to set the contentinfo count */
|
sl@0
|
48 |
inline void SetContentInfoCount(TInt aContentInfoCount){iContentInfoCount = aContentInfoCount;}
|
sl@0
|
49 |
/** to increment the keybagcount */
|
sl@0
|
50 |
inline void IncrementKeyBagCount(){iKeyBagCount++ ;}
|
sl@0
|
51 |
/** to increment the shroudedskeybagcount */
|
sl@0
|
52 |
inline void IncrementShroudedKeyBagCount(){iShroudedKeyBagCount++ ;}
|
sl@0
|
53 |
/** to increment the certbagcount */
|
sl@0
|
54 |
inline void IncrementCertBagCount(){iCertBagCount++;}
|
sl@0
|
55 |
/** to increment the crlbagcount */
|
sl@0
|
56 |
inline void IncrementCrlBagCount(){iCrlBagCount++;}
|
sl@0
|
57 |
/** to increment the secretbagcount */
|
sl@0
|
58 |
inline void IncrementSecretBagCount(){iSecretBagCount++;}
|
sl@0
|
59 |
/** to increment the safecontentbagcount */
|
sl@0
|
60 |
inline void IncrementSafecontentBagCount(){iSafeContentsBagCount++;}
|
sl@0
|
61 |
/** to set the pkcs12 Main Class ExpectedError */
|
sl@0
|
62 |
inline void SetPkcs12ActualError(TInt aPkcs12ActualError){iPkcs12ActualError = aPkcs12ActualError;}
|
sl@0
|
63 |
/** to get the version number*/
|
sl@0
|
64 |
inline TInt Version(){return iVersion;}
|
sl@0
|
65 |
/** to get the integrity mode*/
|
sl@0
|
66 |
inline CDecPkcs12::TIntegrityMode IntegrityMode(){return iIntegrityMode;}
|
sl@0
|
67 |
/** to get the mac data presence */
|
sl@0
|
68 |
inline TBool MacData(){return iIsMacDataPresent;}
|
sl@0
|
69 |
/** to get the mac Id */
|
sl@0
|
70 |
inline TDesC8& MacId(){return *iMac;}
|
sl@0
|
71 |
/** to get the mac salt */
|
sl@0
|
72 |
inline TDesC8& MacSalt(){return *iMacSalt;}
|
sl@0
|
73 |
/** to get the iteration count */
|
sl@0
|
74 |
inline TInt IterationCount(){return iIterationCount;}
|
sl@0
|
75 |
/** to get the contentinfo count */
|
sl@0
|
76 |
inline TInt ContentInfoCount(){return iContentInfoCount;}
|
sl@0
|
77 |
/** to get the keybagcount */
|
sl@0
|
78 |
inline TInt KeyBagCount(){return iKeyBagCount;}
|
sl@0
|
79 |
|
sl@0
|
80 |
/** to get the shroudedskeybagcount */
|
sl@0
|
81 |
inline TInt ShroudedKeyBagCount(){return iShroudedKeyBagCount;}
|
sl@0
|
82 |
/** to get the certbagcount */
|
sl@0
|
83 |
inline TInt CertBagCount(){return iCertBagCount;}
|
sl@0
|
84 |
/** to get the crlbagcount */
|
sl@0
|
85 |
inline TInt CrlBagCount(){return iCrlBagCount;}
|
sl@0
|
86 |
/** to append the secretbagcount */
|
sl@0
|
87 |
inline TInt SecretBagCount(){return iSecretBagCount;}
|
sl@0
|
88 |
/** to append the safecontentbagcount */
|
sl@0
|
89 |
inline TInt SafecontentBagCount(){return iSafeContentsBagCount;}
|
sl@0
|
90 |
inline TInt TotalSafeBagCount(){return (iKeyBagCount+iShroudedKeyBagCount+
|
sl@0
|
91 |
iCertBagCount+iCrlBagCount+iSecretBagCount);}
|
sl@0
|
92 |
|
sl@0
|
93 |
/** to get the pkcs12 Main Class ExpectedError */
|
sl@0
|
94 |
inline TInt Pkcs12ActualError(){return iPkcs12ActualError;}
|
sl@0
|
95 |
private:
|
sl@0
|
96 |
void ConstructL(const CDecPkcs12& aDecPkcs12 , TInt aError);
|
sl@0
|
97 |
|
sl@0
|
98 |
/** contains the version number of the PKCS#12 file */
|
sl@0
|
99 |
TInt iVersion ;
|
sl@0
|
100 |
/** contains the integrity mode of the PKCS#12 file */
|
sl@0
|
101 |
CDecPkcs12::TIntegrityMode iIntegrityMode;
|
sl@0
|
102 |
/** contains 1 if macData is present else 0 */
|
sl@0
|
103 |
TBool iIsMacDataPresent;
|
sl@0
|
104 |
/** contains the mac ID */
|
sl@0
|
105 |
HBufC8* iMac;
|
sl@0
|
106 |
/** contains the mac salt */
|
sl@0
|
107 |
HBufC8* iMacSalt;
|
sl@0
|
108 |
/** contains the iteration count */
|
sl@0
|
109 |
TInt iIterationCount ;
|
sl@0
|
110 |
/** contains the total content info count in the PKCS#12 file */
|
sl@0
|
111 |
TInt iContentInfoCount;
|
sl@0
|
112 |
/** contains the total keybag count in the PKCS#12 file */
|
sl@0
|
113 |
TInt iKeyBagCount;
|
sl@0
|
114 |
/** contains the total shroudedkeybag count in the PKCS#12 file */
|
sl@0
|
115 |
TInt iShroudedKeyBagCount;
|
sl@0
|
116 |
/** contains the total certbag count in the PKCS#12 file */
|
sl@0
|
117 |
TInt iCertBagCount;
|
sl@0
|
118 |
/** contains the total crlbag count in the PKCS#12 file */
|
sl@0
|
119 |
TInt iCrlBagCount;
|
sl@0
|
120 |
/** contains the total secretbag count in the PKCS#12 file */
|
sl@0
|
121 |
TInt iSecretBagCount;
|
sl@0
|
122 |
/** contains the total safecontent bag count in the PKCS#12 file */
|
sl@0
|
123 |
TInt iSafeContentsBagCount;
|
sl@0
|
124 |
/** contains PKCS12 main class error */
|
sl@0
|
125 |
TInt iPkcs12ActualError;
|
sl@0
|
126 |
|
sl@0
|
127 |
/* Constructor */
|
sl@0
|
128 |
CPfxHeader();
|
sl@0
|
129 |
};
|
sl@0
|
130 |
|
sl@0
|
131 |
/*
|
sl@0
|
132 |
To store the safecag attribute details
|
sl@0
|
133 |
*/
|
sl@0
|
134 |
|
sl@0
|
135 |
class CSafeBagAttribute : public CBase
|
sl@0
|
136 |
{
|
sl@0
|
137 |
public:
|
sl@0
|
138 |
/** destructor*/
|
sl@0
|
139 |
~CSafeBagAttribute();
|
sl@0
|
140 |
/** creates a CSafeBagAttribute object*/
|
sl@0
|
141 |
static CSafeBagAttribute* NewL(const CDecPkcs12Attribute& aAttribute);
|
sl@0
|
142 |
/** creates a CSafeBagAttribute object, push it on Cleanupstack*/
|
sl@0
|
143 |
static CSafeBagAttribute* NewLC(const CDecPkcs12Attribute& aAttribute);
|
sl@0
|
144 |
|
sl@0
|
145 |
/** to set the Attribute Id */
|
sl@0
|
146 |
inline void SetAttributeId(const TDesC& aAttributeId){iAttrId = aAttributeId.AllocL();}
|
sl@0
|
147 |
/** to set the Attribute value count */
|
sl@0
|
148 |
inline void SetAttributeValueCount(TInt aAttributeValCount){iAttrValCount = aAttributeValCount;}
|
sl@0
|
149 |
|
sl@0
|
150 |
/** to get the Attribute Id */
|
sl@0
|
151 |
inline const TDesC& AttributeId(){return *iAttrId;}
|
sl@0
|
152 |
/** to get the Attribute value count */
|
sl@0
|
153 |
inline TInt AttributeValueCount(){return iAttrValCount;}
|
sl@0
|
154 |
|
sl@0
|
155 |
private:
|
sl@0
|
156 |
/** constructor */
|
sl@0
|
157 |
CSafeBagAttribute();
|
sl@0
|
158 |
void ConstructL(const CDecPkcs12Attribute& aAttribute);
|
sl@0
|
159 |
/**contains the attribute id*/
|
sl@0
|
160 |
HBufC* iAttrId;
|
sl@0
|
161 |
/**contains the attributes count*/
|
sl@0
|
162 |
TInt iAttrValCount;
|
sl@0
|
163 |
};
|
sl@0
|
164 |
|
sl@0
|
165 |
/*
|
sl@0
|
166 |
To store the safecontent bag details
|
sl@0
|
167 |
*/
|
sl@0
|
168 |
class CSafeContentBag : public CBase
|
sl@0
|
169 |
{
|
sl@0
|
170 |
public:
|
sl@0
|
171 |
|
sl@0
|
172 |
/** creates a CSafeContentBag object*/
|
sl@0
|
173 |
static CSafeContentBag* NewL();
|
sl@0
|
174 |
/** creates a CSafeContentBag object, push it on Cleanupstack*/
|
sl@0
|
175 |
static CSafeContentBag* NewLC();
|
sl@0
|
176 |
|
sl@0
|
177 |
/** to set the safecontent bag number */
|
sl@0
|
178 |
inline void SetBagNumber(TInt aBagNumber){iBagNumber = aBagNumber;}
|
sl@0
|
179 |
/** to set the safebagcount in the safecontent bag*/
|
sl@0
|
180 |
inline void SetSafeBagCount(TInt aSafeBagCount){iSafeBagCount = aSafeBagCount;}
|
sl@0
|
181 |
|
sl@0
|
182 |
/** to get the safecontent bag number */
|
sl@0
|
183 |
inline TInt BagNumber(){return iBagNumber;}
|
sl@0
|
184 |
/** to get the safebagcount in the safecontent bag*/
|
sl@0
|
185 |
inline TInt SafeBagCount(){return iSafeBagCount;}
|
sl@0
|
186 |
|
sl@0
|
187 |
|
sl@0
|
188 |
private:
|
sl@0
|
189 |
/* constructor */
|
sl@0
|
190 |
CSafeContentBag();
|
sl@0
|
191 |
/** contains the safecontent bag number in the PKCS#12 file*/
|
sl@0
|
192 |
TInt iBagNumber ;
|
sl@0
|
193 |
/** contains the safebag count in the safecontent bag*/
|
sl@0
|
194 |
TInt iSafeBagCount;
|
sl@0
|
195 |
/** Unit Test */
|
sl@0
|
196 |
TInt iExpectedError;
|
sl@0
|
197 |
|
sl@0
|
198 |
};
|
sl@0
|
199 |
|
sl@0
|
200 |
/**
|
sl@0
|
201 |
To store the Safebag details
|
sl@0
|
202 |
*/
|
sl@0
|
203 |
class CSafeBagData : public CBase
|
sl@0
|
204 |
{
|
sl@0
|
205 |
public:
|
sl@0
|
206 |
/** creates a CSafeBagData object */
|
sl@0
|
207 |
static CSafeBagData* NewL();
|
sl@0
|
208 |
/** creates a CSafeBagData object, push it on Cleanupstack*/
|
sl@0
|
209 |
static CSafeBagData* NewLC();
|
sl@0
|
210 |
/*destructor*/
|
sl@0
|
211 |
~CSafeBagData();
|
sl@0
|
212 |
|
sl@0
|
213 |
/** to set the contentinfo number corresponding to the bag*/
|
sl@0
|
214 |
inline void SetContentInfoNumber(TInt aContentInfo){iContentInfo = aContentInfo;}
|
sl@0
|
215 |
/** to set the contenttype corresponding to the bag*/
|
sl@0
|
216 |
inline void SetContentInfoType(TInt aContentType){iContentType = aContentType;}
|
sl@0
|
217 |
/** to set the bag number corresponding to the bag*/
|
sl@0
|
218 |
inline void SetBagNumber(TInt aBagNumber){iBagNumber = aBagNumber;}
|
sl@0
|
219 |
/** to set the PrivateKeyInfoVersion corresponding to the bag*/
|
sl@0
|
220 |
inline void SetPrivateKeyInfoVersion(TInt aPrivateKeyInfoVersion){iPrivateKeyInfoVersion = aPrivateKeyInfoVersion;}
|
sl@0
|
221 |
/** to set the bag id corresponding to the bag*/
|
sl@0
|
222 |
inline void SetBagType(CDecPkcs12SafeBag::TBagId aBagId){iBagId = aBagId;}
|
sl@0
|
223 |
/** to set the bag value corresponding to the bag*/
|
sl@0
|
224 |
inline void SetBagValue(const TDesC8& aBagValue){iBagValue = aBagValue.AllocL();}
|
sl@0
|
225 |
/** to set the Algorithem id corresponding to the bag*/
|
sl@0
|
226 |
inline void SetAlgorithmId(const TDesC& aAlgorithmId){iAlgorithmID = aAlgorithmId.AllocL();}
|
sl@0
|
227 |
/** to set the Certificate id corresponding to the certbag*/
|
sl@0
|
228 |
inline void SetCertificateId(const TDesC& aCertificateID){iCertificateID = aCertificateID.AllocL();}
|
sl@0
|
229 |
/** to set the key type corresponding to the bag*/
|
sl@0
|
230 |
inline void SetKeyType(TAlgorithmId aKeyType){iKeyType = aKeyType;}
|
sl@0
|
231 |
|
sl@0
|
232 |
/** to set the X509Certificate corresponding to the bag*/
|
sl@0
|
233 |
inline void SetX509Certificate(const CX509Certificate* aX509Certificate){iX509certificate = aX509Certificate;}
|
sl@0
|
234 |
/** to set the DerEncodedShroudedKey */
|
sl@0
|
235 |
inline void SetEncodedShroudedKey(const TDesC8& aEncodedShroudedKey){iEncodedShroudedKey = aEncodedShroudedKey.AllocL();}
|
sl@0
|
236 |
|
sl@0
|
237 |
/** to get the contentinfo number corresponding to the bag*/
|
sl@0
|
238 |
inline TInt ContentInfoNumber(){return iContentInfo;}
|
sl@0
|
239 |
/** to get the contenttype corresponding to the bag*/
|
sl@0
|
240 |
inline TInt ContentInfoType(){return iContentType ;}
|
sl@0
|
241 |
/** to get the bag number corresponding to the bag*/
|
sl@0
|
242 |
inline TInt BagNumber(){return iBagNumber;}
|
sl@0
|
243 |
/** to get the PrivateKeyInfoVersion corresponding to the bag*/
|
sl@0
|
244 |
inline TInt PrivateKeyInfoVersion(){return iPrivateKeyInfoVersion;}
|
sl@0
|
245 |
/** to get the bag id corresponding to the bag*/
|
sl@0
|
246 |
inline CDecPkcs12SafeBag::TBagId BagType(){return iBagId;}
|
sl@0
|
247 |
/** to get the bag value corresponding to the bag*/
|
sl@0
|
248 |
inline const TDesC8& BagValue(){return *iBagValue;}
|
sl@0
|
249 |
/** to get the Algorithem id corresponding to the bag*/
|
sl@0
|
250 |
inline const TDesC& AlgorithmId(){return *iAlgorithmID ;}
|
sl@0
|
251 |
/** to get the Certificate id corresponding to the certbag*/
|
sl@0
|
252 |
inline const TDesC& CertificateId(){return *iCertificateID ;}
|
sl@0
|
253 |
/** to get the key type corresponding to the bag*/
|
sl@0
|
254 |
inline TAlgorithmId KeyType(){return iKeyType;}
|
sl@0
|
255 |
/** to get the X509Certificate corresponding to the bag*/
|
sl@0
|
256 |
inline const CX509Certificate& X509Certificate(){return *iX509certificate;}
|
sl@0
|
257 |
/** to get the DerEncodedShroudedKey*/
|
sl@0
|
258 |
inline TDesC8& EncodedShroudedKey(){return *iEncodedShroudedKey;}
|
sl@0
|
259 |
|
sl@0
|
260 |
/** contains the attribute IDs and attribute values count*/
|
sl@0
|
261 |
RPointerArray<CSafeBagAttribute> iAttributeIDs;
|
sl@0
|
262 |
/** contains the attribute values */
|
sl@0
|
263 |
RPointerArray<HBufC8> iAttributeValues;
|
sl@0
|
264 |
private:
|
sl@0
|
265 |
|
sl@0
|
266 |
/** contains the content info number of the safebag */
|
sl@0
|
267 |
TInt iContentInfo;
|
sl@0
|
268 |
/** contains the content type of the safebag */
|
sl@0
|
269 |
TInt iContentType ;
|
sl@0
|
270 |
/** contains the bag number of the safebag */
|
sl@0
|
271 |
TInt iBagNumber;
|
sl@0
|
272 |
/** contains the privatekey info version of the safebag */
|
sl@0
|
273 |
TInt iPrivateKeyInfoVersion ;
|
sl@0
|
274 |
/** contains the bag ID of the safebag */
|
sl@0
|
275 |
CDecPkcs12SafeBag::TBagId iBagId;
|
sl@0
|
276 |
/** contains the bag value of the safebag */
|
sl@0
|
277 |
HBufC8* iBagValue;
|
sl@0
|
278 |
/** contains the algorithem ID */
|
sl@0
|
279 |
HBufC* iAlgorithmID;
|
sl@0
|
280 |
/** contains the certificate ID */
|
sl@0
|
281 |
HBufC* iCertificateID;
|
sl@0
|
282 |
/** contains the key type */
|
sl@0
|
283 |
TAlgorithmId iKeyType;
|
sl@0
|
284 |
|
sl@0
|
285 |
/** contains the X509Certificate */
|
sl@0
|
286 |
const CX509Certificate* iX509certificate;
|
sl@0
|
287 |
/*contains the der encoded shrouded key */
|
sl@0
|
288 |
HBufC8* iEncodedShroudedKey;
|
sl@0
|
289 |
|
sl@0
|
290 |
/** Unit Test */
|
sl@0
|
291 |
TInt iVersion;
|
sl@0
|
292 |
|
sl@0
|
293 |
TAlgorithmId iAlgortihmId;
|
sl@0
|
294 |
|
sl@0
|
295 |
TInt iExpectedError;
|
sl@0
|
296 |
/*Constructor*/
|
sl@0
|
297 |
CSafeBagData();
|
sl@0
|
298 |
|
sl@0
|
299 |
};
|
sl@0
|
300 |
|
sl@0
|
301 |
#endif
|
sl@0
|
302 |
|