os/security/cryptoservices/certificateandkeymgmt/tpkcs12intgrtn/src/tpkcs12data.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/tpkcs12intgrtn/src/tpkcs12data.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,242 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* This file contains the implementation of the CPfxHeader,CSafeBagAttribute,
    1.19 +* CSafeContentBag,CSafeBagData.
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +/**
    1.25 + @file 
    1.26 + @internalTechnology
    1.27 +*/
    1.28 +//User Include 
    1.29 +#include "tpkcs12data.h"
    1.30 +
    1.31 +// Implementation of CPfxHeader
    1.32 +
    1.33 +/**
    1.34 +Description:constructor
    1.35 +@internalTechnology:
    1.36 +@test
    1.37 +*/
    1.38 +CPfxHeader::CPfxHeader()
    1.39 +	{
    1.40 +	}
    1.41 +/**
    1.42 +Description:Function is intended to create the  CPfxHeader object
    1.43 +@internalTechnology:
    1.44 +@test
    1.45 +*/
    1.46 + CPfxHeader* CPfxHeader::NewL(const CDecPkcs12& aDecPkcs12 , TInt aError)
    1.47 +	{
    1.48 +	CPfxHeader* self = NewLC(aDecPkcs12 , aError);
    1.49 +	CleanupStack::Pop(self);
    1.50 +	return self;
    1.51 +	}
    1.52 +/**
    1.53 +Description:Function is intended to pcreate the  CPfxHeader object and push it to cleanupstack
    1.54 +@internalTechnology:
    1.55 +@test
    1.56 +*/
    1.57 + CPfxHeader* CPfxHeader::NewLC(const CDecPkcs12& aDecPkcs12 , TInt aError)
    1.58 +	{
    1.59 +	CPfxHeader* self = new (ELeave) CPfxHeader();
    1.60 +	CleanupStack::PushL(self);
    1.61 +	self->ConstructL(aDecPkcs12 , aError);
    1.62 +	return self;
    1.63 +	}
    1.64 +
    1.65 +/**
    1.66 +Description:Function is intended to construct the CPfxHeader object
    1.67 +@param-CDecPkcs12&: reference to the CDecPkcs12 object
    1.68 +@param-aError: Error to be set in case, the CDecPkcs12 object creation fails
    1.69 +@internalTechnology:
    1.70 +@test
    1.71 +*/	
    1.72 +void CPfxHeader::ConstructL(const CDecPkcs12& aDecPkcs12 , TInt aError)
    1.73 +	{	
    1.74 +	if(aError != KErrNone)
    1.75 +		{
    1.76 +		iPkcs12ActualError = aError;
    1.77 +		return;
    1.78 +		}
    1.79 +	//get the version
    1.80 +	iVersion = 	aDecPkcs12.Version();
    1.81 +	// put the integrity mode in the Header
    1.82 +	iIntegrityMode =  aDecPkcs12.IntegrityMode();
    1.83 +	
    1.84 +	// Get the macData 
    1.85 +	const CDecPkcs12MacData* macData = aDecPkcs12.MacData();
    1.86 +	
    1.87 +	// set the macData member in the Header
    1.88 +
    1.89 +	iIsMacDataPresent = ( macData != NULL) ;
    1.90 +	
    1.91 +	if (macData  && iIntegrityMode ==  CDecPkcs12::EPasswordIntegrityMode)
    1.92 +		{
    1.93 +		// MacL method returns the DigestInfo structure.
    1.94 +		const CPKCS7DigestInfo& digestInfo = macData->DigestInfo();		
    1.95 +		iMac = digestInfo.Digest().AllocL();
    1.96 +		// MacSaltL method returns the macSalt
    1.97 +		iMacSalt = macData->MacSalt().AllocL();
    1.98 +		// IterationCountL method returns the iteration Count.
    1.99 +		iIterationCount= macData->IterationCount();
   1.100 +		}
   1.101 +	}
   1.102 +/**
   1.103 +Description:destructor
   1.104 +@internalTechnology:
   1.105 +@test
   1.106 +*/
   1.107 +CPfxHeader::~CPfxHeader()
   1.108 +	{
   1.109 +	delete iMac;
   1.110 +	delete iMacSalt;		
   1.111 +	}
   1.112 +		
   1.113 +// Implementation of CSafeBagAttribute
   1.114 +/**
   1.115 +Description:constructor
   1.116 +@internalTechnology:
   1.117 +@test
   1.118 +*/
   1.119 +CSafeBagAttribute::CSafeBagAttribute()
   1.120 +	{
   1.121 +	}
   1.122 +/**
   1.123 +Description:destructor
   1.124 +@internalTechnology:
   1.125 +@test
   1.126 +*/
   1.127 +CSafeBagAttribute::~CSafeBagAttribute()
   1.128 +	{
   1.129 +	delete iAttrId;
   1.130 +	}
   1.131 +/**
   1.132 +Description:Function is intended create CSafeBagAttribute object
   1.133 +@param-aAttribute: constant reference to the CDecPkcs12Attribute
   1.134 +@internalTechnology:
   1.135 +@test
   1.136 +*/
   1.137 + CSafeBagAttribute* CSafeBagAttribute::NewL(const CDecPkcs12Attribute& aAttribute)
   1.138 +	{
   1.139 +	CSafeBagAttribute* self = NewLC(aAttribute);
   1.140 +	CleanupStack::Pop(self);
   1.141 +	return self;
   1.142 +	}
   1.143 +/**
   1.144 +Description:Function is intended to construct CSafeBagAttribute object, push it to cleanupstack
   1.145 +@param-aAttribute: constant reference to the CDecPkcs12Attribute
   1.146 +@internalTechnology:
   1.147 +@test
   1.148 +*/
   1.149 + CSafeBagAttribute* CSafeBagAttribute::NewLC(const CDecPkcs12Attribute& aAttribute)
   1.150 +	{
   1.151 +	CSafeBagAttribute* self = new (ELeave) CSafeBagAttribute();
   1.152 +	CleanupStack::PushL(self);
   1.153 +	self->ConstructL(aAttribute);
   1.154 +	return self;
   1.155 +	}
   1.156 +/**
   1.157 +Description:Function is intended to construct the CSafeBagAttribute object
   1.158 +@param-CDecPkcs12Attribute: pointer to the CDecPkcs12ShroudedKeyBag
   1.159 +@internalTechnology:
   1.160 +@test
   1.161 +*/
   1.162 +void CSafeBagAttribute::ConstructL(const CDecPkcs12Attribute& aAttribute)	
   1.163 +	{
   1.164 +	iAttrId = aAttribute.AttributeId().AllocL();
   1.165 +	iAttrValCount = aAttribute.AttributeValue().Count();
   1.166 +	}
   1.167 +	
   1.168 +//Implementation of CSafeContentBag
   1.169 +
   1.170 +/**
   1.171 +Description:Function is intended to create the  CSafeContentBag
   1.172 +@internalTechnology:
   1.173 +@test
   1.174 +*/
   1.175 + CSafeContentBag* CSafeContentBag::NewL()
   1.176 +	{
   1.177 +	CSafeContentBag* self = NewLC();
   1.178 +	CleanupStack::Pop(self);
   1.179 +	return self;	
   1.180 +	}
   1.181 +/**
   1.182 +Description:Function is intended to create the  CSafeContentBag, push it to cleanupstack
   1.183 +@internalTechnology:
   1.184 +@test
   1.185 +*/
   1.186 + CSafeContentBag* CSafeContentBag::NewLC()
   1.187 +	{
   1.188 +	CSafeContentBag* self = new (ELeave) CSafeContentBag();
   1.189 +	CleanupStack::PushL(self);
   1.190 +	return self;	
   1.191 +	}
   1.192 +/**
   1.193 +Description:constructor
   1.194 +@internalTechnology:
   1.195 +@test
   1.196 +*/
   1.197 +CSafeContentBag::CSafeContentBag()
   1.198 +	{	
   1.199 +	}
   1.200 +	
   1.201 +// Implementation of CSafeBagData
   1.202 +
   1.203 +/**
   1.204 +Description:destructor
   1.205 +@internalTechnology:
   1.206 +@test
   1.207 +*/
   1.208 +CSafeBagData::~CSafeBagData()
   1.209 +	{
   1.210 +	delete iBagValue;
   1.211 +	delete iAlgorithmID;
   1.212 +	delete iCertificateID;	
   1.213 +	iAttributeIDs.ResetAndDestroy();
   1.214 +	iAttributeValues.ResetAndDestroy();
   1.215 +	}	
   1.216 +/**
   1.217 +Description:Function is intended to create  the  CSafeBagData object
   1.218 +@internalTechnology:
   1.219 +@test
   1.220 +*/
   1.221 + CSafeBagData* CSafeBagData::NewL()
   1.222 +	{
   1.223 +	CSafeBagData* self = NewLC();
   1.224 +	CleanupStack::Pop(self);
   1.225 +	return self;	
   1.226 +	}
   1.227 +/**
   1.228 +Description:Function is intended to create  the  CSafeBagData object, push it to cleanupstack
   1.229 +@internalTechnology:
   1.230 +@test
   1.231 +*/
   1.232 + CSafeBagData* CSafeBagData::NewLC()
   1.233 +	{
   1.234 +	CSafeBagData* self = new (ELeave) CSafeBagData;
   1.235 +	CleanupStack::PushL(self);
   1.236 +	return self;	
   1.237 +	}
   1.238 +/**
   1.239 +Description:constructor
   1.240 +@internalTechnology:
   1.241 +@test
   1.242 +*/		
   1.243 +CSafeBagData::CSafeBagData()
   1.244 +	{		
   1.245 +	}