sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@internalComponent
|
sl@0
|
22 |
@released
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
#include "cryptodriver.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
/*
|
sl@0
|
27 |
NOTE: The following member functions would normally be exported from a separate client DLL
|
sl@0
|
28 |
but are included inline in this header file for convenience.
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
/**
|
sl@0
|
33 |
Opens a logical channel to the driver
|
sl@0
|
34 |
|
sl@0
|
35 |
@return One of the system wide error codes.
|
sl@0
|
36 |
*/
|
sl@0
|
37 |
EXPORT_C TInt RCryptoDriver::Open()
|
sl@0
|
38 |
{
|
sl@0
|
39 |
return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerThread);
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
|
sl@0
|
43 |
/**
|
sl@0
|
44 |
Gets the HW versions
|
sl@0
|
45 |
|
sl@0
|
46 |
@param aHwVersionsBuf A structure which will be filled with the versions
|
sl@0
|
47 |
|
sl@0
|
48 |
@return KErrNone
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
EXPORT_C TInt RCryptoDriver::GetHwVersions(THwVersionsBuf& aHwVersionsBuf)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
return DoControl(EGetHwVersions,(TAny*)&aHwVersionsBuf);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
/**
|
sl@0
|
56 |
Gets the current configuration settings.
|
sl@0
|
57 |
|
sl@0
|
58 |
@param aConfig A structure which will be filled with the configuration settings.
|
sl@0
|
59 |
|
sl@0
|
60 |
@return KErrNone
|
sl@0
|
61 |
*/
|
sl@0
|
62 |
EXPORT_C TInt RCryptoDriver::GetConfig(TConfigBuf& aConfig)
|
sl@0
|
63 |
{
|
sl@0
|
64 |
return DoControl(EGetConfig,(TAny*)&aConfig);
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
|
sl@0
|
68 |
/**
|
sl@0
|
69 |
Sets the current configuration settings.
|
sl@0
|
70 |
|
sl@0
|
71 |
@param aConfig The new configuration settings to be used.
|
sl@0
|
72 |
|
sl@0
|
73 |
@return KErrInUse if there are outstanding data transfer requests.
|
sl@0
|
74 |
KErrArgument if any configuration values are invalid.
|
sl@0
|
75 |
KErrNone otherwise
|
sl@0
|
76 |
*/
|
sl@0
|
77 |
EXPORT_C TInt RCryptoDriver::SetConfig(const TConfigBuf& aConfig)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
return DoControl(ESetConfig,(TAny*)&aConfig);
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
EXPORT_C void RCryptoDriver::Random(TRequestStatus& aStatus,TDes8& aBuffer)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
DoRequest(ERandom,aStatus,(TAny*)&aBuffer);
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
|
sl@0
|
88 |
EXPORT_C void RCryptoDriver::RandomCancel()
|
sl@0
|
89 |
{
|
sl@0
|
90 |
DoCancel(1<<ERandom);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
#include <e32debug.h>
|
sl@0
|
94 |
EXPORT_C TInt RCryptoDriver::SetAesConfig(TBool aEncrypt, TChainingMode aMode,
|
sl@0
|
95 |
const TDesC8& aKey, const TDesC8& aIV)
|
sl@0
|
96 |
{
|
sl@0
|
97 |
TAesConfigBuf configBuf;
|
sl@0
|
98 |
TAesConfig &config = configBuf();
|
sl@0
|
99 |
config.iEncrypt = aEncrypt;
|
sl@0
|
100 |
config.iMode = aMode;
|
sl@0
|
101 |
config.iKey = &aKey;
|
sl@0
|
102 |
config.iIV = &aIV;
|
sl@0
|
103 |
|
sl@0
|
104 |
return DoControl(EAesSetConfig, (TAny*)&configBuf);
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
EXPORT_C void RCryptoDriver::AesWrite(TRequestStatus& aStatus, TDesC8& aBuffer)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
DoRequest(EAesWrite, aStatus,(TAny*)&aBuffer);
|
sl@0
|
110 |
}
|
sl@0
|
111 |
EXPORT_C void RCryptoDriver::AesCancelWrite()
|
sl@0
|
112 |
{
|
sl@0
|
113 |
DoCancel(1<<EAesWrite);
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
EXPORT_C void RCryptoDriver::AesRead(TRequestStatus& aStatus, TDes8& aBuffer, TUint32 aLength)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
DoRequest(EAesRead, aStatus,(TAny*)&aBuffer, (TAny*)aLength);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
EXPORT_C void RCryptoDriver::AesCancelRead()
|
sl@0
|
122 |
{
|
sl@0
|
123 |
DoCancel(1<<EAesRead);
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
// End of file
|