os/security/crypto/weakcryptospi/inc/spi/macplugin.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/crypto/weakcryptospi/inc/spi/macplugin.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,206 @@
     1.4 +/*
     1.5 +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* MAC(message authentication code) plugin interface
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +/**
    1.24 + @file
    1.25 + @publishedPartner
    1.26 + @released
    1.27 +*/
    1.28 +
    1.29 +#ifndef __MAC_PLUGIN_H
    1.30 +#define __MAC_PLUGIN_H
    1.31 +
    1.32 +#include <cryptospi/cryptoplugin.h>
    1.33 +
    1.34 +namespace CryptoSpi
    1.35 +	{
    1.36 +	class CKey;
    1.37 +	
    1.38 +	/**
    1.39 +	 * The generic CryptoSPI MAC definition. This allow plug-ins
    1.40 +	 * to implement extensible MAC functionality and to work with all
    1.41 +	 * known existing hash based or symmetric cipher based MAC algorithms
    1.42 +	 * for e.g. MD2, MD4, MD5, SHA-1, SHA-256, SHA-512, RIPEMD-160, etc. or 
    1.43 +	 * AES-XCBC-MAC-96, AES-XCBC-PRF-128 etc. respectively. 
    1.44 +	 */
    1.45 +	class MMac : public MPlugin
    1.46 +	    {
    1.47 +	public:
    1.48 +
    1.49 +		/**
    1.50 +		 * Adds message to the internal representation of data for which the MAC value
    1.51 +		 * needs to be evaluated and then returns a TPtrC8 of the finalised MAC value 
    1.52 +		 * of all the previously appended messages. 
    1.53 +		 * 
    1.54 +		 * @param aMessage  The data for which MAC value is to be evaluated.
    1.55 +		 * @return          A descriptor pointer to the buffer containing the
    1.56 +		 *                  resulting MAC value.
    1.57 +		 * @leave ...		Any of the crypto error codes defined in 
    1.58 +  							cryptospi_errs.h or any of the system-wide error codes.
    1.59 +		 */
    1.60 +		virtual TPtrC8 MacL(const TDesC8& aMessage) = 0;    
    1.61 +		
    1.62 +        /**
    1.63 +         * Adds data to the internal representation of messages for which the MAC value
    1.64 +		 * needs to be evaluated.
    1.65 +         * 
    1.66 +         * @param aMessage	The data to be included in the MAC evaluation.
    1.67 +		 * @leave ...		Any of the crypto error codes defined in 
    1.68 +  							cryptospi_errs.h or any of the system-wide error codes.
    1.69 +         */
    1.70 +        virtual void UpdateL(const TDesC8& aMessage) = 0;
    1.71 +
    1.72 +        /**
    1.73 +         * Produces a final MAC value from all the previous updates of data to be MACed. 
    1.74 +         * It resets the MAC algorithm in a state similar to creating a new MAC instance
    1.75 +         * with the same underlying algorithm and supplied symmetric key.
    1.76 +         *  
    1.77 +         * @param aMessage	The data to be included in the MAC evaluation.
    1.78 +		 * @return          A descriptor pointer to the buffer containing the
    1.79 +		 *                  resulting MAC value.
    1.80 +		 * @leave ...		Any of the crypto error codes defined in 
    1.81 +  							cryptospi_errs.h or any of the system-wide error codes.
    1.82 +		 */
    1.83 +        virtual TPtrC8 FinalL(const TDesC8& aMessage) = 0;
    1.84 +
    1.85 +		/**
    1.86 +		 * This re-initialises the underlying MAC algorithm with a new symmetric key. 
    1.87 +         * It resets the MAC algorithm in a state similar to creating a new MAC instance
    1.88 +         * with the same underlying algorithm but a new symmetric key.
    1.89 +		 *
    1.90 +		 * @param aKey  Symmetric key for calculating message authentication code value. 
    1.91 +		 * @leave ...	Any of the crypto error codes defined in 
    1.92 +  						cryptospi_errs.h or any of the system-wide error codes.
    1.93 +		 */
    1.94 +		virtual void ReInitialiseAndSetKeyL(const CKey& aKey) = 0;
    1.95 +		
    1.96 +		/**
    1.97 +		 * Creates a brand new reset MMac object containing no state
    1.98 +		 * information from the current object.  
    1.99 +		 * 
   1.100 +		 * @return 	A pointer to the new reset MMac object
   1.101 +		 * @leave ...	Any of the crypto error codes defined in 
   1.102 +  						cryptospi_errs.h or any of the system-wide error codes.
   1.103 +		 */
   1.104 +		virtual MMac* ReplicateL() = 0;		
   1.105 +
   1.106 +		/** 
   1.107 +		 * Creates a new MMac object with the exact same state as
   1.108 +		 * the current object.  
   1.109 + 		 * This function copies all internal state of the message digest.
   1.110 +		 * 
   1.111 +		 * @return 	A pointer to the new MMac object
   1.112 +		 * @leave ...	Any of the crypto error codes defined in 
   1.113 +  						cryptospi_errs.h or any of the system-wide error codes.
   1.114 +		 */
   1.115 +		virtual MMac* CopyL() = 0;
   1.116 +	    };
   1.117 +
   1.118 +	/**
   1.119 +	 * Asynchronous MAC interface typically used by the plug-in implementations 
   1.120 +	 * that are based for dedicated crypto hardware.
   1.121 +	 */    
   1.122 +	class MAsyncMac : public MPlugin
   1.123 +	    {
   1.124 +	public:
   1.125 +
   1.126 +		/**
   1.127 +		 * Adds message to the internal representation of data for which the MAC value,
   1.128 +		 * needs to be evaluated and then returns a TPtrC8 of the finalised MAC value 
   1.129 +		 * of all the previously appended messages. 
   1.130 +		 * 
   1.131 +		 * @param aMessage  The data for which MAC value is to be evaluated.
   1.132 +		 * @param aStatus   Holds the completion status of an asynchronous 
   1.133 +		 * 					request for MAC evaluation.
   1.134 +		 * @return          A descriptor pointer to the buffer containing the
   1.135 +		 *                  resulting MAC value.
   1.136 +		 * @leave ...		Any of the crypto error codes defined in 
   1.137 +  							cryptospi_errs.h or any of the system-wide error codes.
   1.138 +		 */
   1.139 +		virtual TPtrC8 MacL(const TDesC8& aMessage, TRequestStatus& aStatus) = 0;    
   1.140 +			
   1.141 +        /**
   1.142 +         * Adds data to the internal representation of messages for which the MAC value
   1.143 +		 * needs to be evaluated.
   1.144 +         *
   1.145 +         * @param aMessage	The data to be included in the MAC evaluation.
   1.146 +		 * @param aStatus   Holds the completion status of an asynchronous 
   1.147 +		 * 					request for MAC evaluation.
   1.148 +		 * @leave ...		Any of the crypto error codes defined in 
   1.149 +  							cryptospi_errs.h or any of the system-wide error codes.
   1.150 +         */
   1.151 +        virtual void UpdateL(const TDesC8& aMessage, TRequestStatus& aStatus) = 0;
   1.152 +
   1.153 +        /**
   1.154 +         * Produces a final MAC value from all the previous updates of data to be MACed. 
   1.155 +         * It resets the MAC algorithm in a state similar to creating a new MAC instance
   1.156 +         * with the same underlying algorithm and supplied symmetric key.
   1.157 +         *  
   1.158 +         * @param aMessage	The data to be included in the MAC evaluation.
   1.159 +		 * @param aStatus   Holds the completion status of an asynchronous 
   1.160 +		 * 					request for MAC evaluation.
   1.161 +		 * @return          A descriptor pointer to the buffer containing the
   1.162 +		 *                  resulting MAC value.
   1.163 +		 * @leave ...		Any of the crypto error codes defined in 
   1.164 +  							cryptospi_errs.h or any of the system-wide error codes.
   1.165 +         */
   1.166 +        virtual TPtrC8 FinalL(const TDesC8& aMessage, TRequestStatus& aStatus) = 0;
   1.167 +
   1.168 +	    /**
   1.169 +		 * This re-initialises the underlying MAC algorithm with a new symmetric key. 
   1.170 +         * It resets the MAC algorithm in a state similar to creating a new MAC instance
   1.171 +         * with the same underlying algorithm but a new symmetric key.
   1.172 +		 *
   1.173 +		 * @param aKey     Symmetric key for calculating message authentication code value. 
   1.174 +		 * @param aStatus  Holds the completion status of an asynchronous 
   1.175 +		 * 				   request for MAC evaluation.
   1.176 +		 * @leave ...		Any of the crypto error codes defined in 
   1.177 +  							cryptospi_errs.h or any of the system-wide error codes.
   1.178 +		 */
   1.179 +		virtual void ReInitialiseAndSetKeyL(const CKey& aKey) = 0;    
   1.180 +		
   1.181 +		/**
   1.182 +		 * Cancels an outstanding request from the client.
   1.183 +		 */
   1.184 +		virtual void Cancel() = 0;
   1.185 +		
   1.186 +		/**
   1.187 +		 * Creates a brand new reset MAsyncMac object containing no state
   1.188 +		 * information from the current object.  
   1.189 +		 * 
   1.190 +		 * @return	A pointer to the new reset MAsyncHash object
   1.191 +		 * @leave ...	Any of the crypto error codes defined in 
   1.192 +  						cryptospi_errs.h or any of the system-wide error codes.
   1.193 +		 */
   1.194 +		virtual MAsyncMac* ReplicateL() = 0;		
   1.195 +
   1.196 +		/** 
   1.197 +		 * Creates a new MAsyncMac object with the exact same state as
   1.198 +		 * the current object.  
   1.199 +		 * This function copies all internal state of the message digest.
   1.200 +		 * 
   1.201 +		 * @return	A pointer to the new MAsyncMac object
   1.202 +		 * @leave ...	Any of the crypto error codes defined in 
   1.203 +  						cryptospi_errs.h or any of the system-wide error codes.
   1.204 +		 */
   1.205 +		virtual MAsyncMac* CopyL() = 0;
   1.206 +	    };
   1.207 +	}
   1.208 +
   1.209 +#endif  __MAC_PLUGIN_H