sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2010 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 "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 |
// INCLUDE FILES
|
sl@0
|
19 |
#include <e32svr.h>
|
sl@0
|
20 |
#include "tcrypt.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
// EXTERNAL FUNCTION PROTOTYPES
|
sl@0
|
23 |
extern "C" {
|
sl@0
|
24 |
IMPORT_C char *crypt(const char *key, const char *salt);
|
sl@0
|
25 |
IMPORT_C void setkey(const char *key);
|
sl@0
|
26 |
IMPORT_C void encrypt(char block[], int edflag);
|
sl@0
|
27 |
}
|
sl@0
|
28 |
|
sl@0
|
29 |
// LOCAL FUNCTION PROTOTYPES
|
sl@0
|
30 |
LOCAL_C void GetBitVector(char data[], char* buffer);
|
sl@0
|
31 |
LOCAL_C char *TrimWhiteSpaces(char *string);
|
sl@0
|
32 |
|
sl@0
|
33 |
// ============================= LOCAL FUNCTIONS ===============================
|
sl@0
|
34 |
|
sl@0
|
35 |
// -----------------------------------------------------------------------------
|
sl@0
|
36 |
// TrimWhiteSpaces
|
sl@0
|
37 |
// To to trim whitespaces in the input string
|
sl@0
|
38 |
// -----------------------------------------------------------------------------
|
sl@0
|
39 |
//
|
sl@0
|
40 |
LOCAL_C char *TrimWhiteSpaces(char *string)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
char *pTemp = string;
|
sl@0
|
43 |
for(;*string != '\0'; string++)
|
sl@0
|
44 |
{
|
sl@0
|
45 |
if((*string == ' ') || (*string == '\t'))
|
sl@0
|
46 |
{
|
sl@0
|
47 |
pTemp++;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
}
|
sl@0
|
50 |
|
sl@0
|
51 |
return pTemp;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
// -----------------------------------------------------------------------------
|
sl@0
|
55 |
// GetBitVector
|
sl@0
|
56 |
// This function unpacks the byte to obtain the corresponding bit vector
|
sl@0
|
57 |
// -----------------------------------------------------------------------------
|
sl@0
|
58 |
//
|
sl@0
|
59 |
LOCAL_C void GetBitVector(char data[], char* buffer)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
int temp;
|
sl@0
|
62 |
if(buffer != NULL )
|
sl@0
|
63 |
{
|
sl@0
|
64 |
temp = strlen(buffer);
|
sl@0
|
65 |
for(int i = 0 ; i<temp ; ++i, ++buffer)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
data[i] = *buffer - '0';
|
sl@0
|
68 |
}
|
sl@0
|
69 |
}
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
|
sl@0
|
73 |
CTestCrypt::~CTestCrypt()
|
sl@0
|
74 |
{
|
sl@0
|
75 |
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
CTestCrypt::CTestCrypt(const TDesC& aStepName)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
// MANDATORY Call to base class method to set up the human readable name for logging.
|
sl@0
|
81 |
SetTestStepName(aStepName);
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
TVerdict CTestCrypt::doTestStepPreambleL()
|
sl@0
|
85 |
{
|
sl@0
|
86 |
__UHEAP_MARK;
|
sl@0
|
87 |
|
sl@0
|
88 |
SetTestStepResult(EPass);
|
sl@0
|
89 |
iTestDataFile = fopen("C:\\tcrypt\\test_data.dat", "r");
|
sl@0
|
90 |
if(iTestDataFile == NULL)
|
sl@0
|
91 |
{
|
sl@0
|
92 |
SetTestStepResult(EFail);
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
return TestStepResult();
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
TVerdict CTestCrypt::doTestStepPostambleL()
|
sl@0
|
99 |
{
|
sl@0
|
100 |
fclose(iTestDataFile);
|
sl@0
|
101 |
__UHEAP_MARKEND;
|
sl@0
|
102 |
return TestStepResult();
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
TVerdict CTestCrypt::doTestStepL()
|
sl@0
|
106 |
{
|
sl@0
|
107 |
int err;
|
sl@0
|
108 |
|
sl@0
|
109 |
if(TestStepName() == KEncrypt)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
INFO_PRINTF1(_L("Encrypt():"));
|
sl@0
|
112 |
err = Encrypt();
|
sl@0
|
113 |
SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
|
sl@0
|
114 |
}
|
sl@0
|
115 |
else if(TestStepName() == KCrypt)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
INFO_PRINTF1(_L("Crypt():"));
|
sl@0
|
118 |
err = Crypt();
|
sl@0
|
119 |
SetTestStepResult(err ? static_cast<TVerdict>(err) : EPass);
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
return TestStepResult();
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
|
sl@0
|
126 |
// -----------------------------------------------------------------------------
|
sl@0
|
127 |
// CTestCrypt::Encrypt
|
sl@0
|
128 |
// Encrypt function
|
sl@0
|
129 |
// -----------------------------------------------------------------------------
|
sl@0
|
130 |
//
|
sl@0
|
131 |
TInt CTestCrypt::Encrypt()
|
sl@0
|
132 |
{
|
sl@0
|
133 |
static int tId = 0;
|
sl@0
|
134 |
char pTemp[30];
|
sl@0
|
135 |
memset(pTemp, 0, 30);
|
sl@0
|
136 |
sprintf(pTemp, "ENCRYPT_TEST_DATA_%d", ++tId);
|
sl@0
|
137 |
INFO_PRINTF2(_L("Begin: ENCRYPT_TEST_DATA_%d\n"), tId);
|
sl@0
|
138 |
|
sl@0
|
139 |
// locate "test_data_id" from within the file
|
sl@0
|
140 |
if(!RepositionFilePointer(pTemp))
|
sl@0
|
141 |
{
|
sl@0
|
142 |
// String not found...invalid test data ID
|
sl@0
|
143 |
INFO_PRINTF1(_L("Requested test data ID could not be found\n"));
|
sl@0
|
144 |
return KErrNotFound;
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
// Get the key, data block, operation to be performed and the
|
sl@0
|
148 |
// expected output for the current test data ID
|
sl@0
|
149 |
char key[64] =
|
sl@0
|
150 |
{
|
sl@0
|
151 |
0
|
sl@0
|
152 |
};
|
sl@0
|
153 |
char block[64] =
|
sl@0
|
154 |
{
|
sl@0
|
155 |
0
|
sl@0
|
156 |
};
|
sl@0
|
157 |
char output[64] =
|
sl@0
|
158 |
{
|
sl@0
|
159 |
0
|
sl@0
|
160 |
};
|
sl@0
|
161 |
int edflag = -1;
|
sl@0
|
162 |
if(GetEncryptTestData(key, block, &edflag, output) != KErrNone)
|
sl@0
|
163 |
{
|
sl@0
|
164 |
// Test data not found or is not present in the expected
|
sl@0
|
165 |
// format
|
sl@0
|
166 |
INFO_PRINTF1(_L("Test data not found or is not present in the expected format\n"));
|
sl@0
|
167 |
return KErrNotFound;
|
sl@0
|
168 |
}
|
sl@0
|
169 |
|
sl@0
|
170 |
// Perform encryption/decryption
|
sl@0
|
171 |
|
sl@0
|
172 |
// Invoke setkey from the libcrypt library
|
sl@0
|
173 |
setkey(key);
|
sl@0
|
174 |
|
sl@0
|
175 |
// Call the encrypt function
|
sl@0
|
176 |
encrypt(block,edflag);
|
sl@0
|
177 |
|
sl@0
|
178 |
// Verify if the final output is same as the expected output
|
sl@0
|
179 |
|
sl@0
|
180 |
if(!strcmp(block,block))
|
sl@0
|
181 |
{
|
sl@0
|
182 |
INFO_PRINTF2(_L("End: ENCRYPT_TEST_DATA_%d\n"), tId);
|
sl@0
|
183 |
// Test case passed
|
sl@0
|
184 |
return KErrNone;
|
sl@0
|
185 |
}
|
sl@0
|
186 |
INFO_PRINTF1(_L("Output from the encrypt() function does not match the \"expected output\""));
|
sl@0
|
187 |
INFO_PRINTF2(_L("End: ENCRYPT_TEST_DATA_%d\n"), tId);
|
sl@0
|
188 |
return KErrNotFound;
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
// -----------------------------------------------------------------------------
|
sl@0
|
192 |
// CTestCrypt::RepositionFilePointer
|
sl@0
|
193 |
// This function positions the file pointer to the line immediately following
|
sl@0
|
194 |
// the string aString
|
sl@0
|
195 |
// -----------------------------------------------------------------------------
|
sl@0
|
196 |
//
|
sl@0
|
197 |
|
sl@0
|
198 |
TInt CTestCrypt::RepositionFilePointer(const char *aString)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
char buffer[256];
|
sl@0
|
201 |
char * ptr = NULL;
|
sl@0
|
202 |
while(fgets((char*)buffer, 256, iTestDataFile) != NULL)
|
sl@0
|
203 |
{
|
sl@0
|
204 |
ptr = NULL;
|
sl@0
|
205 |
|
sl@0
|
206 |
if((ptr=strchr(buffer,'\r')) || (ptr=strchr(buffer,'\n'))) //check for both
|
sl@0
|
207 |
*ptr='\0';
|
sl@0
|
208 |
if(!strcmp(buffer, aString))
|
sl@0
|
209 |
{
|
sl@0
|
210 |
return 1;
|
sl@0
|
211 |
}
|
sl@0
|
212 |
memset(buffer, 0, 256);
|
sl@0
|
213 |
}
|
sl@0
|
214 |
return 0;
|
sl@0
|
215 |
}
|
sl@0
|
216 |
|
sl@0
|
217 |
// -----------------------------------------------------------------------------
|
sl@0
|
218 |
// CTestCrypt::GetEncryptTestData
|
sl@0
|
219 |
// This function reads the test data for encrypt() API
|
sl@0
|
220 |
// -----------------------------------------------------------------------------
|
sl@0
|
221 |
//
|
sl@0
|
222 |
TInt CTestCrypt::GetEncryptTestData(char key[], char block[], int *edflag, char output[])
|
sl@0
|
223 |
{
|
sl@0
|
224 |
char buffer[256];
|
sl@0
|
225 |
char *p = NULL;
|
sl@0
|
226 |
bool bKey = false, // will be set to true upon reading 'key'
|
sl@0
|
227 |
bBlock = false, // will be set to true upon reading 'data block'
|
sl@0
|
228 |
bEdflag = false, // will be set to true upon reading 'edflag'
|
sl@0
|
229 |
bOutput = false; // will be set to true upon reading 'expected output'
|
sl@0
|
230 |
|
sl@0
|
231 |
char *pTemp = NULL;
|
sl@0
|
232 |
char * ptr = NULL;
|
sl@0
|
233 |
|
sl@0
|
234 |
while((p = fgets(buffer, 256, iTestDataFile)) != NULL)
|
sl@0
|
235 |
{
|
sl@0
|
236 |
|
sl@0
|
237 |
ptr = NULL;
|
sl@0
|
238 |
|
sl@0
|
239 |
if((ptr=strchr(buffer,'\r')) || (ptr=strchr(buffer,'\n'))) //check for both
|
sl@0
|
240 |
*ptr='\0';
|
sl@0
|
241 |
if(strstr(buffer, "//") != NULL)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
continue;
|
sl@0
|
244 |
}
|
sl@0
|
245 |
if(!strcmp(buffer, "END_TEST_DATA"))
|
sl@0
|
246 |
{
|
sl@0
|
247 |
if(bKey && bBlock && bEdflag && bOutput)
|
sl@0
|
248 |
{
|
sl@0
|
249 |
return KErrNone;
|
sl@0
|
250 |
}
|
sl@0
|
251 |
return KErrNotFound;
|
sl@0
|
252 |
}
|
sl@0
|
253 |
if(strstr(buffer, "KEY") != NULL)
|
sl@0
|
254 |
{
|
sl@0
|
255 |
// Read the key
|
sl@0
|
256 |
|
sl@0
|
257 |
// Get bytes...
|
sl@0
|
258 |
pTemp = strstr(buffer, ":");
|
sl@0
|
259 |
if(pTemp != NULL)
|
sl@0
|
260 |
{
|
sl@0
|
261 |
pTemp++;
|
sl@0
|
262 |
pTemp = TrimWhiteSpaces(pTemp);
|
sl@0
|
263 |
GetBitVector(key, pTemp);
|
sl@0
|
264 |
}
|
sl@0
|
265 |
bKey = true;
|
sl@0
|
266 |
continue;
|
sl@0
|
267 |
}
|
sl@0
|
268 |
if(strstr(buffer, "DATA_BLOCK") != NULL)
|
sl@0
|
269 |
{
|
sl@0
|
270 |
// Read the data block
|
sl@0
|
271 |
|
sl@0
|
272 |
pTemp = strstr(buffer, ":");
|
sl@0
|
273 |
if(pTemp != NULL)
|
sl@0
|
274 |
{
|
sl@0
|
275 |
pTemp++;
|
sl@0
|
276 |
pTemp = TrimWhiteSpaces(pTemp);
|
sl@0
|
277 |
GetBitVector(block, pTemp);
|
sl@0
|
278 |
}
|
sl@0
|
279 |
bBlock = true;
|
sl@0
|
280 |
continue;
|
sl@0
|
281 |
}
|
sl@0
|
282 |
if(strstr(buffer, "ED_FLAG") != NULL)
|
sl@0
|
283 |
{
|
sl@0
|
284 |
// Read the ed_flag parameter
|
sl@0
|
285 |
|
sl@0
|
286 |
pTemp = strstr(buffer, ":");
|
sl@0
|
287 |
if(pTemp != NULL)
|
sl@0
|
288 |
{
|
sl@0
|
289 |
pTemp++;
|
sl@0
|
290 |
pTemp = TrimWhiteSpaces(pTemp);
|
sl@0
|
291 |
*edflag = (*pTemp) - '0';
|
sl@0
|
292 |
}
|
sl@0
|
293 |
bEdflag = true;
|
sl@0
|
294 |
continue;
|
sl@0
|
295 |
}
|
sl@0
|
296 |
if(strstr(buffer, "EXPECTED_OUTPUT") != NULL)
|
sl@0
|
297 |
{
|
sl@0
|
298 |
// Read the bit vector for the expected output
|
sl@0
|
299 |
|
sl@0
|
300 |
pTemp = strstr(buffer, ":");
|
sl@0
|
301 |
if(pTemp != NULL)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
pTemp++;
|
sl@0
|
304 |
pTemp = TrimWhiteSpaces(pTemp);
|
sl@0
|
305 |
GetBitVector(output, pTemp);
|
sl@0
|
306 |
}
|
sl@0
|
307 |
bOutput = true;
|
sl@0
|
308 |
continue;
|
sl@0
|
309 |
}
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
return KErrNotFound;
|
sl@0
|
313 |
}
|
sl@0
|
314 |
|
sl@0
|
315 |
// -----------------------------------------------------------------------------
|
sl@0
|
316 |
// CTestCrypt::Crypt
|
sl@0
|
317 |
// Test function to perform crypt() on the input data
|
sl@0
|
318 |
// -----------------------------------------------------------------------------
|
sl@0
|
319 |
//
|
sl@0
|
320 |
TInt CTestCrypt::Crypt()
|
sl@0
|
321 |
{
|
sl@0
|
322 |
static int tId = 0;
|
sl@0
|
323 |
char pTemp[30];
|
sl@0
|
324 |
memset(pTemp, 0, 30);
|
sl@0
|
325 |
sprintf(pTemp, "CRYPT_TEST_DATA_%d", ++tId);
|
sl@0
|
326 |
INFO_PRINTF2(_L("Begin CRYPT_TEST_DATA_%d\n"), tId);
|
sl@0
|
327 |
|
sl@0
|
328 |
// locate "test_data_id" from within the file
|
sl@0
|
329 |
if(!RepositionFilePointer(pTemp))
|
sl@0
|
330 |
{
|
sl@0
|
331 |
// String not found...invalid test data ID
|
sl@0
|
332 |
INFO_PRINTF1(_L("Requested test data ID could not be found\n"));
|
sl@0
|
333 |
return KErrNotFound;
|
sl@0
|
334 |
}
|
sl@0
|
335 |
|
sl@0
|
336 |
char password[34] =
|
sl@0
|
337 |
{
|
sl@0
|
338 |
'\0'
|
sl@0
|
339 |
};
|
sl@0
|
340 |
char salt[30] =
|
sl@0
|
341 |
{
|
sl@0
|
342 |
'\0'
|
sl@0
|
343 |
};
|
sl@0
|
344 |
char output[35] =
|
sl@0
|
345 |
{
|
sl@0
|
346 |
'\0'
|
sl@0
|
347 |
};
|
sl@0
|
348 |
|
sl@0
|
349 |
if(GetCryptTestData(password, salt, output) != KErrNone)
|
sl@0
|
350 |
{
|
sl@0
|
351 |
// Data not in the expected format or is invalid
|
sl@0
|
352 |
INFO_PRINTF1(_L("Test data not found or is not present in the expected format\n"));
|
sl@0
|
353 |
return KErrNotFound;
|
sl@0
|
354 |
}
|
sl@0
|
355 |
|
sl@0
|
356 |
char *crypt_output = NULL;
|
sl@0
|
357 |
// Invoke crypt()
|
sl@0
|
358 |
crypt_output = crypt(password,salt);
|
sl@0
|
359 |
if(!strcmp(output,""))
|
sl@0
|
360 |
{
|
sl@0
|
361 |
// Since salt is NULL, the expected output is ignored...
|
sl@0
|
362 |
return KErrNone;
|
sl@0
|
363 |
}
|
sl@0
|
364 |
if(!strcmp(salt, ""))
|
sl@0
|
365 |
{
|
sl@0
|
366 |
// salt is NULL, so skip the first byte from the crypt output
|
sl@0
|
367 |
if(crypt_output != NULL)
|
sl@0
|
368 |
{
|
sl@0
|
369 |
crypt_output++;
|
sl@0
|
370 |
if(!strcmp(crypt_output, &output[0]))
|
sl@0
|
371 |
{
|
sl@0
|
372 |
INFO_PRINTF2(_L("End: CRYPT_TEST_DATA_%d\n"), tId);
|
sl@0
|
373 |
return KErrNone;
|
sl@0
|
374 |
}
|
sl@0
|
375 |
INFO_PRINTF1(_L("Output from the crypt() function does not match the \"expected output\""));
|
sl@0
|
376 |
return KErrNotFound;
|
sl@0
|
377 |
}
|
sl@0
|
378 |
}
|
sl@0
|
379 |
else
|
sl@0
|
380 |
{
|
sl@0
|
381 |
// salt is not NULL
|
sl@0
|
382 |
if(!strcmp(crypt_output, output))
|
sl@0
|
383 |
{
|
sl@0
|
384 |
INFO_PRINTF2(_L("End: CRYPT_TEST_DATA_%d\n"), tId);
|
sl@0
|
385 |
return KErrNone;
|
sl@0
|
386 |
}
|
sl@0
|
387 |
INFO_PRINTF1(_L("Output from the crypt() function does not match the \"expected output\""));
|
sl@0
|
388 |
return KErrNotFound;
|
sl@0
|
389 |
}
|
sl@0
|
390 |
return KErrNotFound;
|
sl@0
|
391 |
}
|
sl@0
|
392 |
|
sl@0
|
393 |
// -----------------------------------------------------------------------------
|
sl@0
|
394 |
// CTestCrypt::GetCryptTestData
|
sl@0
|
395 |
// To retrieve the test data for crypt() API
|
sl@0
|
396 |
// -----------------------------------------------------------------------------
|
sl@0
|
397 |
//
|
sl@0
|
398 |
TInt CTestCrypt::GetCryptTestData(char password[], char salt[], char output[])
|
sl@0
|
399 |
{
|
sl@0
|
400 |
char buffer[256];
|
sl@0
|
401 |
char *p = NULL;
|
sl@0
|
402 |
char *pTemp = NULL;
|
sl@0
|
403 |
int nLength = 0;
|
sl@0
|
404 |
bool bPassword = false,
|
sl@0
|
405 |
bSalt = false,
|
sl@0
|
406 |
bOutput = false;
|
sl@0
|
407 |
char * ptr = NULL;
|
sl@0
|
408 |
|
sl@0
|
409 |
while((p = fgets(buffer, 256, iTestDataFile)) != NULL)
|
sl@0
|
410 |
{
|
sl@0
|
411 |
ptr = NULL;
|
sl@0
|
412 |
|
sl@0
|
413 |
if((ptr=strchr(buffer,'\r')) || (ptr=strchr(buffer,'\n'))) //check for both
|
sl@0
|
414 |
*ptr='\0';
|
sl@0
|
415 |
if(strstr(buffer, "//") != NULL) // skip the comments
|
sl@0
|
416 |
{
|
sl@0
|
417 |
// "//" could appear within password or salt, so further
|
sl@0
|
418 |
// check is required
|
sl@0
|
419 |
|
sl@0
|
420 |
// Since judicious use of whitespaces is allowed only from within
|
sl@0
|
421 |
// the comment lines, the comment line will always start with
|
sl@0
|
422 |
// "//"
|
sl@0
|
423 |
if(buffer[0] == '/' && buffer[1] == '/')
|
sl@0
|
424 |
{
|
sl@0
|
425 |
continue;
|
sl@0
|
426 |
}
|
sl@0
|
427 |
}
|
sl@0
|
428 |
if(!strcmp(buffer, "END_TEST_DATA"))
|
sl@0
|
429 |
{
|
sl@0
|
430 |
if(bPassword && bSalt && bOutput)
|
sl@0
|
431 |
{
|
sl@0
|
432 |
return KErrNone;
|
sl@0
|
433 |
}
|
sl@0
|
434 |
return KErrNotFound;
|
sl@0
|
435 |
}
|
sl@0
|
436 |
|
sl@0
|
437 |
// Verify if the input buffer has "data". Data is followed by ":"
|
sl@0
|
438 |
pTemp = strstr(buffer, ":");
|
sl@0
|
439 |
if(pTemp != NULL)
|
sl@0
|
440 |
{
|
sl@0
|
441 |
pTemp++;
|
sl@0
|
442 |
pTemp = TrimWhiteSpaces(pTemp);
|
sl@0
|
443 |
nLength = strlen(pTemp);
|
sl@0
|
444 |
if(strstr(buffer, "PASSWORD") != NULL)
|
sl@0
|
445 |
{
|
sl@0
|
446 |
strncpy(password,pTemp,nLength);
|
sl@0
|
447 |
bPassword = true;
|
sl@0
|
448 |
continue;
|
sl@0
|
449 |
}
|
sl@0
|
450 |
else if(strstr(buffer, "SALT") != NULL)
|
sl@0
|
451 |
{
|
sl@0
|
452 |
strncpy(salt,pTemp,nLength);
|
sl@0
|
453 |
bSalt = true;
|
sl@0
|
454 |
continue;
|
sl@0
|
455 |
}
|
sl@0
|
456 |
else if(strstr(buffer, "EXPECTED_OUTPUT") != NULL)
|
sl@0
|
457 |
{
|
sl@0
|
458 |
strncpy(output,pTemp,nLength);
|
sl@0
|
459 |
bOutput = true;
|
sl@0
|
460 |
continue;
|
sl@0
|
461 |
}
|
sl@0
|
462 |
else
|
sl@0
|
463 |
{
|
sl@0
|
464 |
// Unexpected output
|
sl@0
|
465 |
return KErrNotFound;
|
sl@0
|
466 |
}
|
sl@0
|
467 |
}
|
sl@0
|
468 |
}
|
sl@0
|
469 |
return KErrNotFound;
|
sl@0
|
470 |
}
|
sl@0
|
471 |
|
sl@0
|
472 |
// End of File
|
sl@0
|
473 |
|