sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "dummyeccsignerimpl.h" sl@0: #include "keys.h" sl@0: #include "pluginconfig.h" sl@0: #include "cryptospihai.h" sl@0: sl@0: using namespace DummyEccHwCrypto; sl@0: using namespace CryptoSpiHai; sl@0: sl@0: const TInt KMaxSignerOutputLength = 50; sl@0: const TInt KMaxSignerInputLength = 50; sl@0: sl@0: // CDummyECCSignerImpl sl@0: CDummyECCSignerImpl* CDummyECCSignerImpl::NewL(const CKey& aKey, sl@0: TUid aPaddingMode) sl@0: { sl@0: CDummyECCSignerImpl* self = sl@0: CDummyECCSignerImpl::NewLC(aKey, aPaddingMode); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CDummyECCSignerImpl* CDummyECCSignerImpl::NewLC(const CKey& aKey, sl@0: TUid aPaddingMode) sl@0: { sl@0: CDummyECCSignerImpl* self = sl@0: new (ELeave) CDummyECCSignerImpl(aPaddingMode); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aKey); sl@0: return self; sl@0: } sl@0: sl@0: CDummyECCSignerImpl::CDummyECCSignerImpl(TUid aPaddingMode) : sl@0: iPaddingMode(aPaddingMode) sl@0: { sl@0: } sl@0: sl@0: CDummyECCSignerImpl::~CDummyECCSignerImpl() sl@0: { sl@0: delete iKey; sl@0: } sl@0: sl@0: void CDummyECCSignerImpl::ConstructL(const CKey& aKey) sl@0: { sl@0: SetKeyL(aKey); sl@0: } sl@0: sl@0: // MPlugin Interface sl@0: void CDummyECCSignerImpl::Close() sl@0: { sl@0: delete this; sl@0: } sl@0: void CDummyECCSignerImpl::Reset() sl@0: { sl@0: } sl@0: void CDummyECCSignerImpl::GetCharacteristicsL( sl@0: const TCharacteristics*& aPluginCharacteristics) sl@0: { sl@0: TInt numCiphers = sizeof(KSignerCharacteristics) sl@0: / sizeof(TAsymmetricSignatureCharacteristics*); sl@0: TInt32 implUid = ImplementationUid().iUid; sl@0: for (TInt i = 0; i < numCiphers; ++i) sl@0: { sl@0: if (KSignerCharacteristics[i]->cmn.iImplementationUID == implUid) sl@0: { sl@0: aPluginCharacteristics = KSignerCharacteristics[i]; sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: const CExtendedCharacteristics* CDummyECCSignerImpl::GetExtendedCharacteristicsL() sl@0: { sl@0: // All Symbian software plug-ins have unlimited concurrency, cannot be reserved sl@0: // for exclusive use and are not CERTIFIED to be standards compliant. sl@0: return CExtendedCharacteristics::NewL(KMaxTInt, EFalse); sl@0: } sl@0: sl@0: TAny* CDummyECCSignerImpl::GetExtension(TUid /* aExtensionId */) sl@0: { sl@0: return 0; sl@0: } sl@0: // End of MPlugin Interface sl@0: sl@0: // MSignatureBase Interface sl@0: void CDummyECCSignerImpl::SetPaddingModeL(TUid /* aPaddingMode */) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: void CDummyECCSignerImpl::SetKeyL(const CKey& aKey) sl@0: { sl@0: // delete any previous key and recreate the key sl@0: delete iKey; sl@0: iKey = NULL; sl@0: iKey = CKey::NewL(aKey); sl@0: } sl@0: sl@0: TInt CDummyECCSignerImpl::GetMaximumInputLengthL() const sl@0: { sl@0: return KMaxSignerInputLength; sl@0: } sl@0: sl@0: TInt CDummyECCSignerImpl::GetMaximumOutputLengthL() const sl@0: { sl@0: return KMaxSignerOutputLength; sl@0: } sl@0: sl@0: TUid CDummyECCSignerImpl::ImplementationUid() const sl@0: { sl@0: return KCryptoPluginEccSignerUid; sl@0: } sl@0: sl@0: void CDummyECCSignerImpl::SignL(const TDesC8& aInput, sl@0: CCryptoParams& aSignature) sl@0: { sl@0: if (iKey->IsPresent(KPassedHandleToKeyUid)) sl@0: { sl@0: const TInt keyHandle = iKey->GetTIntL(KPassedHandleToKeyUid); sl@0: sl@0: // Invoke the Spi HAI to perform the operation sl@0: CCryptoSpiHai::SignL(keyHandle, aInput, aSignature); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: // End of file