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.
28 #include "symmetriccipherimpl.h"
35 Plug-in class for ARC4 stream cipher
37 namespace SoftwareCrypto
39 using namespace CryptoSpi;
41 NONSHARABLE_CLASS(CArc4Impl) : public CSymmetricStreamCipherImpl
46 Number of bytes to discard by default from an ARC4 key stream.
48 static const TUint KDefaultDiscardBytes = 768;
51 The size of the substitution box (i.e. lookup table) in bytes.
53 static const TInt KSBoxSize = 256;
56 Maximum ARC4 key size in bytes.2048 bits
58 static const TInt KMaxARC4KeyBytes = 256;
61 Creates an instance of an ARC4 symmetric cipher plug-in.
63 @param aDiscardBytes The number of bytes to drop from
64 the beginning of the key stream.
65 @return A pointer to a CArc4Impl instance
67 static CArc4Impl* NewL(const CKey& aKey, TInt aDiscardBytes);
70 Creates an instance of an ARC4 symmetric cipher plug-in,
71 and leave it on the cleanup stack
73 @param aDiscardBytes The number of bytes to drop from
74 the beginning of the key stream.
75 @return A pointer to a CArc4Impl instance
77 static CArc4Impl* NewLC(const CKey& aKey, TInt aDiscardBytes);
82 //Override MPlugin virtual function
85 //Override CSymmetricCipherImpl virtual functions
86 TUid ImplementationUid() const;
87 TBool IsValidKeyLength(TInt aKeyBytes) const;
88 const CExtendedCharacteristics* GetExtendedCharacteristicsL();
90 static CExtendedCharacteristics* CreateExtendedCharacteristicsL();
94 CArc4Impl(TInt aDiscardBytes);
96 //second phase of construction
97 void ConstructL(const CKey& aKey);
99 //Override CSymmetricStreamCipherImpl virtual functions
100 void DoProcess(TDes8& aData);
103 TUint8 GenerateByte();
104 void DiscardBytes(TInt aDiscardBytes);
110 TUint8 iState[KSBoxSize];