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