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