sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Asymmetric cipher abstract interface sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __CRYPTOAPI_ASYMMETRICCIPHER_H__ sl@0: #define __CRYPTOAPI_ASYMMETRICCIPHER_H__ sl@0: sl@0: #include sl@0: sl@0: namespace CryptoSpi sl@0: { sl@0: /** sl@0: The Asymmetric Cipher Base definition. Intended to allow plug-ins sl@0: to implement extensible Asymmetric cipher functionality, and to work with all sl@0: known existing Asymmetric algorithms, e.g. RSA DSA etc sl@0: */ sl@0: class MAsymmetricCipherBase : public MPlugin sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Set the public key of this cipher. Reset() is called to reinitialise the cipher. sl@0: @param aKey The public key. sl@0: @leave KErrArgument if aKey is not of the expected type. sl@0: @leave KErrNotSupported if the key is not of valid length. sl@0: @leave ... Any of the crypto error codes defined in sl@0: cryptospi_errs.h or any of the system-wide error codes. sl@0: */ sl@0: virtual void SetKeyL(const CKey& aKey) = 0; sl@0: sl@0: /** sl@0: Set the crypto mode of this cipher. Reset() is called to reinitialise the cipher. sl@0: @param aCryptoMode The crypto mode sl@0: @leave KErrNotSupported if the specified mode is not supported. sl@0: @leave ... Any of the crypto error codes defined in sl@0: cryptospi_errs.h or any of the system-wide error codes. sl@0: */ sl@0: virtual void SetCryptoModeL(TUid aCryptoMode) = 0; sl@0: sl@0: /** sl@0: Set padding Mode of this cipher. Reset() is called to reinitialise the cipher. sl@0: @param aPaddingMode The padding mode sl@0: @leave KErrNotSupported if the specified mode is not supported. sl@0: @leave ... Any of the crypto error codes defined in sl@0: cryptospi_errs.h or any of the system-wide error codes. sl@0: */ sl@0: virtual void SetPaddingModeL(TUid aPaddingMode) = 0; sl@0: sl@0: /** sl@0: Gets the maximum size of input accepted by this object. sl@0: @return The maximum input length allowed in bytes. sl@0: @leave ... Any of the crypto error codes defined in sl@0: cryptospi_errs.h or any of the system-wide error codes. sl@0: */ sl@0: virtual TInt GetMaximumInputLengthL() const = 0; sl@0: sl@0: /** sl@0: Gets the maximum size of output that can be generated by this object. sl@0: @return The maximum output length in bytes. sl@0: @leave ... Any of the crypto error codes defined in sl@0: cryptospi_errs.h or any of the system-wide error codes. sl@0: */ sl@0: virtual TInt GetMaximumOutputLengthL() const = 0; sl@0: }; sl@0: sl@0: class MAsymmetricCipher : public MAsymmetricCipherBase sl@0: { sl@0: public: sl@0: /** sl@0: Encrypts or decrypts aInput and appends the result to aOutput. sl@0: @param aInput The input data to be processed. sl@0: @param aOutput The resulting processed data appended to aOutput. sl@0: @leave ... Any of the crypto error codes defined in sl@0: cryptospi_errs.h or any of the system-wide error codes. sl@0: */ sl@0: virtual void ProcessL(const TDesC8& aInput, TDes8& aOutput) = 0; sl@0: }; sl@0: sl@0: class MAsyncAsymmetricCipher : public MAsymmetricCipherBase sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Encrypts or decrypts aInput and appends the result to aOutput asynchronously sl@0: @param aInput The input data to be processed. sl@0: @param aOutput The resulting processed data appended to aOutput. sl@0: @param aRequestStatus sl@0: @leave ... Any of the crypto error codes defined in sl@0: cryptospi_errs.h or any of the system-wide error codes. sl@0: */ sl@0: virtual void ProcessL(const TDesC8& aInput, TDes8& aOutput, TRequestStatus& aRequestStatus) = 0; sl@0: sl@0: /** sl@0: Cancel the outstanding request sl@0: */ sl@0: virtual void Cancel() = 0; sl@0: }; sl@0: } sl@0: sl@0: #endif //__CRYPTOAPI_ASYMMETRICCIPHER_H__