os/security/cryptoplugins/cryptospiplugins/test/h4drv/crypto_h4_plugin/rijndaelimpl.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2007-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 /**
    20  @file
    21  @internalComponent
    22  @released
    23 */
    24 #ifndef	__RIJNDAELIMPL_H__
    25 #define	__RIJNDAELIMPL_H__
    26 #include <e32base.h>
    27 #include <e32cmn.h>
    28 #include "keys.h"
    29 #include "h4cipherimpl.h"
    30 #include "cryptodriver.h"
    31 
    32 /**
    33 Plug-in class for AES (Rijndael) block cipher
    34 */
    35 namespace HwCrypto
    36 	{
    37 	class __NOTSHARED CH4RijndaelImpl : public CH4CipherImpl
    38 		{
    39 	public:
    40 	
    41 		/**
    42 		Creates an instance of an AES (Rijndael) symmetric cipher plug-in.
    43 		@param aKey The key
    44 		@param aCryptoMode Whether to encrypt or decrypt
    45 		@param aOperationMode The block cipher mode ECB, CBC, CTR etc
    46 		@param aPadding The padding scheme to use None, SSLv3, PKCS#7
    47 		@return A pointer to a CH4RijndaelImpl instance
    48 		*/
    49 		static CH4RijndaelImpl* NewL(const CryptoSpi::CKey& aKey, 
    50 			TUid aCryptoMode, TUid aOperationMode, TUid aPadding);
    51 
    52 		/**
    53 		Creates an instance of an AES (Rijndael) symmetric cipher plug-in.
    54 		A pointer to the plug-in instance is placed on the cleanup stack.
    55 		@param aKey The key
    56 		@param aCryptoMode Whether to encrypt or decrypt
    57 		@param aOperationMode The block cipher mode ECB, CBC, CTR etc
    58 		@param aPadding The padding scheme to use None, SSLv3, PKCS#7
    59 		@return A pointer to a CH4RijndaelImpl instance
    60 		*/
    61 		static CH4RijndaelImpl* NewLC(const CryptoSpi::CKey& aKey, 
    62 			TUid aCryptoMode,	TUid aOperationMode, TUid aPadding);
    63 
    64 		// From CSymmetricCipherImpl
    65 		TBool IsValidKeyLength(TInt aKeyBytes) const;
    66 		TUid ImplementationUid() const;
    67 
    68 		const CExtendedCharacteristics* GetExtendedCharacteristicsL();
    69 		
    70 		static CExtendedCharacteristics* StaticGetExtendedCharacteristicsL();
    71 		
    72 		/// Destructor
    73 		~CH4RijndaelImpl();
    74 
    75 	private:
    76 		/**
    77 		Constructor
    78 		@param aOperationMode The mode of operation e.g. CBC
    79 		@param aCryptoMode Whether to encrypt or decrypt
    80 		@param aPaddingMode The padding mode to use. None, SSL, PKCS#7
    81 		*/
    82 		CH4RijndaelImpl(TUid aOperationMode, TUid aCryptoMode, TUid aPaddingMode);
    83 			
    84 		///	second phase of construction	
    85 		void ConstructL(const CryptoSpi::CKey& aKey);
    86 					
    87 		// From CH4CipherImpl
    88 		virtual void DoSetupL();
    89 		virtual void DoWriteL(const TUint8* aBuffer, TUint aNumBytes);
    90 		virtual void DoReadL(TDes8 &aBuffer, TUint32 aLength);
    91 				
    92 	private:
    93 		RCryptoDriver iDriver;
    94 		TBool iDriverOpen;
    95 		};
    96 	}
    97 
    98 #endif //__RIJNDAELIMPL_H__