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.
30 #include <cryptospi/keys.h>
31 #include "symmetriccipherimpl.h"
34 Plug-in class for RC2 block cipher
36 namespace SoftwareCrypto
38 NONSHARABLE_CLASS(CRc2Impl) : public CSymmetricBlockCipherImpl
43 Creates an instance of an RC2 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 @param aEffectiveKeyLenBits The effective key length in bits
49 @return A pointer to a CRc2Impl instance
51 static CRc2Impl* NewL(const CryptoSpi::CKey& aKey,
52 TUid aCryptoMode, TUid aOperationMode, TUid aPadding, TInt aEffectiveKeyLenBits);
55 Creates an instance of an RC2 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 @param aEffectiveKeyLenBits The effective key length in bits
62 @return A pointer to a CRc2Impl instance
64 static CRc2Impl* NewLC(const CryptoSpi::CKey& aKey,
65 TUid aCryptoMode, TUid aOperationMode, TUid aPadding, TInt aEffectiveKeyLenBits);
67 // From CSymmetricCipherImpl
68 TBool IsValidKeyLength(TInt aKeyBytes) const;
69 TUid ImplementationUid() const;
70 TInt GetKeyStrength() const;
75 /** SSL Effective Key Length Compatibility - for compatibility with SSL */
76 static const TUint KDefaultEffectiveKeyLenBits = 1024;
81 @param aOperationMode The mode of operation e.g. CBC
82 @param aCryptoMode Whether to encrypt or decrypt
83 @param aPaddingMode The padding mode to use. None, SSL, PKCS#7
85 CRc2Impl(TUid aOperationMode, TUid aCryptoMode, TUid aPaddingMode);
87 /// second phase of construction
88 void ConstructL(const CKey& aKey, TInt aEffectiveKeyLenBits);
91 Expands the key (iKey) to iEffectiveKeyLenBits and stores the result in iK
93 void SetKeySchedule();
95 // From CSymmetricBlockCipherImpl
96 void TransformEncrypt(TUint8* aBuffer, TUint aNumBlocks);
97 void TransformDecrypt(TUint8* aBuffer, TUint aNumBlocks);
100 static const TUint8 KRc2BlockBytes = 8;
101 static const TInt KRc2MaxKeySizeBytes = 128;
102 static const TInt KRc2ExpandedKeyLen = 64;
104 The expanded key buffer.
105 Each iK[i] is a 16-bit word.
107 TUint16 iK[KRc2ExpandedKeyLen]; // 128 bytes
109 /** The effective key length in bits */
110 TInt iEffectiveKeyLenBits;