crypto/weakcryptospi/test/tplugins/inc/rsaimpl.h
changeset 8 35751d3474b7
child 49 2f10d260163b
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2006-2009 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 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __RSAIMPL_H__
       
    20 #define __RSAIMPL_H__
       
    21 
       
    22 /**
       
    23 @file 
       
    24 @internalComponent
       
    25 @released
       
    26 */
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <e32cmn.h>
       
    30 #include "keys.h"
       
    31 #include "asymmetriccipherimpl.h"
       
    32 
       
    33 /**
       
    34  * Implementation of RSA encryption as described in PKCS#1 v1.5.
       
    35  */
       
    36 namespace SoftwareCrypto
       
    37 	{
       
    38 	using namespace CryptoSpi;
       
    39 
       
    40 	NONSHARABLE_CLASS(CRSAImpl) : public CAsymmetricCipherImpl
       
    41 		{
       
    42 	public:
       
    43 	
       
    44 		/**
       
    45 		Creates an instance of an RSA asymmetric cipher plug-in.
       
    46 		@param aKey The key
       
    47 		@param aCryptoMode Whether to encrypt or decrypt
       
    48 		@param aPadding The padding scheme to use None, SSLv3, PKCS#7
       
    49 		@return A pointer to a CRSAImpl instance
       
    50 		*/
       
    51 		static CRSAImpl* NewL(TUid aImplementationUid, const CKey& aKey,
       
    52 			TUid aCryptoMode, TUid aPadding);
       
    53 
       
    54 		/**
       
    55 		Creates an instance of an RSA asymmetric cipher plug-in.
       
    56 		A pointer to the plug-in instance is placed on the cleanup stack.
       
    57 		@param aKey The key
       
    58 		@param aCryptoMode Whether to encrypt or decrypt
       
    59 		@param aPadding The padding scheme to use None, SSLv3, PKCS#7
       
    60 		@return A pointer to a CRSAImpl instance
       
    61 		*/
       
    62 		static CRSAImpl* NewLC(TUid aImplementationUid, const CKey& aKey,
       
    63 			TUid aCryptoMode, TUid aPadding);
       
    64 
       
    65 		// Override CAsymmetricCipherImpl virtual functions
       
    66 		TUid ImplementationUid() const;
       
    67 		TBool IsValidKeyLengthL(TInt aKeyBytes) const;
       
    68 		TInt GetMaximumInputLengthL() const;
       
    69 		TInt GetMaximumOutputLengthL() const;
       
    70 		void ProcessL(const TDesC8& aInput, TDes8& aOutput);
       
    71 		// End of CAsymmetricCipherImpl
       
    72 		
       
    73 		const CExtendedCharacteristics* GetExtendedCharacteristicsL();
       
    74 		static CExtendedCharacteristics* CreateExtendedCharacteristicsL();
       
    75 
       
    76 		// Destructor
       
    77 		~CRSAImpl();
       
    78 
       
    79 	private:
       
    80 		/**
       
    81 		Constructor
       
    82 		@param aCryptoMode Whether to encrypt or decrypt
       
    83 		@param aPaddingMode The padding mode to use. None, SSL, PKCS#7
       
    84 		*/
       
    85 		CRSAImpl(TUid aImplementationUid, TUid aCryptoMode, TUid aPaddingMode);
       
    86 			
       
    87 		/// second phase of construction
       
    88 		void ConstructL(const CKey& aKey);
       
    89 		
       
    90 		/// for internal usage, called from ProcessL
       
    91 		void EncryptL(const TDesC8& aInput, TDes8& aOutput) const;
       
    92 		void DecryptL(const TDesC8& aInput, TDes8& aOutput) const;
       
    93 		
       
    94 	private:
       
    95 	
       
    96 		TUid iImplementationUid; 
       
    97 
       
    98 		};
       
    99 	}
       
   100 
       
   101 #endif // __RSAIMPL_H__