sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * ARC4 shim classes definition sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: sl@0: #ifndef ARC4SHIM_H sl@0: #define ARC4SHIM_H sl@0: sl@0: #include sl@0: sl@0: namespace CryptoSpi sl@0: { sl@0: class CCryptoParams; sl@0: class CSymmetricCipher; sl@0: class CKey; sl@0: } sl@0: sl@0: NONSHARABLE_CLASS(CArc4Shim) : public CARC4 sl@0: { sl@0: public: sl@0: /** sl@0: Creates a CArc4Shim object which has the same interface as CARC4 sl@0: but delegates all work to a Crypto SPI plug-in. sl@0: @param aKey The key to use. aKey must be less sl@0: than or equal to KRC4MaxKeySizeBytes. sl@0: @param aDiscardBytes The number of bytes to drop from the sl@0: beginning of the key stream. sl@0: @return A pointer to a CArc4Shim instance sl@0: @leave KErrKeyNotWeakEnough If the key size is larger than that sl@0: allowed by the cipher strength sl@0: restrictions of the crypto library. sl@0: See TCrypto::IsSymmetricWeakEnoughL() sl@0: */ sl@0: static CArc4Shim* NewL(const TDesC8& aKey, TUint aDiscardBytes); sl@0: sl@0: /** sl@0: Creates a CArc4Shim object which has the same interface as CARC4, sl@0: and leave it on the cleanup stack. but delegates all work to a sl@0: Crypto SPI plug-in. sl@0: @param aKey The key to use. aKey must be less sl@0: than or equal to KRC4MaxKeySizeBytes. sl@0: @param aDiscardBytes The number of bytes to drop from the sl@0: beginning of the key stream. sl@0: @return A pointer to a CArc4Shim instance sl@0: @leave KErrKeyNotWeakEnough If the key size is larger than that sl@0: allowed by the cipher strength sl@0: restrictions of the crypto library. sl@0: See TCrypto::IsSymmetricWeakEnoughL() sl@0: */ sl@0: static CArc4Shim* NewLC(const TDesC8& aKey, TUint aDiscardBytes); sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: ~CArc4Shim(); sl@0: sl@0: // From CSymmetricCipher class sl@0: void Reset(); sl@0: TInt BlockSize() const; sl@0: TInt KeySize() const; sl@0: void Process(const TDesC8& aInput, TDes8& aOutput); sl@0: void ProcessFinalL(const TDesC8& aInput, TDes8& aOutput); sl@0: TInt MaxOutputLength(TInt aInputLength) const; sl@0: TInt MaxFinalOutputLength(TInt aInputLength) const; sl@0: sl@0: private: sl@0: /** sl@0: Constructor sl@0: */ sl@0: CArc4Shim(); sl@0: sl@0: /** sl@0: Second Phase Constructor sl@0: */ sl@0: void ConstructL(const TDesC8& aKey, TUint aDiscardBytes); sl@0: sl@0: private: sl@0: /// SPI delegate sl@0: CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl; sl@0: sl@0: /// SPI requires all key to passed as key-objects sl@0: CryptoSpi::CKey* iKey; sl@0: sl@0: CryptoSpi::CCryptoParams* iAlgorithmParams; sl@0: }; sl@0: sl@0: #endif // ARC4SHIM_H