os/security/crypto/weakcryptospi/test/tplugins/src/tplugin01/pluginentry.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/crypto/weakcryptospi/test/tplugins/src/tplugin01/pluginentry.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,281 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* plugin entry implementation
    1.19 +* plugin entry implementation
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +/**
    1.25 + @file
    1.26 +*/
    1.27 +
    1.28 +#include "pluginentry.h"
    1.29 +#include "pluginconfig.h"
    1.30 +#include "md2impl.h"
    1.31 +#include "hmacimpl.h"
    1.32 +#include <cryptospi/keys.h>
    1.33 +#include "desimpl.h"
    1.34 +#include "rsakeypairgenextendimpl.h"
    1.35 +#include "rsaverifyimpl.h"
    1.36 +#include <cryptospi/cryptospidef.h>
    1.37 +
    1.38 +#ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
    1.39 +#include "macimpl.h"
    1.40 +#include "rijndaelimpl.h"
    1.41 +#endif
    1.42 +
    1.43 +using namespace SoftwareCrypto;
    1.44 +
    1.45 +EXPORT_C const TCharacteristics** CCryptoPluginEntry::Enumerate(TUid aInterface, TInt& aNumPlugins)
    1.46 +	{
    1.47 +	const TCharacteristics** ptr(0);
    1.48 +	switch (aInterface.iUid)
    1.49 +		{
    1.50 +	case KHashInterface:
    1.51 +		{
    1.52 +		aNumPlugins=sizeof(KHashCharacteristics)/sizeof(THashCharacteristics*);
    1.53 +		ptr = (const TCharacteristics**) &KHashCharacteristics[0];			
    1.54 +		}
    1.55 +		break;
    1.56 +		
    1.57 +#ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
    1.58 +	case KMacInterface:
    1.59 +		{
    1.60 +		aNumPlugins=sizeof(KMacCharacteristics)/sizeof(TMacCharacteristics*);
    1.61 +		ptr = (const TCharacteristics**) &KMacCharacteristics[0];
    1.62 +		}
    1.63 +		break;
    1.64 +#endif
    1.65 +
    1.66 +	case KSymmetricCipherInterface:
    1.67 +		{
    1.68 +		aNumPlugins=sizeof(KSymmetricCipherCharacteristics)/sizeof(TSymmetricCipherCharacteristics*);
    1.69 +		ptr = (const TCharacteristics**) &KSymmetricCipherCharacteristics[0];			
    1.70 +		}
    1.71 +		break;
    1.72 +		
    1.73 +	case KKeypairGeneratorInterface:
    1.74 +		{
    1.75 +		aNumPlugins=sizeof(KKeyPairGeneratorCharacteristics)/sizeof(TAsymmetricKeypairGeneratorCharacteristics*);
    1.76 +		ptr = (const TCharacteristics**) &KKeyPairGeneratorCharacteristics[0];			
    1.77 +		}
    1.78 +		break;
    1.79 +		
    1.80 +	case KVerifierInterface:
    1.81 +		{
    1.82 +		aNumPlugins=sizeof(KVerifierCharacteristics)/sizeof(TAsymmetricSignatureCharacteristics*);
    1.83 +		ptr = (const TCharacteristics**) &KVerifierCharacteristics[0];
    1.84 +		}
    1.85 +		break;
    1.86 +		
    1.87 +	default:;
    1.88 +		}
    1.89 +		
    1.90 +	return ptr;
    1.91 +	}
    1.92 +
    1.93 +
    1.94 +EXPORT_C void CCryptoPluginEntry::GetExtendedCharacteristicsL(TUid aImplementationUid, CExtendedCharacteristics*& aExt)
    1.95 +	{
    1.96 +	switch (aImplementationUid.iUid)
    1.97 +		{
    1.98 +		case KTestPlugin01Md2_1:
    1.99 +		case KTestPlugin01Md2_2:
   1.100 +#ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
   1.101 +		case KTestPlugin01MacMd2_1:
   1.102 +		case KTestPlugin01MacMd2_2:
   1.103 +#endif
   1.104 +			{
   1.105 +			aExt = CMD2Impl::CreateExtendedCharacteristicsL();	
   1.106 +			}
   1.107 +		   	break;
   1.108 +
   1.109 +		case KTestPlugin01Des_1:
   1.110 +		case KTestPlugin01Des_2:
   1.111 +		case KTestPlugin01Des_3:
   1.112 +		case KTestPlugin01Des_4:
   1.113 +			{
   1.114 +			aExt = CDesImpl::CreateExtendedCharacteristicsL();	
   1.115 +			}
   1.116 +		   	break;
   1.117 +	   
   1.118 +		case KTestPlugin01RsaKeyGen_1:
   1.119 +			{
   1.120 +			aExt = CRSAKeyPairGenExtendImpl::CreateExtendedCharacteristicsL();
   1.121 +			}
   1.122 +		   	break;
   1.123 +	   
   1.124 +		case KTestPlugin01RsaVerifier_1:
   1.125 +		case KTestPlugin01RsaVerifier_2:
   1.126 +			{
   1.127 +			aExt = CRSAVerifierImpl::CreateExtendedCharacteristicsL();	
   1.128 +			}
   1.129 +		   	break;
   1.130 +
   1.131 +#ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
   1.132 +		case KTestPlugin01XcbcMac96:
   1.133 +		case KTestPlugin01Aes:
   1.134 +			{
   1.135 +			aExt = CRijndaelImpl::CreateExtendedCharacteristicsL();
   1.136 +			}
   1.137 +			break;
   1.138 +#endif
   1.139 +			
   1.140 +		default:
   1.141 +			{
   1.142 +			User::Leave(KErrNotSupported);	
   1.143 +			}
   1.144 +		}
   1.145 +	}
   1.146 +	
   1.147 +	
   1.148 +EXPORT_C void CCryptoPluginEntry::CreateAsymmetricCipherL(MAsymmetricCipher*& /*aPlugin*/,
   1.149 +														TUid /*aImplementationId*/,
   1.150 +														const CKey& /*aKey*/,
   1.151 +														TUid /*aCryptoMode*/,
   1.152 +														TUid /*aPaddingMode*/,
   1.153 +														const CCryptoParams* /*aAlgorithmParams*/)
   1.154 +	{
   1.155 +	User::Leave(KErrNotFound);
   1.156 +	}
   1.157 +														
   1.158 +														
   1.159 +														
   1.160 +EXPORT_C void CCryptoPluginEntry::CreateAsymmetricSignerL(MSigner*& /*aPlugin*/,
   1.161 +														TUid /*aImplementationId*/,
   1.162 +														const CKey& /*aKey*/,
   1.163 +														TUid /*aPaddingMode*/,
   1.164 +														const CCryptoParams* /*aAlgorithmParams*/)
   1.165 +	{
   1.166 +	User::Leave(KErrNotFound);
   1.167 +	}
   1.168 +														
   1.169 +														
   1.170 +														
   1.171 +														
   1.172 +EXPORT_C void CCryptoPluginEntry::CreateAsymmetricVerifierL(MVerifier*& aPlugin,
   1.173 +															TUid aImplementationId,
   1.174 +															const CKey& aKey,
   1.175 +															TUid aPaddingMode,
   1.176 +															const CCryptoParams* /*aAlgorithmParams*/)
   1.177 +	{
   1.178 +	switch (aImplementationId.iUid)
   1.179 +		{
   1.180 +		
   1.181 +		case KTestPlugin01RsaVerifier_1:
   1.182 +		case KTestPlugin01RsaVerifier_2:
   1.183 +			aPlugin = CRSAVerifierImpl::NewL(aImplementationId, aKey, aPaddingMode);
   1.184 +			break;
   1.185 +			
   1.186 +		default:
   1.187 +			User::Leave(KErrNotFound);
   1.188 +		}
   1.189 +	}																
   1.190 +
   1.191 +EXPORT_C void CCryptoPluginEntry::CreateHashL(MHash*& aPlugin,
   1.192 +											TUid aImplementationId,
   1.193 +											TUid aOperationMode,
   1.194 +											const CKey* aKey,
   1.195 +											const CCryptoParams* /*aAlgorithmParams*/)
   1.196 +	{
   1.197 +	aPlugin=CSoftwareHash::NewL(aImplementationId, aOperationMode, aKey);
   1.198 +	}
   1.199 +
   1.200 +#ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
   1.201 +EXPORT_C void CCryptoPluginEntry::CreateHashL(MHash*& aPlugin,
   1.202 +											TUid aImplementationId,
   1.203 +											const CCryptoParams* /*aAlgorithmParams*/)
   1.204 +	{
   1.205 +	aPlugin=CSoftwareHash::NewL(aImplementationId);
   1.206 +	}
   1.207 +
   1.208 +EXPORT_C void CCryptoPluginEntry::CreateMacL(MMac*& aPlugin,
   1.209 +											const TUid aImplementationId,
   1.210 +											const CKey& aKey,
   1.211 +											const CCryptoParams* aAlgorithmParams)
   1.212 +	{
   1.213 +	aPlugin=CMacImpl::NewL(aKey, aImplementationId, aAlgorithmParams);
   1.214 +	}
   1.215 +#endif
   1.216 +
   1.217 +
   1.218 +EXPORT_C void CCryptoPluginEntry::CreateKeyAgreementL(MKeyAgreement*& /*aPlugin*/,
   1.219 +														TUid /*aImplementationId*/,
   1.220 +														const CKey& /*aPrivateKey*/,
   1.221 +														const CCryptoParams* /*aAlgorithmParams*/)
   1.222 +	{
   1.223 +	User::Leave(KErrNotFound);	
   1.224 +	}
   1.225 +														
   1.226 +EXPORT_C void CCryptoPluginEntry::CreateKeyPairGeneratorL(MKeyPairGenerator*& aPlugin,
   1.227 +														TUid aImplementationId,
   1.228 +														const CCryptoParams* /*aAlgorithmParams*/)
   1.229 +	{
   1.230 +	//create requested key pair generator implementation in this plugin
   1.231 +	switch (aImplementationId.iUid)
   1.232 +		{
   1.233 +			
   1.234 +		case KTestPlugin01RsaKeyGen_1:
   1.235 +			{
   1.236 +			aPlugin = CRSAKeyPairGenExtendImpl::NewL(aImplementationId);
   1.237 +			}
   1.238 +			break;
   1.239 +			
   1.240 +		default:
   1.241 +			User::Leave(KErrNotFound);
   1.242 +			}		
   1.243 +	}
   1.244 +	
   1.245 +														
   1.246 +EXPORT_C void CCryptoPluginEntry::CreateRandomL(MRandom*& /*aPlugin*/,
   1.247 +												TUid /*aImplementationId*/,
   1.248 +												const CCryptoParams* /*aAlgorithmParams*/)
   1.249 +	{
   1.250 +	User::Leave(KErrNotFound);
   1.251 +	}	
   1.252 +
   1.253 +EXPORT_C void CCryptoPluginEntry::CreateSymmetricCipherL(MSymmetricCipher*& aPlugin,
   1.254 +														TUid aImplementationId,
   1.255 +														const CKey& aKey,
   1.256 +														TUid aCryptoMode,
   1.257 +														TUid aOperationMode,
   1.258 +														TUid aPadding,
   1.259 +														const CCryptoParams* /*aAlgorithmParams*/)
   1.260 +	{
   1.261 +	switch (aImplementationId.iUid)
   1.262 +		{
   1.263 +		case KTestPlugin01Des_1:
   1.264 +		case KTestPlugin01Des_2:
   1.265 +		case KTestPlugin01Des_3:
   1.266 +		case KTestPlugin01Des_4:
   1.267 +			{
   1.268 +			aPlugin=CDesImpl::NewL(aImplementationId, aKey, aCryptoMode, aOperationMode, aPadding);
   1.269 +			}	
   1.270 +			break;		
   1.271 +
   1.272 +#ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
   1.273 +		case KTestPlugin01Aes:
   1.274 +			{
   1.275 +			aPlugin=CRijndaelImpl::NewL(aKey, aCryptoMode, aOperationMode, aPadding, KTestPlugin01AesUid);
   1.276 +			}
   1.277 +			break;
   1.278 +#endif
   1.279 +			
   1.280 +		default:
   1.281 +			User::Leave(KErrNotFound);
   1.282 +			}
   1.283 +	}
   1.284 +