sl@0: /* sl@0: * Copyright (c) 2007-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: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: #include "cryptodriver.h" sl@0: sl@0: /* sl@0: NOTE: The following member functions would normally be exported from a separate client DLL sl@0: but are included inline in this header file for convenience. sl@0: */ sl@0: sl@0: sl@0: /** sl@0: Opens a logical channel to the driver sl@0: sl@0: @return One of the system wide error codes. sl@0: */ sl@0: EXPORT_C TInt RCryptoDriver::Open() sl@0: { sl@0: return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Gets the HW versions sl@0: sl@0: @param aHwVersionsBuf A structure which will be filled with the versions sl@0: sl@0: @return KErrNone sl@0: */ sl@0: EXPORT_C TInt RCryptoDriver::GetHwVersions(THwVersionsBuf& aHwVersionsBuf) sl@0: { sl@0: return DoControl(EGetHwVersions,(TAny*)&aHwVersionsBuf); sl@0: } sl@0: sl@0: /** sl@0: Gets the current configuration settings. sl@0: sl@0: @param aConfig A structure which will be filled with the configuration settings. sl@0: sl@0: @return KErrNone sl@0: */ sl@0: EXPORT_C TInt RCryptoDriver::GetConfig(TConfigBuf& aConfig) sl@0: { sl@0: return DoControl(EGetConfig,(TAny*)&aConfig); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Sets the current configuration settings. sl@0: sl@0: @param aConfig The new configuration settings to be used. sl@0: sl@0: @return KErrInUse if there are outstanding data transfer requests. sl@0: KErrArgument if any configuration values are invalid. sl@0: KErrNone otherwise sl@0: */ sl@0: EXPORT_C TInt RCryptoDriver::SetConfig(const TConfigBuf& aConfig) sl@0: { sl@0: return DoControl(ESetConfig,(TAny*)&aConfig); sl@0: } sl@0: sl@0: EXPORT_C void RCryptoDriver::Random(TRequestStatus& aStatus,TDes8& aBuffer) sl@0: { sl@0: DoRequest(ERandom,aStatus,(TAny*)&aBuffer); sl@0: } sl@0: sl@0: sl@0: EXPORT_C void RCryptoDriver::RandomCancel() sl@0: { sl@0: DoCancel(1< sl@0: EXPORT_C TInt RCryptoDriver::SetAesConfig(TBool aEncrypt, TChainingMode aMode, sl@0: const TDesC8& aKey, const TDesC8& aIV) sl@0: { sl@0: TAesConfigBuf configBuf; sl@0: TAesConfig &config = configBuf(); sl@0: config.iEncrypt = aEncrypt; sl@0: config.iMode = aMode; sl@0: config.iKey = &aKey; sl@0: config.iIV = &aIV; sl@0: sl@0: return DoControl(EAesSetConfig, (TAny*)&configBuf); sl@0: } sl@0: sl@0: EXPORT_C void RCryptoDriver::AesWrite(TRequestStatus& aStatus, TDesC8& aBuffer) sl@0: { sl@0: DoRequest(EAesWrite, aStatus,(TAny*)&aBuffer); sl@0: } sl@0: EXPORT_C void RCryptoDriver::AesCancelWrite() sl@0: { sl@0: DoCancel(1<