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: * RC2 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 __RC2SHIM_H__ sl@0: #define __RC2SHIM_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(CRC2EncryptorShim) : public CRC2Encryptor sl@0: { sl@0: public: sl@0: /** sl@0: Creates an CRC2EncryptorShim object which has the same interface sl@0: as RC2 Encryptor but delegates all work to a Crypto SPI plug-in. sl@0: sl@0: @param aKey The encryption key sl@0: @return A pointer to a CRC2EncryptorShim instance sl@0: */ sl@0: static CRC2EncryptorShim* NewL(const TDesC8& aKey, TInt aEffectiveKeyLenBits); sl@0: sl@0: /** sl@0: Creates an CRC2EncryptorShim object which has the same interface sl@0: as RC2 Encryptor but delegates all work to a Crypto SPI plug-in. sl@0: sl@0: A pointer to the new object is placed on the cleanup stack sl@0: sl@0: @param aKey The encryption key sl@0: @return A pointer to a CRC2EncryptorShim instance sl@0: */ sl@0: static CRC2EncryptorShim* NewLC(const TDesC8& aKey, TInt aEffectiveKeyLenBits); sl@0: sl@0: // From CBlockTransform sl@0: TInt BlockSize() const; sl@0: void Transform(TDes8& aBlock); sl@0: void Reset(void); sl@0: TInt KeySize(void) const; sl@0: sl@0: /// Destructor sl@0: ~CRC2EncryptorShim(); sl@0: sl@0: private: sl@0: /// Constructor sl@0: CRC2EncryptorShim(); sl@0: void ConstructL(const TDesC8& aKey, TInt aEffectiveKeyLenBits); sl@0: sl@0: // From CBase sl@0: TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); 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: /// Temporary output block, SPI does not overwrite input sl@0: /// RC2 uses 64bit blocks sl@0: TBuf8<16> iOutputBlock; sl@0: sl@0: /// The effective key length is passed as an algorithm sl@0: /// parameter. This allows it to be externalised. sl@0: CryptoSpi::CCryptoParams* iAlgorithmParams; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(CRC2DecryptorShim) : public CRC2Decryptor sl@0: { sl@0: public: sl@0: /** sl@0: Creates an CRC2DecryptorShim object which has the same interface sl@0: as RC2 Decryptor but delegates all work to a Crypto SPI plug-in. sl@0: sl@0: @param aKey The decryption key sl@0: @return A pointer to a CRC2DecryptorShim instance sl@0: */ sl@0: static CRC2DecryptorShim* NewL(const TDesC8& aKey, TInt aEffectiveKeyLenBits); sl@0: sl@0: /** sl@0: Creates an CRC2DecryptorShim object which has the same interface sl@0: as RC2 Decryptor but delegates all work to a Crypto SPI plug-in. sl@0: sl@0: A pointer to the new object is placed on the cleanup stack sl@0: sl@0: @param aKey The decryption key sl@0: @return A pointer to a CRC2DecryptorShim instance sl@0: */ sl@0: static CRC2DecryptorShim* NewLC(const TDesC8& aKey, TInt aEffectiveKeyLenBits); sl@0: sl@0: // From CBlockTransform sl@0: TInt BlockSize() const; sl@0: void Transform(TDes8& aBlock); sl@0: void Reset(void); sl@0: TInt KeySize(void) const; sl@0: sl@0: /// Destructor sl@0: ~CRC2DecryptorShim(); sl@0: sl@0: private: sl@0: /// Constructor sl@0: CRC2DecryptorShim(); sl@0: void ConstructL(const TDesC8& aKey, TInt aEffectiveKeyLenBits); sl@0: sl@0: /** sl@0: From CBase, to allow CBufferedTransform & CBlockChainingMode sl@0: to determine whether the functionality may be delegated to sl@0: the SPI object. sl@0: */ sl@0: TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); 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: /// Temporary output block, SPI does not overwrite input sl@0: /// RC2 uses 64bit blocks sl@0: TBuf8<16> iOutputBlock; sl@0: sl@0: /// The effective key length is passed as an algorithm sl@0: /// parameter. This allows it to be externalised. sl@0: CryptoSpi::CCryptoParams* iAlgorithmParams; sl@0: }; sl@0: sl@0: #endif // __RC2SHIM_H__