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