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 implementation of the CPfxHeader,CSafeBagAttribute,
|
sl@0
|
16 |
* CSafeContentBag,CSafeBagData.
|
sl@0
|
17 |
*
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
@file
|
sl@0
|
23 |
@internalTechnology
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
//User Include
|
sl@0
|
26 |
#include "tpkcs12data.h"
|
sl@0
|
27 |
|
sl@0
|
28 |
// Implementation of CPfxHeader
|
sl@0
|
29 |
|
sl@0
|
30 |
/**
|
sl@0
|
31 |
Description:constructor
|
sl@0
|
32 |
@internalTechnology:
|
sl@0
|
33 |
@test
|
sl@0
|
34 |
*/
|
sl@0
|
35 |
CPfxHeader::CPfxHeader()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
}
|
sl@0
|
38 |
/**
|
sl@0
|
39 |
Description:Function is intended to create the CPfxHeader object
|
sl@0
|
40 |
@internalTechnology:
|
sl@0
|
41 |
@test
|
sl@0
|
42 |
*/
|
sl@0
|
43 |
CPfxHeader* CPfxHeader::NewL(const CDecPkcs12& aDecPkcs12 , TInt aError)
|
sl@0
|
44 |
{
|
sl@0
|
45 |
CPfxHeader* self = NewLC(aDecPkcs12 , aError);
|
sl@0
|
46 |
CleanupStack::Pop(self);
|
sl@0
|
47 |
return self;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
/**
|
sl@0
|
50 |
Description:Function is intended to pcreate the CPfxHeader object and push it to cleanupstack
|
sl@0
|
51 |
@internalTechnology:
|
sl@0
|
52 |
@test
|
sl@0
|
53 |
*/
|
sl@0
|
54 |
CPfxHeader* CPfxHeader::NewLC(const CDecPkcs12& aDecPkcs12 , TInt aError)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
CPfxHeader* self = new (ELeave) CPfxHeader();
|
sl@0
|
57 |
CleanupStack::PushL(self);
|
sl@0
|
58 |
self->ConstructL(aDecPkcs12 , aError);
|
sl@0
|
59 |
return self;
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
/**
|
sl@0
|
63 |
Description:Function is intended to construct the CPfxHeader object
|
sl@0
|
64 |
@param-CDecPkcs12&: reference to the CDecPkcs12 object
|
sl@0
|
65 |
@param-aError: Error to be set in case, the CDecPkcs12 object creation fails
|
sl@0
|
66 |
@internalTechnology:
|
sl@0
|
67 |
@test
|
sl@0
|
68 |
*/
|
sl@0
|
69 |
void CPfxHeader::ConstructL(const CDecPkcs12& aDecPkcs12 , TInt aError)
|
sl@0
|
70 |
{
|
sl@0
|
71 |
if(aError != KErrNone)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
iPkcs12ActualError = aError;
|
sl@0
|
74 |
return;
|
sl@0
|
75 |
}
|
sl@0
|
76 |
//get the version
|
sl@0
|
77 |
iVersion = aDecPkcs12.Version();
|
sl@0
|
78 |
// put the integrity mode in the Header
|
sl@0
|
79 |
iIntegrityMode = aDecPkcs12.IntegrityMode();
|
sl@0
|
80 |
|
sl@0
|
81 |
// Get the macData
|
sl@0
|
82 |
const CDecPkcs12MacData* macData = aDecPkcs12.MacData();
|
sl@0
|
83 |
|
sl@0
|
84 |
// set the macData member in the Header
|
sl@0
|
85 |
|
sl@0
|
86 |
iIsMacDataPresent = ( macData != NULL) ;
|
sl@0
|
87 |
|
sl@0
|
88 |
if (macData && iIntegrityMode == CDecPkcs12::EPasswordIntegrityMode)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
// MacL method returns the DigestInfo structure.
|
sl@0
|
91 |
const CPKCS7DigestInfo& digestInfo = macData->DigestInfo();
|
sl@0
|
92 |
iMac = digestInfo.Digest().AllocL();
|
sl@0
|
93 |
// MacSaltL method returns the macSalt
|
sl@0
|
94 |
iMacSalt = macData->MacSalt().AllocL();
|
sl@0
|
95 |
// IterationCountL method returns the iteration Count.
|
sl@0
|
96 |
iIterationCount= macData->IterationCount();
|
sl@0
|
97 |
}
|
sl@0
|
98 |
}
|
sl@0
|
99 |
/**
|
sl@0
|
100 |
Description:destructor
|
sl@0
|
101 |
@internalTechnology:
|
sl@0
|
102 |
@test
|
sl@0
|
103 |
*/
|
sl@0
|
104 |
CPfxHeader::~CPfxHeader()
|
sl@0
|
105 |
{
|
sl@0
|
106 |
delete iMac;
|
sl@0
|
107 |
delete iMacSalt;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
// Implementation of CSafeBagAttribute
|
sl@0
|
111 |
/**
|
sl@0
|
112 |
Description:constructor
|
sl@0
|
113 |
@internalTechnology:
|
sl@0
|
114 |
@test
|
sl@0
|
115 |
*/
|
sl@0
|
116 |
CSafeBagAttribute::CSafeBagAttribute()
|
sl@0
|
117 |
{
|
sl@0
|
118 |
}
|
sl@0
|
119 |
/**
|
sl@0
|
120 |
Description:destructor
|
sl@0
|
121 |
@internalTechnology:
|
sl@0
|
122 |
@test
|
sl@0
|
123 |
*/
|
sl@0
|
124 |
CSafeBagAttribute::~CSafeBagAttribute()
|
sl@0
|
125 |
{
|
sl@0
|
126 |
delete iAttrId;
|
sl@0
|
127 |
}
|
sl@0
|
128 |
/**
|
sl@0
|
129 |
Description:Function is intended create CSafeBagAttribute object
|
sl@0
|
130 |
@param-aAttribute: constant reference to the CDecPkcs12Attribute
|
sl@0
|
131 |
@internalTechnology:
|
sl@0
|
132 |
@test
|
sl@0
|
133 |
*/
|
sl@0
|
134 |
CSafeBagAttribute* CSafeBagAttribute::NewL(const CDecPkcs12Attribute& aAttribute)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
CSafeBagAttribute* self = NewLC(aAttribute);
|
sl@0
|
137 |
CleanupStack::Pop(self);
|
sl@0
|
138 |
return self;
|
sl@0
|
139 |
}
|
sl@0
|
140 |
/**
|
sl@0
|
141 |
Description:Function is intended to construct CSafeBagAttribute object, push it to cleanupstack
|
sl@0
|
142 |
@param-aAttribute: constant reference to the CDecPkcs12Attribute
|
sl@0
|
143 |
@internalTechnology:
|
sl@0
|
144 |
@test
|
sl@0
|
145 |
*/
|
sl@0
|
146 |
CSafeBagAttribute* CSafeBagAttribute::NewLC(const CDecPkcs12Attribute& aAttribute)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
CSafeBagAttribute* self = new (ELeave) CSafeBagAttribute();
|
sl@0
|
149 |
CleanupStack::PushL(self);
|
sl@0
|
150 |
self->ConstructL(aAttribute);
|
sl@0
|
151 |
return self;
|
sl@0
|
152 |
}
|
sl@0
|
153 |
/**
|
sl@0
|
154 |
Description:Function is intended to construct the CSafeBagAttribute object
|
sl@0
|
155 |
@param-CDecPkcs12Attribute: pointer to the CDecPkcs12ShroudedKeyBag
|
sl@0
|
156 |
@internalTechnology:
|
sl@0
|
157 |
@test
|
sl@0
|
158 |
*/
|
sl@0
|
159 |
void CSafeBagAttribute::ConstructL(const CDecPkcs12Attribute& aAttribute)
|
sl@0
|
160 |
{
|
sl@0
|
161 |
iAttrId = aAttribute.AttributeId().AllocL();
|
sl@0
|
162 |
iAttrValCount = aAttribute.AttributeValue().Count();
|
sl@0
|
163 |
}
|
sl@0
|
164 |
|
sl@0
|
165 |
//Implementation of CSafeContentBag
|
sl@0
|
166 |
|
sl@0
|
167 |
/**
|
sl@0
|
168 |
Description:Function is intended to create the CSafeContentBag
|
sl@0
|
169 |
@internalTechnology:
|
sl@0
|
170 |
@test
|
sl@0
|
171 |
*/
|
sl@0
|
172 |
CSafeContentBag* CSafeContentBag::NewL()
|
sl@0
|
173 |
{
|
sl@0
|
174 |
CSafeContentBag* self = NewLC();
|
sl@0
|
175 |
CleanupStack::Pop(self);
|
sl@0
|
176 |
return self;
|
sl@0
|
177 |
}
|
sl@0
|
178 |
/**
|
sl@0
|
179 |
Description:Function is intended to create the CSafeContentBag, push it to cleanupstack
|
sl@0
|
180 |
@internalTechnology:
|
sl@0
|
181 |
@test
|
sl@0
|
182 |
*/
|
sl@0
|
183 |
CSafeContentBag* CSafeContentBag::NewLC()
|
sl@0
|
184 |
{
|
sl@0
|
185 |
CSafeContentBag* self = new (ELeave) CSafeContentBag();
|
sl@0
|
186 |
CleanupStack::PushL(self);
|
sl@0
|
187 |
return self;
|
sl@0
|
188 |
}
|
sl@0
|
189 |
/**
|
sl@0
|
190 |
Description:constructor
|
sl@0
|
191 |
@internalTechnology:
|
sl@0
|
192 |
@test
|
sl@0
|
193 |
*/
|
sl@0
|
194 |
CSafeContentBag::CSafeContentBag()
|
sl@0
|
195 |
{
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
// Implementation of CSafeBagData
|
sl@0
|
199 |
|
sl@0
|
200 |
/**
|
sl@0
|
201 |
Description:destructor
|
sl@0
|
202 |
@internalTechnology:
|
sl@0
|
203 |
@test
|
sl@0
|
204 |
*/
|
sl@0
|
205 |
CSafeBagData::~CSafeBagData()
|
sl@0
|
206 |
{
|
sl@0
|
207 |
delete iBagValue;
|
sl@0
|
208 |
delete iAlgorithmID;
|
sl@0
|
209 |
delete iCertificateID;
|
sl@0
|
210 |
iAttributeIDs.ResetAndDestroy();
|
sl@0
|
211 |
iAttributeValues.ResetAndDestroy();
|
sl@0
|
212 |
}
|
sl@0
|
213 |
/**
|
sl@0
|
214 |
Description:Function is intended to create the CSafeBagData object
|
sl@0
|
215 |
@internalTechnology:
|
sl@0
|
216 |
@test
|
sl@0
|
217 |
*/
|
sl@0
|
218 |
CSafeBagData* CSafeBagData::NewL()
|
sl@0
|
219 |
{
|
sl@0
|
220 |
CSafeBagData* self = NewLC();
|
sl@0
|
221 |
CleanupStack::Pop(self);
|
sl@0
|
222 |
return self;
|
sl@0
|
223 |
}
|
sl@0
|
224 |
/**
|
sl@0
|
225 |
Description:Function is intended to create the CSafeBagData object, push it to cleanupstack
|
sl@0
|
226 |
@internalTechnology:
|
sl@0
|
227 |
@test
|
sl@0
|
228 |
*/
|
sl@0
|
229 |
CSafeBagData* CSafeBagData::NewLC()
|
sl@0
|
230 |
{
|
sl@0
|
231 |
CSafeBagData* self = new (ELeave) CSafeBagData;
|
sl@0
|
232 |
CleanupStack::PushL(self);
|
sl@0
|
233 |
return self;
|
sl@0
|
234 |
}
|
sl@0
|
235 |
/**
|
sl@0
|
236 |
Description:constructor
|
sl@0
|
237 |
@internalTechnology:
|
sl@0
|
238 |
@test
|
sl@0
|
239 |
*/
|
sl@0
|
240 |
CSafeBagData::CSafeBagData()
|
sl@0
|
241 |
{
|
sl@0
|
242 |
}
|