Update contrib.
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 #ifndef CRYPTODRIVER_H
25 #define CRYPTODRIVER_H
29 #ifndef __KERNEL_MODE__
34 User interface for crypto hw
36 class RCryptoDriver : public RBusLogicalChannel
40 Structure for holding driver capabilities information
49 Structure for holding driver configuration data
54 TInt iFakeDriverSetting;
57 Typedef used for passing TConfig structure to GetConfig and SetConfig APIs
59 typedef TPckgBuf<TConfig> TConfigBuf;
62 Structure for holding h/w version information
67 TUint32 iRngHwVersion; ///< RNG h/w version number
68 TUint32 iDes3DesHwVersion; ///< 3DES h/w version number
69 TUint32 iSha1Md5HwVersion; ///< SHA1 h/w version number
70 TUint32 iAesHwVersion; ///< AES h/w version number
71 TUint32 iPkaHwVersion; ///< PKA h/w version number
73 typedef TPckgBuf<THwVersions> THwVersionsBuf;
77 IMPORT_C TInt GetHwVersions(THwVersionsBuf& aHwVersionsBuf);
79 IMPORT_C TInt GetConfig(TConfigBuf& aConfig);
80 IMPORT_C TInt SetConfig(const TConfigBuf& aConfig);
82 inline static const TDesC& Name();
83 inline static TVersion VersionRequired();
86 Fill buffer with random data
87 Only one "random" request may be pending at any time.
89 @param aStatus The request to be signalled when the data has been received.
90 The result value will be set to KErrNone on success;
91 or set to one of the system wide error codes when an error occurs.
93 @param aData Fills the descriptor up to its current length with
94 random data. Any existing contents are lost.
96 IMPORT_C void Random(TRequestStatus& aStatus, TDes8& aDestination);
98 Causes the current Random request to cancel synchronously.
100 IMPORT_C void RandomCancel();
102 enum TChainingMode {EEcbMode, ECbcMode, ECntrMode};
104 @param aEncrypt ETrue for encryption
105 @param aMode See TChainingMode
106 @param aKey Must be one of the following lengths - 128, 192 or 256 bits (16, 24 or 32 bytes).
107 @param aIV Initialisation Vector, Length must be, 0 for ECB mode, or 16 bytes (all other mdoes)
109 IMPORT_C TInt SetAesConfig(TBool aEncrypt, TChainingMode aMode, const TDesC8& aKey, const TDesC8& aIV);
112 Any length of data may be written, but the h/w will only
113 process the data in multiples of 16 bytes. Any remainder will
114 be buffered pending future writes.
116 Padding is NOT done by this function.
123 IMPORT_C void AesWrite(TRequestStatus& aStatus, TDesC8& aBuffer);
126 Causes the current "to hw" requests to cancel synchronously.
128 IMPORT_C void AesCancelWrite();
131 The destination buffer is overwritten. This call will block
132 until the specified number of bytes have been read (the max
135 The length is not required to be a multiple of the block size
136 (16 bytes), but note that written data is only processed in
137 multiples of the block size.
139 Data is appended to the supplied buffer.
145 IMPORT_C void AesRead(TRequestStatus& aStatus, TDes8& aBuffer, TUint32 aLenth);
148 Causes the current "from hw" requests to cancel synchronously.
150 IMPORT_C void AesCancelRead();
155 Enumeration of Control messages.
166 Enumeration of Request messages.
174 EAllRequests = (1<<ENumRequests)-1
178 Structure for holding driver configuration data
188 typedef TPckgBuf<TAesConfig> TAesConfigBuf;
190 // Kernel side LDD channel is a friend
191 friend class DCryptoLddChannel;
192 friend class DLddChanAes;
197 Returns the driver's name
199 inline const TDesC& RCryptoDriver::Name()
201 _LIT(KDriver1Name,"crypto");
206 Returns the version number of the driver
208 inline TVersion RCryptoDriver::VersionRequired()
210 const TInt KMajorVersionNumber=1;
211 const TInt KMinorVersionNumber=0;
212 const TInt KBuildVersionNumber=KE32BuildVersionNumber;
213 return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);