crypto/weakcrypto/inc/cbcmode.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     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 * CBC mode encryptor and decryptor implementation
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @file 
       
    26  @internalAll
       
    27 */
       
    28  
       
    29 #ifndef __CBCMODE_H__
       
    30 #define __CBCMODE_H__
       
    31 
       
    32 #include "mode.h"
       
    33 
       
    34 /**
       
    35 * Concrete subclass of CBlockChainingMode implementing CBC mode block chaining
       
    36 * for encryption.
       
    37 *
       
    38 * @publishedPartner
       
    39 * @released 
       
    40 */
       
    41 class CModeCBCEncryptor : public CBlockChainingMode
       
    42 {
       
    43 public:
       
    44 	/**
       
    45 	* Creates an object of this class for CBC mode encryption.
       
    46 	*
       
    47 	* @param aBT	An appropriate CBlockTransformation derived encryptor.
       
    48 	* @param aIV	Initialization vector, the length of this descriptor must be
       
    49 	*				the same as the underlying cipher's block size.
       
    50 	* @return		A pointer to the new CModeCBCEncryptor object
       
    51 	*/
       
    52 	IMPORT_C static CModeCBCEncryptor* NewL(CBlockTransformation* aBT, 
       
    53 		const TDesC8& aIV);
       
    54 
       
    55 	/**
       
    56 	* Creates an object of this class for CBC mode encryption.
       
    57 	*
       
    58 	* The returned pointer is put onto the cleanup stack.
       
    59 	*
       
    60 	* @param aBT	An appropriate CBlockTransformation derived encryptor.
       
    61 	* @param aIV	Initialization vector, the length of this descriptor must be
       
    62 	*				the same as the underlying cipher's block size.
       
    63 	* @return		A pointer to the new CModeCBCEncryptor object
       
    64 	*/
       
    65 	IMPORT_C static CModeCBCEncryptor* NewLC(CBlockTransformation* aBT, 
       
    66 		const TDesC8& aIV);
       
    67 	virtual void Transform(TDes8& aBlock);	
       
    68 protected:
       
    69 	/**
       
    70 	 * @internalAll
       
    71 	 */
       
    72 	CModeCBCEncryptor();
       
    73 private:
       
    74 	const CModeCBCEncryptor& operator=(const CModeCBCEncryptor&);
       
    75 };
       
    76 
       
    77 /**
       
    78 * Concrete subclass of CBlockChainingMode implementing CBC mode block chaining
       
    79 * for decryption.
       
    80 *
       
    81 * @publishedPartner
       
    82 * @released 
       
    83 */
       
    84 class CModeCBCDecryptor : public CBlockChainingMode
       
    85 {
       
    86 public:
       
    87 	/**
       
    88 	* Creates an object of this class for CBC mode decryption.
       
    89 	* 
       
    90 	* @param aBT	An appropriate CBlockTransformation derived decryptor.
       
    91 	* @param aIV	Initialization vector, the length of this descriptor must be
       
    92 	*				the same as the underlying cipher's block size.
       
    93 	* @return		A pointer to the CModeCBCDecryptor new object.
       
    94 	*/
       
    95 	IMPORT_C static CModeCBCDecryptor* NewL(CBlockTransformation* aBT, 
       
    96 		const TDesC8& aIV);
       
    97 
       
    98 	/**
       
    99 	* Creates an object of this class for CBC mode decryption.
       
   100 	*
       
   101 	* The returned pointer is put onto the cleanup stack.
       
   102 	* 
       
   103 	* @param aBT	An appropriate CBlockTransformation derived decryptor.
       
   104 	* @param aIV	Initialization vector, the length of this descriptor must be
       
   105 	*				the same as the underlying cipher's block size.
       
   106 	* @return		A pointer to the CModeCBCDecryptor new object.
       
   107 	*/
       
   108 	IMPORT_C static CModeCBCDecryptor* NewLC(CBlockTransformation* aBT, 
       
   109 		const TDesC8& aIV);
       
   110 	virtual ~CModeCBCDecryptor(void);
       
   111 public:
       
   112 	virtual void Transform(TDes8& aBlock);	
       
   113 protected:
       
   114 	/** @internalAll */
       
   115 	CModeCBCDecryptor();
       
   116 	/** @internalAll */
       
   117 	void ConstructL(CBlockTransformation* aBT, const TDesC8& aIV);
       
   118 private:
       
   119 	HBufC8* iIVBakBuf;
       
   120 	TPtr8 iIVBak;
       
   121 private:
       
   122 	const CModeCBCDecryptor& operator=(const CModeCBCDecryptor&);
       
   123 };
       
   124 
       
   125 #endif	//	__CBCMODE_H__