Update contrib.
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #ifndef __RIJNDAELIMPL_H__
20 #define __RIJNDAELIMPL_H__
30 #include <cryptospi/keys.h>
31 #include "symmetriccipherimpl.h"
34 Plug-in class for AES (Rijndael) block cipher
36 namespace SoftwareCrypto
38 NONSHARABLE_CLASS(CRijndaelImpl) : public CSymmetricBlockCipherImpl
43 Creates an instance of an AES (Rijndael) symmetric cipher plug-in.
45 @param aCryptoMode Whether to encrypt or decrypt
46 @param aOperationMode The block cipher mode ECB, CBC, CTR etc
47 @param aPadding The padding scheme to use None, SSLv3, PKCS#7
48 @return A pointer to a CRijndaelImpl instance
50 static CRijndaelImpl* NewL(const CryptoSpi::CKey& aKey,
51 TUid aCryptoMode, TUid aOperationMode, TUid aPadding, TUid aImplementationUid);
54 Creates an instance of an AES (Rijndael) symmetric cipher plug-in.
55 A pointer to the plug-in instance is placed on the cleanup stack.
57 @param aCryptoMode Whether to encrypt or decrypt
58 @param aOperationMode The block cipher mode ECB, CBC, CTR etc
59 @param aPadding The padding scheme to use None, SSLv3, PKCS#7
60 @return A pointer to a CRijndaelImpl instance
62 static CRijndaelImpl* NewLC(const CryptoSpi::CKey& aKey,
63 TUid aCryptoMode, TUid aOperationMode, TUid aPadding, TUid aImplementationUid);
65 // From CSymmetricCipherImpl
66 TBool IsValidKeyLength(TInt aKeyBytes) const;
67 TUid ImplementationUid() const;
69 const CExtendedCharacteristics* GetExtendedCharacteristicsL();
70 static CExtendedCharacteristics* CreateExtendedCharacteristicsL();
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
82 CRijndaelImpl(TUid aOperationMode, TUid aCryptoMode, TUid aPaddingMode,
83 TUid aImplementationUid);
85 /// second phase of construction
86 void ConstructL(const CryptoSpi::CKey& aKey);
89 Creates the key schedule iK from CBlockTransformationImpl::iKey.
90 This should be called from ConstructL and Reset
92 void SetKeySchedule();
95 Setup the key schedule for encryption
96 @param aKey The input key
97 @param aKeySchedule The pointer to the key schedule buffer
99 void SetEncryptKeySchedule(const TDesC8& aKey, TUint32* aKeySchedule);
102 Setup the key schedule for decryption
103 @param aKey The input key
104 @param aKeySchedule The pointer to the key schedule buffer
106 void SetDecryptKeySchedule(const TDesC8& aKey, TUint32* aKeySchedule);
108 // From CSymmetricBlockCipherImpl
109 void TransformEncrypt(TUint8* aBuffer, TUint aNumBlocks);
110 void TransformDecrypt(TUint8* aBuffer, TUint aNumBlocks);
115 The key-schedule size in WORDS
117 The maximum size is (((KAESMaxBlockSize/4)+6)+1)*4
119 static const TUint32 KKeyScheduleSize = 60;
122 TUint32 iK[KKeyScheduleSize];
126 TUid iImplementationUid;
130 #endif //__RIJNDAELIMPL_H__