cryptoplugins/cryptospiplugins/source/softwarecrypto/keyagreementimpl.cpp
changeset 17 cd501b96611d
equal deleted inserted replaced
15:da2ae96f639b 17:cd501b96611d
       
     1 /*
       
     2 * Copyright (c) 2006-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 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "keyagreementimpl.h"
       
    20 #include <cryptospi/plugincharacteristics.h>
       
    21 #include "pluginconfig.h"
       
    22 
       
    23 using namespace SoftwareCrypto;
       
    24 
       
    25 CKeyAgreementImpl::CKeyAgreementImpl()
       
    26 	{
       
    27 	}
       
    28 
       
    29 void CKeyAgreementImpl::ConstructL(const CKey& aPrivateKey, const CCryptoParams* aParams)
       
    30 	{
       
    31 	SetKeyL(aPrivateKey, aParams);
       
    32 	}
       
    33 	
       
    34 CKeyAgreementImpl::~CKeyAgreementImpl()
       
    35 	{
       
    36 	delete iSharedParams;
       
    37 	delete iPrivateKey;
       
    38 	}
       
    39 
       
    40 void CKeyAgreementImpl::Close()
       
    41 	{
       
    42 	delete this;
       
    43 	}
       
    44 	
       
    45 void CKeyAgreementImpl::Reset()
       
    46 	{
       
    47 	}
       
    48 	
       
    49 TAny* CKeyAgreementImpl::GetExtension(TUid /*aExtensionId*/)
       
    50 	{
       
    51 	return 0;
       
    52 	}
       
    53 
       
    54 void CKeyAgreementImpl::GetCharacteristicsL(const TAny*& aPluginCharacteristics)
       
    55 	{
       
    56 	TInt numCiphers = sizeof(KKeyAgreementCharacteristics)/sizeof(TKeyAgreementCharacteristics*);
       
    57 	TInt32 implUid = ImplementationUid().iUid;
       
    58 	for (TInt i = 0; i < numCiphers; ++i)
       
    59 		{
       
    60 		if (KKeyAgreementCharacteristics[i]->cmn.iImplementationUID == implUid)
       
    61 			{
       
    62 			aPluginCharacteristics = KKeyAgreementCharacteristics[i];
       
    63 			break;
       
    64 			}
       
    65 		}
       
    66 	}
       
    67 
       
    68 void CKeyAgreementImpl::SetKeyL(const CKey& aSelfPrivateKey, const CCryptoParams* aSharedParams)
       
    69 	{
       
    70 	delete iPrivateKey;
       
    71 	iPrivateKey = CKey::NewL(aSelfPrivateKey);
       
    72 	delete iSharedParams;
       
    73 	iSharedParams = CCryptoParams::NewL();
       
    74 	iSharedParams->CopyL(*aSharedParams);			// copy contents of the object
       
    75 	}