|
1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "tpkcs7stepbase.h" |
|
20 #include <testexecutelog.h> |
|
21 |
|
22 CTPKCS7StepBase::~CTPKCS7StepBase() |
|
23 { |
|
24 delete iRawData; |
|
25 iFs.Close (); |
|
26 } |
|
27 |
|
28 CTPKCS7StepBase::CTPKCS7StepBase() |
|
29 { |
|
30 } |
|
31 |
|
32 HBufC8* CTPKCS7StepBase::readFileL (TPtrC tag) |
|
33 { |
|
34 TPtrC fileName; |
|
35 if (GetStringFromConfig(ConfigSection(), tag, fileName) == EFalse) |
|
36 { |
|
37 return NULL; |
|
38 } |
|
39 |
|
40 RFile file; |
|
41 if (file.Open(iFs, fileName, EFileRead) != KErrNone) |
|
42 { |
|
43 INFO_PRINTF2(_L("Cannot open file %S for reading"), &fileName); |
|
44 return NULL; |
|
45 } |
|
46 CleanupClosePushL(file); |
|
47 |
|
48 TInt fileSize = 0; |
|
49 User::LeaveIfError(file.Size(fileSize)); |
|
50 |
|
51 HBufC8* result = HBufC8::NewL(fileSize); |
|
52 result->Des().SetLength(fileSize); |
|
53 |
|
54 TPtr8 rawDataPtr(result->Des()); |
|
55 rawDataPtr.SetLength(fileSize); |
|
56 file.Read (rawDataPtr); |
|
57 |
|
58 CleanupStack::PopAndDestroy (&file); |
|
59 |
|
60 INFO_PRINTF3(_L("Read %d octets from %S"), result->Size(), &fileName); |
|
61 |
|
62 return result; |
|
63 } |
|
64 |
|
65 TVerdict CTPKCS7StepBase::doTestStepPreambleL() |
|
66 { |
|
67 User::LeaveIfError (iFs.Connect()); |
|
68 |
|
69 SetTestStepResult(EPass); |
|
70 |
|
71 iRawData = readFileL (_L("File")); |
|
72 if (iRawData == NULL) |
|
73 { |
|
74 INFO_PRINTF1(_L("Failed to read 'File' section of script")); |
|
75 SetTestStepResult(ETestSuiteError); |
|
76 } |
|
77 |
|
78 HBufC8* certificate = readFileL (_L("RootCertificate")); |
|
79 if (certificate == NULL) |
|
80 { |
|
81 INFO_PRINTF1(_L("No 'RootCertificate' available")); |
|
82 } |
|
83 else |
|
84 { |
|
85 CleanupStack::PushL (certificate); |
|
86 iRootCertificate = CX509Certificate::NewL(*certificate); |
|
87 CleanupStack::PopAndDestroy (certificate); |
|
88 } |
|
89 |
|
90 //for encrypted_data |
|
91 |
|
92 //get Salt value for comparison |
|
93 iSaltValue = readFileL (_L("Salt")); |
|
94 if(iSaltValue == NULL) |
|
95 { |
|
96 INFO_PRINTF1(_L("No 'Salt' available")); |
|
97 } |
|
98 //get content data |
|
99 iContentData = readFileL (_L("ContentData")); |
|
100 if(iContentData == NULL) |
|
101 { |
|
102 INFO_PRINTF1(_L("No 'ContentData' available")); |
|
103 } |
|
104 |
|
105 //for digest_Info |
|
106 //Digest |
|
107 iDigest = readFileL (_L("DigestValue")); |
|
108 if(iDigest == NULL) |
|
109 { |
|
110 INFO_PRINTF1(_L("No 'DigestValue' available")); |
|
111 } |
|
112 |
|
113 //EncodeParams |
|
114 iEncodedParams = readFileL (_L("EncodedParams")); |
|
115 if(iEncodedParams == NULL) |
|
116 { |
|
117 INFO_PRINTF1(_L("No 'EncodedParams' available")); |
|
118 } |
|
119 |
|
120 return TestStepResult(); |
|
121 } |