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 __3DESIMPL_H__
20 #define __3DESIMPL_H__
34 Plug-in class for 3DES block cipher
36 namespace SoftwareCrypto
38 using namespace CryptoSpi;
40 NONSHARABLE_CLASS(C3DesImpl) : public CDesImpl
44 Creates an instance of a 3DES (Data Encryption Standard) 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 C3DesImpl instance
51 static C3DesImpl* NewL(const CKey& aKey,
52 TUid aCryptoMode, TUid aOperationMode, TUid aPadding);
55 Creates an instance of a 3DES (Data Encryption Standard) 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 C3DesImpl instance
63 static C3DesImpl* NewLC(const CKey& aKey,
64 TUid aCryptoMode, TUid aOperationMode, TUid aPadding);
66 // From CSymmetricCipherImpl
67 TBool IsValidKeyLength(TInt aKeyBytes) const;
68 TInt GetKeyStrength() const;
69 TUid ImplementationUid() const;
70 const CExtendedCharacteristics* GetExtendedCharacteristicsL();
72 static CExtendedCharacteristics* CreateExtendedCharacteristicsL();
80 @param aOperationMode The mode of operation e.g. CBC
81 @param aCryptoMode Whether to encrypt or decrypt
82 @param aPaddingMode The padding mode to use. None, SSL, PKCS#7
84 C3DesImpl(TUid aOperationMode, TUid aCryptoMode, TUid aPaddingMode);
86 /// second phase of construction
87 void ConstructL(const CKey& aKey);
90 Creates the key schedules iK1, iK2, iK3 from CBlockTransformationImpl::iKey.
91 This should be called from ConstructL and Reset
93 void SetKeySchedule();
95 // From CSymmetricBlockCipherImpl
96 void TransformEncrypt(TUint8* aBuffer, TUint aNumBlocks);
97 void TransformDecrypt(TUint8* aBuffer, TUint aNumBlocks);
100 /// Size of the key schedule in words
101 static const TUint KKeyScheduleSize = 32;
103 /// the key schedules
104 TUint32 iK1[KKeyScheduleSize];
105 TUint32 iK2[KKeyScheduleSize];
106 TUint32 iK3[KKeyScheduleSize];
108 static const TUint8 K3DesBlockBytes = 8;
109 static const TUint8 K3DesKeyBytes = 24;
113 #endif // __3DESIMPL_H__