os/security/cryptoplugins/cryptospiplugins/test/dummyecchwplugin/src/dummyeccsignerimpl.cpp
Update contrib.
2 * Copyright (c) 2009 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.
19 #include "dummyeccsignerimpl.h"
21 #include "pluginconfig.h"
22 #include "cryptospihai.h"
24 using namespace DummyEccHwCrypto;
25 using namespace CryptoSpiHai;
27 const TInt KMaxSignerOutputLength = 50;
28 const TInt KMaxSignerInputLength = 50;
30 // CDummyECCSignerImpl
31 CDummyECCSignerImpl* CDummyECCSignerImpl::NewL(const CKey& aKey,
34 CDummyECCSignerImpl* self =
35 CDummyECCSignerImpl::NewLC(aKey, aPaddingMode);
36 CleanupStack::Pop(self);
40 CDummyECCSignerImpl* CDummyECCSignerImpl::NewLC(const CKey& aKey,
43 CDummyECCSignerImpl* self =
44 new (ELeave) CDummyECCSignerImpl(aPaddingMode);
45 CleanupStack::PushL(self);
46 self->ConstructL(aKey);
50 CDummyECCSignerImpl::CDummyECCSignerImpl(TUid aPaddingMode) :
51 iPaddingMode(aPaddingMode)
55 CDummyECCSignerImpl::~CDummyECCSignerImpl()
60 void CDummyECCSignerImpl::ConstructL(const CKey& aKey)
66 void CDummyECCSignerImpl::Close()
70 void CDummyECCSignerImpl::Reset()
73 void CDummyECCSignerImpl::GetCharacteristicsL(
74 const TCharacteristics*& aPluginCharacteristics)
76 TInt numCiphers = sizeof(KSignerCharacteristics)
77 / sizeof(TAsymmetricSignatureCharacteristics*);
78 TInt32 implUid = ImplementationUid().iUid;
79 for (TInt i = 0; i < numCiphers; ++i)
81 if (KSignerCharacteristics[i]->cmn.iImplementationUID == implUid)
83 aPluginCharacteristics = KSignerCharacteristics[i];
89 const CExtendedCharacteristics* CDummyECCSignerImpl::GetExtendedCharacteristicsL()
91 // All Symbian software plug-ins have unlimited concurrency, cannot be reserved
92 // for exclusive use and are not CERTIFIED to be standards compliant.
93 return CExtendedCharacteristics::NewL(KMaxTInt, EFalse);
96 TAny* CDummyECCSignerImpl::GetExtension(TUid /* aExtensionId */)
100 // End of MPlugin Interface
102 // MSignatureBase Interface
103 void CDummyECCSignerImpl::SetPaddingModeL(TUid /* aPaddingMode */)
105 User::Leave(KErrNotSupported);
108 void CDummyECCSignerImpl::SetKeyL(const CKey& aKey)
110 // delete any previous key and recreate the key
113 iKey = CKey::NewL(aKey);
116 TInt CDummyECCSignerImpl::GetMaximumInputLengthL() const
118 return KMaxSignerInputLength;
121 TInt CDummyECCSignerImpl::GetMaximumOutputLengthL() const
123 return KMaxSignerOutputLength;
126 TUid CDummyECCSignerImpl::ImplementationUid() const
128 return KCryptoPluginEccSignerUid;
131 void CDummyECCSignerImpl::SignL(const TDesC8& aInput,
132 CCryptoParams& aSignature)
134 if (iKey->IsPresent(KPassedHandleToKeyUid))
136 const TInt keyHandle = iKey->GetTIntL(KPassedHandleToKeyUid);
138 // Invoke the Spi HAI to perform the operation
139 CCryptoSpiHai::SignL(keyHandle, aInput, aSignature);
143 User::Leave(KErrNotSupported);