os/security/crypto/weakcrypto/inc/mode.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
* ** IMPORTANT ** PublishedPartner API's in this file are published to 3rd party developers via the 
sl@0
    16
* Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted.
sl@0
    17
*
sl@0
    18
*/
sl@0
    19
sl@0
    20
sl@0
    21
/**
sl@0
    22
 @file 
sl@0
    23
 @publishedPartner
sl@0
    24
 @released 
sl@0
    25
*/
sl@0
    26
 
sl@0
    27
#ifndef __MODE_H__
sl@0
    28
#define __MODE_H__
sl@0
    29
sl@0
    30
#include "blocktransformation.h"
sl@0
    31
sl@0
    32
/**
sl@0
    33
* Abstract class defining the use of block transformation objects as block
sl@0
    34
* chaining modes.
sl@0
    35
*
sl@0
    36
* It is initialised with a subclass of CBlockTransformation,
sl@0
    37
* which it subsequently owns.  Calls to its Transform() function will call the
sl@0
    38
* Transform() function in the underlying CBlockTransformation object, and perform
sl@0
    39
* the additional transformation for block chaining in that mode.  This all means
sl@0
    40
* that if you want to do, say, AES encryption in CBC mode, you need to construct
sl@0
    41
* a CAESEncryptor object, then pass it to the CModeCBCEncryptor subclass of
sl@0
    42
* CBlockChainingMode, and subsequently use the CModeCBCEncryptor object to call
sl@0
    43
* Transform().
sl@0
    44
* 
sl@0
    45
* @publishedPartner
sl@0
    46
* @released 
sl@0
    47
*/
sl@0
    48
class CBlockChainingMode : public CBlockTransformation
sl@0
    49
{
sl@0
    50
public:
sl@0
    51
	virtual void Reset();
sl@0
    52
	virtual TInt BlockSize() const;
sl@0
    53
	virtual TInt KeySize() const;
sl@0
    54
public:
sl@0
    55
	/**
sl@0
    56
	* Sets the initialization vector.
sl@0
    57
	* 
sl@0
    58
	* @param aIV	The initialization vector.  The length of this descriptor must be
sl@0
    59
	*				the same as the underlying cipher's block size.
sl@0
    60
	*/
sl@0
    61
	virtual void SetIV(const TDesC8& aIV);
sl@0
    62
protected:
sl@0
    63
	/** Default constructor */
sl@0
    64
	IMPORT_C CBlockChainingMode();
sl@0
    65
	/** 
sl@0
    66
	 * Second phase constructor
sl@0
    67
	 * 
sl@0
    68
	 * This should be called last by derived classes' ContructL()s .
sl@0
    69
	 *
sl@0
    70
	 * @param aBT	A block transformation object
sl@0
    71
	 * @param aIV	Initialization vector, the length of this descriptor must be
sl@0
    72
	 *				the same as the underlying cipher's block size.
sl@0
    73
	 */
sl@0
    74
	IMPORT_C void ConstructL(CBlockTransformation* aBT, const TDesC8& aIV);
sl@0
    75
	
sl@0
    76
	/** The destructor frees all resources owned by the object, prior to its destruction. */
sl@0
    77
	IMPORT_C virtual ~CBlockChainingMode();
sl@0
    78
protected:
sl@0
    79
	/** A block transformation object */
sl@0
    80
	CBlockTransformation* iBT;
sl@0
    81
sl@0
    82
	/** 
sl@0
    83
	 * A buffer containing the feedback register
sl@0
    84
	 *
sl@0
    85
	 * This must equal the underlying cipher's block size in length. 
sl@0
    86
	 * Initially this register is filled with the initialization vector.
sl@0
    87
	 */
sl@0
    88
	HBufC8* iRegisterBuf;
sl@0
    89
sl@0
    90
	/** Encapsulates a pointer to iRegisterBuf */
sl@0
    91
	TPtr8 iRegister;
sl@0
    92
sl@0
    93
	/** 
sl@0
    94
	 * A buffer containing the Initialisation Vector (IV) 
sl@0
    95
	 *
sl@0
    96
	 * This must equal the underlying cipher's block size in length. 
sl@0
    97
	 */
sl@0
    98
	HBufC8* iIVBuf;
sl@0
    99
sl@0
   100
	/** Encapsulates a pointer to iIVBuf */
sl@0
   101
	TPtr8 iIV;
sl@0
   102
};
sl@0
   103
sl@0
   104
#endif	//	__MODE_H__