First public contribution.
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
24 #include "cryptodriver.h"
27 NOTE: The following member functions would normally be exported from a separate client DLL
28 but are included inline in this header file for convenience.
33 Opens a logical channel to the driver
35 @return One of the system wide error codes.
37 EXPORT_C TInt RCryptoDriver::Open()
39 return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);
46 @param aHwVersionsBuf A structure which will be filled with the versions
50 EXPORT_C TInt RCryptoDriver::GetHwVersions(THwVersionsBuf& aHwVersionsBuf)
52 return DoControl(EGetHwVersions,(TAny*)&aHwVersionsBuf);
56 Gets the current configuration settings.
58 @param aConfig A structure which will be filled with the configuration settings.
62 EXPORT_C TInt RCryptoDriver::GetConfig(TConfigBuf& aConfig)
64 return DoControl(EGetConfig,(TAny*)&aConfig);
69 Sets the current configuration settings.
71 @param aConfig The new configuration settings to be used.
73 @return KErrInUse if there are outstanding data transfer requests.
74 KErrArgument if any configuration values are invalid.
77 EXPORT_C TInt RCryptoDriver::SetConfig(const TConfigBuf& aConfig)
79 return DoControl(ESetConfig,(TAny*)&aConfig);
82 EXPORT_C void RCryptoDriver::Random(TRequestStatus& aStatus,TDes8& aBuffer)
84 DoRequest(ERandom,aStatus,(TAny*)&aBuffer);
88 EXPORT_C void RCryptoDriver::RandomCancel()
94 EXPORT_C TInt RCryptoDriver::SetAesConfig(TBool aEncrypt, TChainingMode aMode,
95 const TDesC8& aKey, const TDesC8& aIV)
97 TAesConfigBuf configBuf;
98 TAesConfig &config = configBuf();
99 config.iEncrypt = aEncrypt;
100 config.iMode = aMode;
104 return DoControl(EAesSetConfig, (TAny*)&configBuf);
107 EXPORT_C void RCryptoDriver::AesWrite(TRequestStatus& aStatus, TDesC8& aBuffer)
109 DoRequest(EAesWrite, aStatus,(TAny*)&aBuffer);
111 EXPORT_C void RCryptoDriver::AesCancelWrite()
113 DoCancel(1<<EAesWrite);
116 EXPORT_C void RCryptoDriver::AesRead(TRequestStatus& aStatus, TDes8& aBuffer, TUint32 aLength)
118 DoRequest(EAesRead, aStatus,(TAny*)&aBuffer, (TAny*)aLength);
121 EXPORT_C void RCryptoDriver::AesCancelRead()
123 DoCancel(1<<EAesRead);