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: * sl@0: */ sl@0: sl@0: sl@0: #ifndef __CBCMODESHIM_H__ sl@0: #define __CBCMODESHIM_H__ sl@0: sl@0: #include sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: sl@0: namespace CryptoSpi sl@0: { sl@0: class CSymmetricCipher; sl@0: } sl@0: sl@0: /** sl@0: CBC mode encryptor shim class that delegates all work to CModeCBCEncryptor. sl@0: This should only be instantiated by CModeCBCEncryptor::NewLC sl@0: */ sl@0: NONSHARABLE_CLASS(CModeCBCEncryptorShim) : public CModeCBCEncryptor sl@0: { sl@0: public: sl@0: /** sl@0: Creates a new CModeCBCEncryptorShim. If the block transfer sl@0: @param aBT A pointer to the block transform object. sl@0: @param aIV The initialisation vector to use. sl@0: @return A pointer to a CModeCBCEncryptorShim instance or NULL if the block transform sl@0: does not support SPI or the SPI plug-in does not support CBC mode sl@0: */ sl@0: static CModeCBCEncryptorShim* NewL(CBlockTransformation* aBT, const TDesC8& aIV); sl@0: sl@0: // From CBase sl@0: TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); sl@0: sl@0: // From CBlockTransformation sl@0: void Reset(); sl@0: TInt BlockSize() const; sl@0: TInt KeySize() const; sl@0: void Transform(TDes8& aBlock); sl@0: sl@0: // From CBlockChainingMode sl@0: void SetIV(const TDesC8& aIv); sl@0: sl@0: private: sl@0: /// Constructor sl@0: CModeCBCEncryptorShim(CryptoSpi::CSymmetricCipher* aSymmetricCipherImpl); sl@0: sl@0: // Just invokes ContructL in super-class sl@0: void ConstructL(CBlockTransformation* aBT, const TDesC8& aIv); sl@0: sl@0: // owned by block transform - iBT sl@0: CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl; sl@0: }; sl@0: sl@0: /** sl@0: CBC mode decryptor shim class that delegates all work to CModeCBCDecryptor. sl@0: This should only be instantiated by CModeCBCDecryptor::NewLC sl@0: */ sl@0: NONSHARABLE_CLASS(CModeCBCDecryptorShim) : public CModeCBCDecryptor sl@0: { sl@0: public: sl@0: /** sl@0: Creates a new CModeCBCEncryptorShim. sl@0: @param aBT A pointer to the block transform object. sl@0: @param aIV The initialisation vector to use. sl@0: @return A pointer to a CModeCBCDecryptorShim instance or NULL if the block transform sl@0: does not support SPI or the SPI plug-in does not support CBC mode sl@0: */ sl@0: static CModeCBCDecryptorShim* NewL(CBlockTransformation* aBT, const TDesC8& aIV); sl@0: sl@0: // From CBase sl@0: TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); sl@0: sl@0: // From CBlockTransformation sl@0: void Reset(); sl@0: TInt BlockSize() const; sl@0: TInt KeySize() const; sl@0: void Transform(TDes8& aBlock); sl@0: sl@0: // From CBlockChainingMode sl@0: void SetIV(const TDesC8& aIv); sl@0: sl@0: private: sl@0: /// Constructor sl@0: CModeCBCDecryptorShim(CryptoSpi::CSymmetricCipher* aSymmetricCipherImpl); sl@0: sl@0: // Just invokes ContructL in super-class sl@0: void ConstructL(CBlockTransformation* aBT, const TDesC8& aIv); sl@0: sl@0: // owned by block transform - iBT sl@0: CryptoSpi::CSymmetricCipher* iSymmetricCipherImpl; sl@0: }; sl@0: sl@0: #endif // __CBCMODESHIM_H__