cryptoplugins/cryptospiplugins/test/dummyecchwplugin/src/dummyeccimpl.h
changeset 15 da2ae96f639b
equal deleted inserted replaced
10:afc583cfa176 15:da2ae96f639b
       
     1 /*
       
     2 * Copyright (c) 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 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22  @released
       
    23 */
       
    24 #ifndef	CDUMMYECCIMPL_H
       
    25 #define	CDUMMYECCIMPL_H
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <e32cmn.h>
       
    29 #include <cryptospi/cryptospidef.h>
       
    30 #include "keys.h"
       
    31 #include "asymmetriccipherplugin.h"
       
    32 
       
    33 namespace DummyEccHwCrypto
       
    34 	{
       
    35 	using namespace CryptoSpi;
       
    36 	
       
    37 	/**
       
    38 	 * Implements the MAsymmetricCipher interface.
       
    39 	 * 
       
    40 	 * This should be used to create the cipher object to perform 
       
    41 	 * encryption / decryption using ECC.
       
    42 	 */
       
    43 	NONSHARABLE_CLASS(CDummyECCCipherImpl) : public CBase, public MAsymmetricCipher
       
    44 		{
       
    45 	public:
       
    46 	    static CDummyECCCipherImpl* NewL(const CKey& aKey, TUid aCryptoMode, TUid aPaddingMode);
       
    47 	    static CDummyECCCipherImpl* NewLC(const CKey& aKey, TUid aCryptoMode, TUid aPaddingMode);
       
    48 	    
       
    49 	    // MPlugin Interface
       
    50 	    void Close();
       
    51 	    void Reset();
       
    52 	    void GetCharacteristicsL(const TCharacteristics*& aPluginCharacteristics);
       
    53 	    const CExtendedCharacteristics* GetExtendedCharacteristicsL();
       
    54 	    TAny* GetExtension(TUid aExtensionId); 
       
    55 	    // End of MPlugin Interface
       
    56 	    
       
    57 	    // MAsymmetricCipherBase Interface
       
    58 	    void SetKeyL(const CKey& aKey);
       
    59 	    void SetCryptoModeL(TUid aCryptoMode);
       
    60 	    void SetPaddingModeL(TUid aPaddingMode);
       
    61 	    TInt GetMaximumInputLengthL() const;
       
    62 	    TInt GetMaximumOutputLengthL() const;
       
    63 	    // End of MAsymmetricCipherBase Interface
       
    64 	    
       
    65 		// MAsymmetricCipher Interface
       
    66 		void ProcessL(const TDesC8& aInput, TDes8& aOutput);
       
    67 		
       
    68 		TUid ImplementationUid() const;
       
    69 		// Destructor
       
    70 		~CDummyECCCipherImpl();
       
    71 
       
    72 	private:
       
    73 		CDummyECCCipherImpl(TUid aCryptoMode, TUid aPaddingMode);
       
    74 		void ConstructL(const CKey& aKey);
       
    75 		void DecryptL(const TDesC8& aInput, TDes8& aOutput);
       
    76 		void EncryptL(const TDesC8& aInput, TDes8& aOutput);
       
    77 		
       
    78 	private:
       
    79 		/* The key extracted from a CKey object. This would just have 
       
    80 		 * a handle to the key stored in hardware. Hence the actual key 
       
    81 		 * would not be available to the user of this cryptoSPI plugin.
       
    82 		 */
       
    83 	    CKey* iKey;
       
    84 		
       
    85 		/// encryption or decryption
       
    86 		TUid iCryptoMode;		
       
    87 
       
    88 		/* The current padding scheme. This is not being used in the 
       
    89 		 * reference implementation.
       
    90 		 */
       
    91 		TUid iPaddingMode;
       
    92 		};
       
    93 
       
    94 			
       
    95 	}
       
    96 
       
    97 #endif	//	CDUMMYECCIMPL_H