os/security/crypto/weakcryptospi/inc/spi/asymmetriccipherplugin.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 * Asymmetric cipher abstract interface
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file
    22  @publishedPartner
    23  @released
    24 */
    25 
    26 #ifndef __CRYPTOAPI_ASYMMETRICCIPHER_H__
    27 #define __CRYPTOAPI_ASYMMETRICCIPHER_H__
    28 
    29 #include <cryptospi/cryptoplugin.h>
    30 
    31 namespace CryptoSpi
    32 	{
    33 	/**
    34 	The Asymmetric Cipher Base definition. Intended to allow plug-ins
    35 	to implement extensible Asymmetric cipher functionality, and to work with all
    36 	known existing Asymmetric algorithms, e.g. RSA DSA etc
    37 	*/
    38 	class MAsymmetricCipherBase : public MPlugin
    39 		{
    40 	public:
    41 		
    42 		/**
    43 		Set the public key of this cipher. Reset() is called to reinitialise the cipher.
    44 		@param aKey	The public key.
    45 		@leave KErrArgument if aKey is not of the expected type.
    46 		@leave KErrNotSupported if the key is not of valid length.
    47 		@leave ...	Any of the crypto error codes defined in 
    48   					cryptospi_errs.h or any of the system-wide error codes.
    49 		*/
    50 		virtual void SetKeyL(const CKey& aKey) = 0;
    51 
    52 		/**
    53 		Set the crypto mode of this cipher. Reset() is called to reinitialise the cipher.
    54 		@param aCryptoMode	The crypto mode
    55 		@leave KErrNotSupported if the specified mode is not supported.
    56 		@leave ...	Any of the crypto error codes defined in 
    57   					cryptospi_errs.h or any of the system-wide error codes.
    58 		*/
    59 		virtual void SetCryptoModeL(TUid aCryptoMode) = 0;
    60 
    61 		/**
    62 		Set padding Mode of this cipher. Reset() is called to reinitialise the cipher.
    63 		@param aPaddingMode	The padding mode
    64 		@leave	KErrNotSupported if the specified mode is not supported.
    65 		@leave ...	Any of the crypto error codes defined in 
    66   					cryptospi_errs.h or any of the system-wide error codes.
    67 		*/
    68 		virtual void SetPaddingModeL(TUid aPaddingMode) = 0;
    69 
    70 		/**
    71 		Gets the maximum size of input accepted by this object.	
    72 		@return The maximum input length allowed in bytes.
    73 		@leave ...	Any of the crypto error codes defined in 
    74   					cryptospi_errs.h or any of the system-wide error codes.
    75 		*/	 
    76 		virtual TInt GetMaximumInputLengthL() const = 0;
    77 
    78 		/**
    79 		Gets the maximum size of output that can be generated by this object.
    80 		@return The maximum output length in bytes.
    81 		@leave ...	Any of the crypto error codes defined in 
    82   					cryptospi_errs.h or any of the system-wide error codes.
    83 		 */	 
    84 		virtual TInt GetMaximumOutputLengthL() const = 0;
    85 		};
    86 
    87 	class MAsymmetricCipher : public MAsymmetricCipherBase
    88 		{
    89 	public:
    90 		/**
    91 		Encrypts or decrypts aInput and appends the result to aOutput.
    92 		@param aInput	The input data to be processed.
    93 		@param aOutput	The resulting processed data appended to aOutput.
    94 		@leave ...	Any of the crypto error codes defined in 
    95   					cryptospi_errs.h or any of the system-wide error codes.
    96 		*/
    97 		virtual void ProcessL(const TDesC8& aInput, TDes8& aOutput) = 0;
    98 		};
    99 
   100 	class MAsyncAsymmetricCipher : public MAsymmetricCipherBase
   101 		{
   102 	public:
   103 
   104 		/**
   105 		Encrypts or decrypts aInput and appends the result to aOutput asynchronously
   106 		@param aInput	The input data to be processed.
   107 		@param aOutput	The resulting processed data appended to aOutput.
   108 		@param aRequestStatus
   109 		@leave ...	Any of the crypto error codes defined in 
   110   					cryptospi_errs.h or any of the system-wide error codes.
   111 		*/
   112 		virtual void ProcessL(const TDesC8& aInput, TDes8& aOutput, TRequestStatus& aRequestStatus) = 0;
   113 
   114 		/**
   115 		Cancel the outstanding request
   116 		*/
   117 		virtual void Cancel() = 0;
   118 		};
   119 	}
   120 
   121 #endif //__CRYPTOAPI_ASYMMETRICCIPHER_H__