First public contribution.
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 __3DESIMPL_H__
20 #define __3DESIMPL_H__
30 #include <cryptospi/keys.h>
34 Plug-in class for 3DES block cipher
36 namespace SoftwareCrypto
38 NONSHARABLE_CLASS(C3DesImpl) : public CDesImpl
43 Creates an instance of a 3DES (Data Encryption Standard) 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 C3DesImpl instance
50 static C3DesImpl* NewL(const CryptoSpi::CKey& aKey,
51 TUid aCryptoMode, TUid aOperationMode, TUid aPadding);
54 Creates an instance of a 3DES (Data Encryption Standard) 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 C3DesImpl instance
62 static C3DesImpl* NewLC(const CryptoSpi::CKey& aKey,
63 TUid aCryptoMode, TUid aOperationMode, TUid aPadding);
65 // From CSymmetricCipherImpl
66 TBool IsValidKeyLength(TInt aKeyBytes) const;
67 TInt GetKeyStrength() const;
68 TUid ImplementationUid() const;
76 @param aOperationMode The mode of operation e.g. CBC
77 @param aCryptoMode Whether to encrypt or decrypt
78 @param aPaddingMode The padding mode to use. None, SSL, PKCS#7
80 C3DesImpl(TUid aOperationMode, TUid aCryptoMode, TUid aPaddingMode);
82 /// second phase of construction
83 void ConstructL(const CryptoSpi::CKey& aKey);
86 Creates the key schedules iK1, iK2, iK3 from CBlockTransformationImpl::iKey.
87 This should be called from ConstructL and Reset
89 void SetKeySchedule();
91 // From CSymmetricBlockCipherImpl
92 void TransformEncrypt(TUint8* aBuffer, TUint aNumBlocks);
93 void TransformDecrypt(TUint8* aBuffer, TUint aNumBlocks);
96 /// Size of the key schedule in words
97 static const TUint KKeyScheduleSize = 32;
100 TUint32 iK1[KKeyScheduleSize];
101 TUint32 iK2[KKeyScheduleSize];
102 TUint32 iK3[KKeyScheduleSize];
104 static const TUint8 K3DesBlockBytes = 8;
105 static const TUint8 K3DesKeyBytes = 24;
109 #endif // __3DESIMPL_H__