crypto/weakcryptospi/inc/spi/hashplugin.h
changeset 8 35751d3474b7
child 30 cf642210ecb7
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2006-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 * hash plugin interface
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @publishedPartner
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef __HashPlugin_h__
       
    27 #define __HashPlugin_h__
       
    28 
       
    29 #include <cryptospi/cryptoplugin.h>
       
    30 
       
    31 namespace CryptoSpi
       
    32 	{
       
    33 	class CKey;
       
    34 	/**
       
    35 	The generic CryptoSPI hash definition. Intended to allow plug-ins
       
    36 	to implement extensible hash functionality, and to work with all
       
    37 	known existing hashing algorithms, e.g. MD2, MD4, MD5, SHA-1,
       
    38 	SHA-256, SHA-512, RIPEMD-160, etc.
       
    39 	*/
       
    40 	class MHash : public MPlugin
       
    41 	    {
       
    42 	public:
       
    43 		/**
       
    44 		Adds aMessage to the internal representation of data to be hashed,
       
    45 		then returns a TPtrC8 of the finalised hash of all the previously
       
    46 		appended messages.
       
    47 
       
    48 		@param aMessage  The data to be included in the hash.
       
    49 		@return A descriptor pointer to the buffer containing the resulting hash.
       
    50 		*/
       
    51 		virtual TPtrC8 Hash(const TDesC8& aMessage) = 0;    // Combination of Update and Final
       
    52 
       
    53 		/**
       
    54 		Adds data to the internal representation of messages to be hashed.
       
    55 		@param aMessage	The data to be included in the hash.
       
    56 		*/
       
    57 		virtual void Update(const TDesC8& aMessage) = 0;
       
    58 
       
    59 		/**
       
    60 		Produces a final hash value from all the previous updates of data
       
    61 		to be hashed.
       
    62 		@param aMessage	The data to be included in the hash.
       
    63 		*/
       
    64 		virtual TPtrC8 Final(const TDesC8& aMessage) = 0;
       
    65 
       
    66 		/**
       
    67 		Creates a brand new reset MHash object containing no state
       
    68 		information from the current object.  
       
    69 
       
    70 		To make a copy of a message digest with its internal state intact,
       
    71 		see CopyL().
       
    72 		@return A pointer to the new reset MHash object
       
    73 		*/
       
    74 		virtual MHash* ReplicateL() = 0;		
       
    75 
       
    76 		/** 
       
    77 		Creates a new MHash object with the exact same state as
       
    78 		the current object.  
       
    79 
       
    80 		This function copies all internal state of the message digest.
       
    81 		To create a new MHash object without the state of
       
    82 		the current object, see ReplicateL().
       
    83 		@return A pointer to the new MHash object
       
    84 		*/
       
    85 		virtual MHash* CopyL() = 0;
       
    86 		
       
    87 		/**
       
    88 		 * @deprecated
       
    89 		 * 
       
    90 		 * Set the key used for HMAC mode operation.
       
    91 		 * @param aKey	The key for HMAC
       
    92 		 */
       
    93 		virtual void SetKeyL(const CKey& aKey) = 0;
       
    94 			
       
    95 		/**
       
    96 		 * @deprecated
       
    97 		 * 
       
    98 		 * Set the operation mode, ie hash or hmac
       
    99 		 * @param aOperationMode	The UID to identifiy the operation mode
       
   100 		 */		
       
   101 		virtual void SetOperationModeL(TUid aOperationMode) = 0;
       
   102 	    };
       
   103 
       
   104 
       
   105 	class MAsyncHash: public MPlugin
       
   106 	    {
       
   107     public:
       
   108 		/**
       
   109 		 * Adds aMessage to the internal representation of data to be hashed,
       
   110 		 * then returns a TPtrC8 of the finalised hash of all the previously
       
   111 		 * appended messages.
       
   112 		 *
       
   113 		 * @param aMessage	The data to be included in the hash.
       
   114 		 * @param aHash A descriptor pointer to the buffer containing the resulting hash.
       
   115 		 * @param aStatus
       
   116 		 */
       
   117 		virtual void Hash(const TDesC8& aMessage, TPtrC8 aHash, TRequestStatus& aStatus) = 0;    // Combination of Update and Final
       
   118 
       
   119 		/**
       
   120 		 * Adds data to the internal representation of messages to be hashed.
       
   121 		 * @param aMessage	The data to be included in the hash.
       
   122 		 * @param aStatus
       
   123 		 */
       
   124 		virtual void Update(const TDesC8& aMessage, TRequestStatus& aStatus) = 0;
       
   125 
       
   126 		/**
       
   127 		 * Produces a final hash value from all the previous updates of data
       
   128 		 * to be hashed.
       
   129 		 * @param aMessage  Data to be included in the hash.
       
   130 		 * @param aFinal A descriptor pointer to the buffer containing the resulting hash.
       
   131 		 * @param aStatus
       
   132 		 */
       
   133 		virtual void Final(const TDesC8& aMessage, TPtrC8 aFinal, TRequestStatus& aStatus) = 0;
       
   134 
       
   135 		/**
       
   136 		 * Cancel an outstanding request
       
   137 		 */
       
   138 		virtual void Cancel() = 0;
       
   139 
       
   140 		/**
       
   141 		Creates a brand new reset MAsyncHash object containing no state
       
   142 		information from the current object.  
       
   143 
       
   144 		To make a copy of a message digest with its internal state intact,
       
   145 		see CopyL().
       
   146 
       
   147 		@return A pointer to the new reset MAsyncHash object
       
   148 		*/
       
   149 		virtual MAsyncHash* ReplicateL() = 0;		
       
   150 
       
   151 		/** 
       
   152 		Creates a new MAsyncHash object with the exact same state as
       
   153 		the current object.  
       
   154 
       
   155 		This function copies all internal state of the message digest.
       
   156 		To create a new MAsyncHash object without the state of
       
   157 		the current object, see ReplicateL().
       
   158 
       
   159 		@return A pointer to the new MAsyncHash object
       
   160 		*/
       
   161 		virtual MAsyncHash* CopyL() = 0;
       
   162 		
       
   163 		/**
       
   164 		 * @deprecated
       
   165 		 * 
       
   166 		 * Set the key used for HMAC mode operation.
       
   167 		 * @param aKey	The key for HMAC
       
   168 		 */
       
   169 		virtual void SetKeyL(const CKey& aKey) = 0;
       
   170 			
       
   171 		/**
       
   172 		 * @deprecated
       
   173 		 * 
       
   174 		 * Set the operation mode, ie hash or hmac
       
   175 		 * @param aOperationMode	The UID to identifiy the operation mode
       
   176 		 */		
       
   177 		virtual void SetOperationModeL(TUid aOperationMode) = 0;
       
   178 	    };	
       
   179 	}
       
   180 
       
   181 #endif  // __HashPlugin_h__