os/security/cryptoservices/certificateandkeymgmt/tpkcs12intgrtn/src/tpkcs12data.cpp
Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * This file contains the implementation of the CPfxHeader,CSafeBagAttribute,
16 * CSafeContentBag,CSafeBagData.
26 #include "tpkcs12data.h"
28 // Implementation of CPfxHeader
31 Description:constructor
35 CPfxHeader::CPfxHeader()
39 Description:Function is intended to create the CPfxHeader object
43 CPfxHeader* CPfxHeader::NewL(const CDecPkcs12& aDecPkcs12 , TInt aError)
45 CPfxHeader* self = NewLC(aDecPkcs12 , aError);
46 CleanupStack::Pop(self);
50 Description:Function is intended to pcreate the CPfxHeader object and push it to cleanupstack
54 CPfxHeader* CPfxHeader::NewLC(const CDecPkcs12& aDecPkcs12 , TInt aError)
56 CPfxHeader* self = new (ELeave) CPfxHeader();
57 CleanupStack::PushL(self);
58 self->ConstructL(aDecPkcs12 , aError);
63 Description:Function is intended to construct the CPfxHeader object
64 @param-CDecPkcs12&: reference to the CDecPkcs12 object
65 @param-aError: Error to be set in case, the CDecPkcs12 object creation fails
69 void CPfxHeader::ConstructL(const CDecPkcs12& aDecPkcs12 , TInt aError)
71 if(aError != KErrNone)
73 iPkcs12ActualError = aError;
77 iVersion = aDecPkcs12.Version();
78 // put the integrity mode in the Header
79 iIntegrityMode = aDecPkcs12.IntegrityMode();
82 const CDecPkcs12MacData* macData = aDecPkcs12.MacData();
84 // set the macData member in the Header
86 iIsMacDataPresent = ( macData != NULL) ;
88 if (macData && iIntegrityMode == CDecPkcs12::EPasswordIntegrityMode)
90 // MacL method returns the DigestInfo structure.
91 const CPKCS7DigestInfo& digestInfo = macData->DigestInfo();
92 iMac = digestInfo.Digest().AllocL();
93 // MacSaltL method returns the macSalt
94 iMacSalt = macData->MacSalt().AllocL();
95 // IterationCountL method returns the iteration Count.
96 iIterationCount= macData->IterationCount();
100 Description:destructor
104 CPfxHeader::~CPfxHeader()
110 // Implementation of CSafeBagAttribute
112 Description:constructor
116 CSafeBagAttribute::CSafeBagAttribute()
120 Description:destructor
124 CSafeBagAttribute::~CSafeBagAttribute()
129 Description:Function is intended create CSafeBagAttribute object
130 @param-aAttribute: constant reference to the CDecPkcs12Attribute
134 CSafeBagAttribute* CSafeBagAttribute::NewL(const CDecPkcs12Attribute& aAttribute)
136 CSafeBagAttribute* self = NewLC(aAttribute);
137 CleanupStack::Pop(self);
141 Description:Function is intended to construct CSafeBagAttribute object, push it to cleanupstack
142 @param-aAttribute: constant reference to the CDecPkcs12Attribute
146 CSafeBagAttribute* CSafeBagAttribute::NewLC(const CDecPkcs12Attribute& aAttribute)
148 CSafeBagAttribute* self = new (ELeave) CSafeBagAttribute();
149 CleanupStack::PushL(self);
150 self->ConstructL(aAttribute);
154 Description:Function is intended to construct the CSafeBagAttribute object
155 @param-CDecPkcs12Attribute: pointer to the CDecPkcs12ShroudedKeyBag
159 void CSafeBagAttribute::ConstructL(const CDecPkcs12Attribute& aAttribute)
161 iAttrId = aAttribute.AttributeId().AllocL();
162 iAttrValCount = aAttribute.AttributeValue().Count();
165 //Implementation of CSafeContentBag
168 Description:Function is intended to create the CSafeContentBag
172 CSafeContentBag* CSafeContentBag::NewL()
174 CSafeContentBag* self = NewLC();
175 CleanupStack::Pop(self);
179 Description:Function is intended to create the CSafeContentBag, push it to cleanupstack
183 CSafeContentBag* CSafeContentBag::NewLC()
185 CSafeContentBag* self = new (ELeave) CSafeContentBag();
186 CleanupStack::PushL(self);
190 Description:constructor
194 CSafeContentBag::CSafeContentBag()
198 // Implementation of CSafeBagData
201 Description:destructor
205 CSafeBagData::~CSafeBagData()
209 delete iCertificateID;
210 iAttributeIDs.ResetAndDestroy();
211 iAttributeValues.ResetAndDestroy();
214 Description:Function is intended to create the CSafeBagData object
218 CSafeBagData* CSafeBagData::NewL()
220 CSafeBagData* self = NewLC();
221 CleanupStack::Pop(self);
225 Description:Function is intended to create the CSafeBagData object, push it to cleanupstack
229 CSafeBagData* CSafeBagData::NewLC()
231 CSafeBagData* self = new (ELeave) CSafeBagData;
232 CleanupStack::PushL(self);
236 Description:constructor
240 CSafeBagData::CSafeBagData()