crypto/weakcryptospi/source/spi/cryptospiutil.cpp
changeset 108 ca9a0fc2f082
parent 94 0e6c5a9328b5
equal deleted inserted replaced
102:deec7e509f66 108:ca9a0fc2f082
     1 /*
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    39 	{
    39 	{
    40 	RDesReadStream stream;
    40 	RDesReadStream stream;
    41 	RBuf8 rBuf;
    41 	RBuf8 rBuf;
    42 	TInt count=0;
    42 	TInt count=0;
    43 	CleanupClosePushL(rBuf);
    43 	CleanupClosePushL(rBuf);
       
    44 
       
    45 	CleanupClosePushL(stream);
    44 	TInt length=RetrieveCharacteristicsL(aInterface, stream, rBuf, count);
    46 	TInt length=RetrieveCharacteristicsL(aInterface, stream, rBuf, count);
    45 	if (length<=4)	
    47 	if (length<=4)	
    46 		{
    48 		{
    47 		CleanupStack::PopAndDestroy(&rBuf);
    49 		CleanupStack::PopAndDestroy(2);
    48 		return;
    50 		return;
    49 		}
    51 		}
    50 		
    52 		
    51 	//internalize the characteristics and dll index
    53 	//internalize the characteristics and dll index
    52 	for (TInt i=0;i<count;i++)
    54 	for (TInt i=0;i<count;i++)
    54 		CCharacteristicsAndPluginName* temp=CCharacteristicsAndPluginName::NewLC(aInterface);
    56 		CCharacteristicsAndPluginName* temp=CCharacteristicsAndPluginName::NewLC(aInterface);
    55 		temp->InternalizeL(stream);
    57 		temp->InternalizeL(stream);
    56 		aList.AppendL(temp);
    58 		aList.AppendL(temp);
    57 		CleanupStack::Pop(temp); //temp
    59 		CleanupStack::Pop(temp); //temp
    58 		}
    60 		}
       
    61 
       
    62 	CleanupStack::PopAndDestroy(&stream);
    59 	CleanupStack::PopAndDestroy(&rBuf);
    63 	CleanupStack::PopAndDestroy(&rBuf);
    60 	}
    64 	}
    61 
    65 
    62 void CryptoSpiUtil::RetrieveCharacteristicsL(TInt32 aInterface, RPointerArray<CRulesCharacteristicsAndPluginName>& aList)
    66 void CryptoSpiUtil::RetrieveCharacteristicsL(TInt32 aInterface, RPointerArray<CRulesCharacteristicsAndPluginName>& aList)
    63 	{
    67 	{
    64 	RDesReadStream stream;
    68 	RDesReadStream stream;
    65 	RBuf8 rBuf;
    69 	RBuf8 rBuf;
    66 	TInt count=0;
    70 	TInt count=0;
    67 	CleanupClosePushL(rBuf);
    71 	CleanupClosePushL(rBuf);
       
    72 	CleanupClosePushL(stream);
       
    73 
    68 	TInt length=RetrieveCharacteristicsL(aInterface, stream, rBuf, count);
    74 	TInt length=RetrieveCharacteristicsL(aInterface, stream, rBuf, count);
    69 	if (length<=4)	
    75 	if (length<=4)	
    70 		{
    76 		{
    71 		CleanupStack::PopAndDestroy(&rBuf);
    77 		CleanupStack::PopAndDestroy(2);
    72 		return;
    78 		return;
    73 		}
    79 		}
    74 		
    80 		
    75 	//internalize the characteristics and dll index
    81 	//internalize the characteristics and dll index
    76 	for (TInt i=0;i<count;i++)
    82 	for (TInt i=0;i<count;i++)
    78 		CRulesCharacteristicsAndPluginName* temp=CRulesCharacteristicsAndPluginName::NewLC(aInterface);
    84 		CRulesCharacteristicsAndPluginName* temp=CRulesCharacteristicsAndPluginName::NewLC(aInterface);
    79 		temp->InternalizeL(stream);
    85 		temp->InternalizeL(stream);
    80 		aList.AppendL(temp);
    86 		aList.AppendL(temp);
    81 		CleanupStack::Pop(temp); //temp
    87 		CleanupStack::Pop(temp); //temp
    82 		}
    88 		}
       
    89 
       
    90 	CleanupStack::PopAndDestroy(&stream);
    83 	CleanupStack::PopAndDestroy(&rBuf);
    91 	CleanupStack::PopAndDestroy(&rBuf);
    84 	}
    92 	}
    85 
    93 
    86 TInt CryptoSpiUtil::RetrieveCharacteristicsL(TInt32 aInterface, RDesReadStream& aStream, RBuf8& aBuf, TInt& aCount)
    94 TInt CryptoSpiUtil::RetrieveCharacteristicsL(TInt32 aInterface, RDesReadStream& aStream, RBuf8& aBuf, TInt& aCount)
    87 	{
    95 	{
   117 	aBuf.CreateMaxL(len);
   125 	aBuf.CreateMaxL(len);
   118 	User::LeaveIfError(RProperty::Get(KCryptoSpiPropertyCat, aInterface, aBuf));
   126 	User::LeaveIfError(RProperty::Get(KCryptoSpiPropertyCat, aInterface, aBuf));
   119 	
   127 	
   120 	//Read the length
   128 	//Read the length
   121 	aStream.Open(aBuf);
   129 	aStream.Open(aBuf);
       
   130 
   122 	len=aStream.ReadInt32L();
   131 	len=aStream.ReadInt32L();
   123 	
   132 	
   124 	//Read the count of the characteristics
   133 	//Read the count of the characteristics
   125 	aCount=aStream.ReadInt16L();
   134 	aCount=aStream.ReadInt16L();
       
   135 
   126 	return len;	
   136 	return len;	
   127 	}
   137 	}
   128 
   138 
   129 TInt CryptoSpiUtil::DllIndexToName(TInt aDllIndex, TFileName& aName)
   139 TInt CryptoSpiUtil::DllIndexToName(TInt aDllIndex, TFileName& aName)
   130 	{
   140 	{