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