os/security/crypto/weakcryptospi/inc/spi/signerplugin.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006-2010 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 * Signer Abstract interface
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file
    22  @publishedPartner
    23  @released
    24 */
    25 
    26 #ifndef __CRYPTOAPI_SIGNER_H__
    27 #define __CRYPTOAPI_SIGNER_H__
    28 
    29 #include <cryptospi/cryptoplugin.h>
    30 #include <cryptospi/keys.h>
    31 
    32 namespace CryptoSpi
    33 	{
    34 	/**
    35 	The Signer definition. Intended to allow plug-ins to implement 
    36 	extensible signature signer functionality, and to work with all
    37 	known existing  signature algorithms, e.g. DSA, RSA etc
    38 	*/
    39 	class MSignatureBase : public MPlugin
    40 		{
    41 	public:
    42 		/**
    43 		Set the padding mode for the signer or verifier. Reset() is called to reinitialise the cipher.
    44 		@param aPaddingMode The padding mode of the signer
    45 		@leave KErrNotSupported if the padding mode is not supported.
    46 		@leave ...	Any of the crypto error codes defined in 
    47   					cryptospi_errs.h or any of the system-wide error codes.
    48 		*/
    49 		virtual void SetPaddingModeL(TUid aPaddingMode) = 0;
    50 
    51 		/**
    52 		Set the private key for the signer or verifier. Reset() is called to reinitialise the cipher.
    53 		@param aPrivateKey The privatekey that used to sign
    54 		@leave KErrArgument if key is not of the expected type.
    55 		@leave KErrNotSupported if the key is not of valid length.
    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 SetKeyL(const CKey& aPrivateKey) = 0;
    60 
    61 		/**
    62 		Gets the maximum size of input accepted by this object.
    63 		@return The maximum length allowed in bytes
    64 		@leave ...	Any of the crypto error codes defined in 
    65   					cryptospi_errs.h or any of the system-wide error codes.
    66 		*/	 
    67 		virtual TInt GetMaximumInputLengthL() const = 0;
    68 
    69 		/**
    70 		Gets the maximum size of output that can be generated by this object.
    71 		@return The maximum output length in bytes
    72 		@leave ...	Any of the crypto error codes defined in 
    73   					cryptospi_errs.h or any of the system-wide error codes.
    74 		*/	 
    75 		virtual TInt GetMaximumOutputLengthL() const = 0;
    76 		};
    77 
    78 	class MSigner : public MSignatureBase
    79 		{
    80 	public:
    81 
    82 		/**
    83 		Signs the input hash
    84 		@param aInput	The hash of the message to sign
    85 		@param aSignature The signature of the hash 
    86 		@leave ...	Any of the crypto error codes defined in 
    87   					cryptospi_errs.h or any of the system-wide error codes.
    88 		*/
    89 		virtual void SignL(const TDesC8& aInput, CCryptoParams& aSignature) = 0;
    90 		};
    91 
    92 
    93 	class MAsyncSigner : public MSignatureBase
    94 		{
    95 	public:
    96 
    97 		/**
    98 		Set the public key for the signer
    99 		@param aInput	The hash of the message to sign
   100 		@param aSignature The signature of the hash 
   101 		@param aRequestStatus
   102 		@leave ...	Any of the crypto error codes defined in 
   103   					cryptospi_errs.h or any of the system-wide error codes.
   104 		*/
   105 		virtual void SignL(const TDesC8& aInput, CCryptoParams& aSignature, TRequestStatus& aRequestStatus) = 0;
   106 
   107 		/**
   108 		Cancel the outstanding request
   109 		*/
   110 		virtual void Cancel() = 0;
   111 
   112 		};
   113 
   114 	} // namespace CryptoSpi
   115 
   116 #endif //__CRYPTOAPI_SIGNER_H__