sl@0: /* sl@0: * Copyright (c) 2002-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: * ** IMPORTANT ** PublishedPartner API's in this file are published to 3rd party developers via the sl@0: * Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted. sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __MODE_H__ sl@0: #define __MODE_H__ sl@0: sl@0: #include sl@0: sl@0: /** sl@0: * Abstract class defining the use of block transformation objects as block sl@0: * chaining modes. sl@0: * sl@0: * It is initialised with a subclass of CBlockTransformation, sl@0: * which it subsequently owns. Calls to its Transform() function will call the sl@0: * Transform() function in the underlying CBlockTransformation object, and perform sl@0: * the additional transformation for block chaining in that mode. This all means sl@0: * that if you want to do, say, AES encryption in CBC mode, you need to construct sl@0: * a CAESEncryptor object, then pass it to the CModeCBCEncryptor subclass of sl@0: * CBlockChainingMode, and subsequently use the CModeCBCEncryptor object to call sl@0: * Transform(). sl@0: * sl@0: * @publishedPartner sl@0: * @released sl@0: */ sl@0: class CBlockChainingMode : public CBlockTransformation sl@0: { sl@0: public: sl@0: virtual void Reset(); sl@0: virtual TInt BlockSize() const; sl@0: virtual TInt KeySize() const; sl@0: public: sl@0: /** sl@0: * Sets the initialization vector. sl@0: * sl@0: * @param aIV The initialization vector. The length of this descriptor must be sl@0: * the same as the underlying cipher's block size. sl@0: */ sl@0: virtual void SetIV(const TDesC8& aIV); sl@0: protected: sl@0: /** Default constructor */ sl@0: IMPORT_C CBlockChainingMode(); sl@0: /** sl@0: * Second phase constructor sl@0: * sl@0: * This should be called last by derived classes' ContructL()s . sl@0: * sl@0: * @param aBT A block transformation object sl@0: * @param aIV Initialization vector, the length of this descriptor must be sl@0: * the same as the underlying cipher's block size. sl@0: */ sl@0: IMPORT_C void ConstructL(CBlockTransformation* aBT, const TDesC8& aIV); sl@0: sl@0: /** The destructor frees all resources owned by the object, prior to its destruction. */ sl@0: IMPORT_C virtual ~CBlockChainingMode(); sl@0: protected: sl@0: /** A block transformation object */ sl@0: CBlockTransformation* iBT; sl@0: sl@0: /** sl@0: * A buffer containing the feedback register sl@0: * sl@0: * This must equal the underlying cipher's block size in length. sl@0: * Initially this register is filled with the initialization vector. sl@0: */ sl@0: HBufC8* iRegisterBuf; sl@0: sl@0: /** Encapsulates a pointer to iRegisterBuf */ sl@0: TPtr8 iRegister; sl@0: sl@0: /** sl@0: * A buffer containing the Initialisation Vector (IV) sl@0: * sl@0: * This must equal the underlying cipher's block size in length. sl@0: */ sl@0: HBufC8* iIVBuf; sl@0: sl@0: /** Encapsulates a pointer to iIVBuf */ sl@0: TPtr8 iIV; sl@0: }; sl@0: sl@0: #endif // __MODE_H__