Update contrib.
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * crypto key agreement API implementation
16 * crypto key agreement API implementation
25 #include <cryptospi/cryptokeyagreementapi.h>
26 #include <cryptospi/keyagreementplugin.h>
27 #include "legacyselector.h"
29 using namespace CryptoSpi;
32 // Implementation of Key Agreement
34 CKeyAgreement* CKeyAgreement::NewL(MKeyAgreement* aKeyAgreement, TInt aHandle)
36 CKeyAgreement* self=new(ELeave) CKeyAgreement(aKeyAgreement, aHandle);
40 CKeyAgreement::CKeyAgreement(MKeyAgreement* aKeyAgreement, TInt aHandle)
41 : CCryptoBase(aKeyAgreement, aHandle)
45 EXPORT_C CKeyAgreement::~CKeyAgreement()
49 EXPORT_C void CKeyAgreement::SetKeyL(const CKey& aSelfPrivateKey, const CCryptoParams* aParams)
51 MKeyAgreement* ptr=static_cast<MKeyAgreement*>(iPlugin);
52 ptr->SetKeyL(aSelfPrivateKey, aParams);
55 EXPORT_C CKey* CKeyAgreement::AgreeL(const CKey& aOtherPublicKey, const CCryptoParams* aParams)
57 MKeyAgreement* ptr=static_cast<MKeyAgreement*>(iPlugin);
58 return ptr->AgreeL(aOtherPublicKey, aParams);
62 // Implementation of Key agreement factory
64 EXPORT_C void CKeyAgreementFactory::CreateKeyAgreementL(CKeyAgreement*& aKeyAgreement,
66 const CKey& aPrivateKey,
67 const CCryptoParams* aAlgorithmParams)
69 MPluginSelector* selector=reinterpret_cast<MPluginSelector *>(Dll::Tls());
72 selector->CreateKeyAgreementL(aKeyAgreement, aAlgorithmUid, aPrivateKey, aAlgorithmParams);
76 CLegacySelector* legacySelector=CLegacySelector::NewLC();
77 legacySelector->CreateKeyAgreementL(aKeyAgreement, aAlgorithmUid, aPrivateKey, aAlgorithmParams);
78 CleanupStack::PopAndDestroy(legacySelector); //legacySelector
83 // Implementation of Asynchronous Key Agreement
84 // (async methods not implemented, so no coverage)
87 #ifdef _BullseyeCoverage
88 #pragma suppress_warnings on
89 #pragma BullseyeCoverage off
90 #pragma suppress_warnings off
93 CAsyncKeyAgreement* CAsyncKeyAgreement::NewL(MAsyncKeyAgreement* /*aKeyAgreement*/, TInt /*aHandle*/)
99 CAsyncKeyAgreement::CAsyncKeyAgreement(MAsyncKeyAgreement* aKeyAgreement, TInt aHandle)
100 : CCryptoBase(aKeyAgreement, aHandle)
105 EXPORT_C CAsyncKeyAgreement::~CAsyncKeyAgreement()
109 EXPORT_C void CAsyncKeyAgreement::SetKeyL(const CKey& aSelfPrivateKey, const CCryptoParams* aParams)
111 MAsyncKeyAgreement* ptr=static_cast<MAsyncKeyAgreement*>(iPlugin);
112 ptr->SetKeyL(aSelfPrivateKey, aParams);
115 EXPORT_C void CAsyncKeyAgreement::AgreeL(const CKey& aOtherPublicKey, CKey& aKey, const CCryptoParams* aParams, TRequestStatus& aRequestStatus)
117 MAsyncKeyAgreement* ptr=static_cast<MAsyncKeyAgreement*>(iPlugin);
118 return ptr->AgreeL(aOtherPublicKey, aKey, aParams, aRequestStatus);
121 EXPORT_C void CKeyAgreementFactory::CreateAsyncKeyAgreementL(CAsyncKeyAgreement*& aKeyAgreement,
123 const CKey& aPrivateKey,
124 const CCryptoParams* aAlgorithmParams)
126 MPluginSelector* selector=reinterpret_cast<MPluginSelector *>(Dll::Tls());
129 selector->CreateAsyncKeyAgreementL(aKeyAgreement, aAlgorithmUid, aPrivateKey, aAlgorithmParams);
133 CLegacySelector* legacySelector=CLegacySelector::NewLC();
134 legacySelector->CreateAsyncKeyAgreementL(aKeyAgreement, aAlgorithmUid, aPrivateKey, aAlgorithmParams);
135 CleanupStack::PopAndDestroy(legacySelector); //legacySelector