First public contribution.
2 * Copyright (c) 2006-2009 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__
31 #include "symmetriccipherimpl.h"
34 Plug-in class for AES (Rijndael) block cipher
36 namespace SoftwareCrypto
38 using namespace CryptoSpi;
40 NONSHARABLE_CLASS(CRijndaelImpl) : public CSymmetricBlockCipherImpl
44 Creates an instance of an AES (Rijndael) symmetric cipher plug-in.
46 @param aCryptoMode Whether to encrypt or decrypt
47 @param aOperationMode The block cipher mode ECB, CBC, CTR etc
48 @param aPadding The padding scheme to use None, SSLv3, PKCS#7
49 @return A pointer to a CRijndaelImpl instance
51 static CRijndaelImpl* NewL(const CKey& aKey,
52 TUid aCryptoMode, TUid aOperationMode, TUid aPadding);
55 Creates an instance of an AES (Rijndael) symmetric cipher plug-in.
56 A pointer to the plug-in instance is placed on the cleanup stack.
58 @param aCryptoMode Whether to encrypt or decrypt
59 @param aOperationMode The block cipher mode ECB, CBC, CTR etc
60 @param aPadding The padding scheme to use None, SSLv3, PKCS#7
61 @return A pointer to a CRijndaelImpl instance
63 static CRijndaelImpl* NewLC(const CKey& aKey,
64 TUid aCryptoMode, TUid aOperationMode, TUid aPadding);
66 // From CSymmetricCipherImpl
67 TBool IsValidKeyLength(TInt aKeyBytes) const;
68 TUid ImplementationUid() const;
69 const CExtendedCharacteristics* GetExtendedCharacteristicsL();
71 static CExtendedCharacteristics* CreateExtendedCharacteristicsL();
79 @param aOperationMode The mode of operation e.g. CBC
80 @param aCryptoMode Whether to encrypt or decrypt
81 @param aPaddingMode The padding mode to use. None, SSL, PKCS#7
83 CRijndaelImpl(TUid aOperationMode, TUid aCryptoMode, TUid aPaddingMode);
85 /// second phase of construction
86 void ConstructL(const 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];
128 #endif //__RIJNDAELIMPL_H__