os/security/crypto/weakcryptospi/test/tplugins/src/tplugin01/pluginentry.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2007-2010 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 * plugin entry implementation
    16 * plugin entry implementation
    17 *
    18 */
    19 
    20 
    21 /**
    22  @file
    23 */
    24 
    25 #include "pluginentry.h"
    26 #include "pluginconfig.h"
    27 #include "md2impl.h"
    28 #include "hmacimpl.h"
    29 #include <cryptospi/keys.h>
    30 #include "desimpl.h"
    31 #include "rsakeypairgenextendimpl.h"
    32 #include "rsaverifyimpl.h"
    33 #include <cryptospi/cryptospidef.h>
    34 
    35 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
    36 #include "macimpl.h"
    37 #include "rijndaelimpl.h"
    38 #endif
    39 
    40 using namespace SoftwareCrypto;
    41 
    42 EXPORT_C const TCharacteristics** CCryptoPluginEntry::Enumerate(TUid aInterface, TInt& aNumPlugins)
    43 	{
    44 	const TCharacteristics** ptr(0);
    45 	switch (aInterface.iUid)
    46 		{
    47 	case KHashInterface:
    48 		{
    49 		aNumPlugins=sizeof(KHashCharacteristics)/sizeof(THashCharacteristics*);
    50 		ptr = (const TCharacteristics**) &KHashCharacteristics[0];			
    51 		}
    52 		break;
    53 		
    54 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
    55 	case KMacInterface:
    56 		{
    57 		aNumPlugins=sizeof(KMacCharacteristics)/sizeof(TMacCharacteristics*);
    58 		ptr = (const TCharacteristics**) &KMacCharacteristics[0];
    59 		}
    60 		break;
    61 #endif
    62 
    63 	case KSymmetricCipherInterface:
    64 		{
    65 		aNumPlugins=sizeof(KSymmetricCipherCharacteristics)/sizeof(TSymmetricCipherCharacteristics*);
    66 		ptr = (const TCharacteristics**) &KSymmetricCipherCharacteristics[0];			
    67 		}
    68 		break;
    69 		
    70 	case KKeypairGeneratorInterface:
    71 		{
    72 		aNumPlugins=sizeof(KKeyPairGeneratorCharacteristics)/sizeof(TAsymmetricKeypairGeneratorCharacteristics*);
    73 		ptr = (const TCharacteristics**) &KKeyPairGeneratorCharacteristics[0];			
    74 		}
    75 		break;
    76 		
    77 	case KVerifierInterface:
    78 		{
    79 		aNumPlugins=sizeof(KVerifierCharacteristics)/sizeof(TAsymmetricSignatureCharacteristics*);
    80 		ptr = (const TCharacteristics**) &KVerifierCharacteristics[0];
    81 		}
    82 		break;
    83 		
    84 	default:;
    85 		}
    86 		
    87 	return ptr;
    88 	}
    89 
    90 
    91 EXPORT_C void CCryptoPluginEntry::GetExtendedCharacteristicsL(TUid aImplementationUid, CExtendedCharacteristics*& aExt)
    92 	{
    93 	switch (aImplementationUid.iUid)
    94 		{
    95 		case KTestPlugin01Md2_1:
    96 		case KTestPlugin01Md2_2:
    97 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
    98 		case KTestPlugin01MacMd2_1:
    99 		case KTestPlugin01MacMd2_2:
   100 #endif
   101 			{
   102 			aExt = CMD2Impl::CreateExtendedCharacteristicsL();	
   103 			}
   104 		   	break;
   105 
   106 		case KTestPlugin01Des_1:
   107 		case KTestPlugin01Des_2:
   108 		case KTestPlugin01Des_3:
   109 		case KTestPlugin01Des_4:
   110 			{
   111 			aExt = CDesImpl::CreateExtendedCharacteristicsL();	
   112 			}
   113 		   	break;
   114 	   
   115 		case KTestPlugin01RsaKeyGen_1:
   116 			{
   117 			aExt = CRSAKeyPairGenExtendImpl::CreateExtendedCharacteristicsL();
   118 			}
   119 		   	break;
   120 	   
   121 		case KTestPlugin01RsaVerifier_1:
   122 		case KTestPlugin01RsaVerifier_2:
   123 			{
   124 			aExt = CRSAVerifierImpl::CreateExtendedCharacteristicsL();	
   125 			}
   126 		   	break;
   127 
   128 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
   129 		case KTestPlugin01XcbcMac96:
   130 		case KTestPlugin01Aes:
   131 			{
   132 			aExt = CRijndaelImpl::CreateExtendedCharacteristicsL();
   133 			}
   134 			break;
   135 #endif
   136 			
   137 		default:
   138 			{
   139 			User::Leave(KErrNotSupported);	
   140 			}
   141 		}
   142 	}
   143 	
   144 	
   145 EXPORT_C void CCryptoPluginEntry::CreateAsymmetricCipherL(MAsymmetricCipher*& /*aPlugin*/,
   146 														TUid /*aImplementationId*/,
   147 														const CKey& /*aKey*/,
   148 														TUid /*aCryptoMode*/,
   149 														TUid /*aPaddingMode*/,
   150 														const CCryptoParams* /*aAlgorithmParams*/)
   151 	{
   152 	User::Leave(KErrNotFound);
   153 	}
   154 														
   155 														
   156 														
   157 EXPORT_C void CCryptoPluginEntry::CreateAsymmetricSignerL(MSigner*& /*aPlugin*/,
   158 														TUid /*aImplementationId*/,
   159 														const CKey& /*aKey*/,
   160 														TUid /*aPaddingMode*/,
   161 														const CCryptoParams* /*aAlgorithmParams*/)
   162 	{
   163 	User::Leave(KErrNotFound);
   164 	}
   165 														
   166 														
   167 														
   168 														
   169 EXPORT_C void CCryptoPluginEntry::CreateAsymmetricVerifierL(MVerifier*& aPlugin,
   170 															TUid aImplementationId,
   171 															const CKey& aKey,
   172 															TUid aPaddingMode,
   173 															const CCryptoParams* /*aAlgorithmParams*/)
   174 	{
   175 	switch (aImplementationId.iUid)
   176 		{
   177 		
   178 		case KTestPlugin01RsaVerifier_1:
   179 		case KTestPlugin01RsaVerifier_2:
   180 			aPlugin = CRSAVerifierImpl::NewL(aImplementationId, aKey, aPaddingMode);
   181 			break;
   182 			
   183 		default:
   184 			User::Leave(KErrNotFound);
   185 		}
   186 	}																
   187 
   188 EXPORT_C void CCryptoPluginEntry::CreateHashL(MHash*& aPlugin,
   189 											TUid aImplementationId,
   190 											TUid aOperationMode,
   191 											const CKey* aKey,
   192 											const CCryptoParams* /*aAlgorithmParams*/)
   193 	{
   194 	aPlugin=CSoftwareHash::NewL(aImplementationId, aOperationMode, aKey);
   195 	}
   196 
   197 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
   198 EXPORT_C void CCryptoPluginEntry::CreateHashL(MHash*& aPlugin,
   199 											TUid aImplementationId,
   200 											const CCryptoParams* /*aAlgorithmParams*/)
   201 	{
   202 	aPlugin=CSoftwareHash::NewL(aImplementationId);
   203 	}
   204 
   205 EXPORT_C void CCryptoPluginEntry::CreateMacL(MMac*& aPlugin,
   206 											const TUid aImplementationId,
   207 											const CKey& aKey,
   208 											const CCryptoParams* aAlgorithmParams)
   209 	{
   210 	aPlugin=CMacImpl::NewL(aKey, aImplementationId, aAlgorithmParams);
   211 	}
   212 #endif
   213 
   214 
   215 EXPORT_C void CCryptoPluginEntry::CreateKeyAgreementL(MKeyAgreement*& /*aPlugin*/,
   216 														TUid /*aImplementationId*/,
   217 														const CKey& /*aPrivateKey*/,
   218 														const CCryptoParams* /*aAlgorithmParams*/)
   219 	{
   220 	User::Leave(KErrNotFound);	
   221 	}
   222 														
   223 EXPORT_C void CCryptoPluginEntry::CreateKeyPairGeneratorL(MKeyPairGenerator*& aPlugin,
   224 														TUid aImplementationId,
   225 														const CCryptoParams* /*aAlgorithmParams*/)
   226 	{
   227 	//create requested key pair generator implementation in this plugin
   228 	switch (aImplementationId.iUid)
   229 		{
   230 			
   231 		case KTestPlugin01RsaKeyGen_1:
   232 			{
   233 			aPlugin = CRSAKeyPairGenExtendImpl::NewL(aImplementationId);
   234 			}
   235 			break;
   236 			
   237 		default:
   238 			User::Leave(KErrNotFound);
   239 			}		
   240 	}
   241 	
   242 														
   243 EXPORT_C void CCryptoPluginEntry::CreateRandomL(MRandom*& /*aPlugin*/,
   244 												TUid /*aImplementationId*/,
   245 												const CCryptoParams* /*aAlgorithmParams*/)
   246 	{
   247 	User::Leave(KErrNotFound);
   248 	}	
   249 
   250 EXPORT_C void CCryptoPluginEntry::CreateSymmetricCipherL(MSymmetricCipher*& aPlugin,
   251 														TUid aImplementationId,
   252 														const CKey& aKey,
   253 														TUid aCryptoMode,
   254 														TUid aOperationMode,
   255 														TUid aPadding,
   256 														const CCryptoParams* /*aAlgorithmParams*/)
   257 	{
   258 	switch (aImplementationId.iUid)
   259 		{
   260 		case KTestPlugin01Des_1:
   261 		case KTestPlugin01Des_2:
   262 		case KTestPlugin01Des_3:
   263 		case KTestPlugin01Des_4:
   264 			{
   265 			aPlugin=CDesImpl::NewL(aImplementationId, aKey, aCryptoMode, aOperationMode, aPadding);
   266 			}	
   267 			break;		
   268 
   269 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
   270 		case KTestPlugin01Aes:
   271 			{
   272 			aPlugin=CRijndaelImpl::NewL(aKey, aCryptoMode, aOperationMode, aPadding, KTestPlugin01AesUid);
   273 			}
   274 			break;
   275 #endif
   276 			
   277 		default:
   278 			User::Leave(KErrNotFound);
   279 			}
   280 	}
   281