|
1 /* |
|
2 * Copyright (c) 2008-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 "badconfigwriter.h" |
|
20 #include <iostream> |
|
21 #include <sstream> |
|
22 #include "tcertapp_bad.h" |
|
23 |
|
24 // Array for the StatCA- contains all relevant details |
|
25 const char *badstatCA_array[]= |
|
26 { |
|
27 "X576", |
|
28 "TEst", |
|
29 "9b843cbfXXXXXXXXX5a87ce5f6da5ec", |
|
30 "", |
|
31 "!!!", |
|
32 "Junk" |
|
33 }; |
|
34 |
|
35 // Array for the Root5CA- contains all relevant details |
|
36 const char *badroot5CA_array[]= |
|
37 { |
|
38 "!@##", |
|
39 "T@$%$%Est", |
|
40 "@#$b843#%3cbfXXXXXXXXX5a87ce5f6da5ec", |
|
41 "", |
|
42 "!!!", |
|
43 "J&u$n%k" |
|
44 }; |
|
45 |
|
46 // Array for the SymbianTestDSACA- contains all relevant details |
|
47 const char *badsymbianTestDSACA_array[]= |
|
48 { |
|
49 "X576", |
|
50 "TEst", |
|
51 "9b843cbfXXXXXXXXX5a87ce5f6da5ec", |
|
52 "", |
|
53 "!!!", |
|
54 "J&u$n%k" |
|
55 }; |
|
56 |
|
57 // Array for the SymbianTestRSACA- contains all relevant details |
|
58 const char *badsymbianTestRSACA_array[]= |
|
59 { |
|
60 "X509", |
|
61 "ca", |
|
62 "7ac99da26d384fcf6ffd0578c4f50b549ffb2032", |
|
63 "", |
|
64 "584", |
|
65 "EFalse" |
|
66 }; |
|
67 |
|
68 // uids required for cacerts |
|
69 const char *bademu_cacertsUid[]= |
|
70 { |
|
71 "26QWERER23", |
|
72 "5555555555" |
|
73 }; |
|
74 |
|
75 //Capabilities required for stataca |
|
76 const char *aBadCapabilities_statca[]= |
|
77 { |
|
78 "TCB", |
|
79 "CommDD", |
|
80 "#&%^&%^&", |
|
81 "MultimediaDD", |
|
82 "ReadDeviceData", |
|
83 "WriteDeviceData", |
|
84 "DRM", |
|
85 "TrustedUI", |
|
86 "ProtServ", |
|
87 "@$%%#$%$#", |
|
88 "NetworkControl", |
|
89 "XXXXXXX", |
|
90 "SwEvent", |
|
91 "NetworkServices", |
|
92 "LocalServices", |
|
93 "ReadUserData", |
|
94 "#&%^&%^&", |
|
95 "Location", |
|
96 "SurroundingsDD", |
|
97 "UserEnvironment" |
|
98 }; |
|
99 |
|
100 |
|
101 //Capabilities required for root5ca |
|
102 const char *aBadCapabilities_root5ca[]= |
|
103 { |
|
104 "SurroundingsDD", |
|
105 "XXXXXXX", |
|
106 "WriteDeviceData", |
|
107 " ", |
|
108 "A#$2l%#4lF$%^iles" |
|
109 }; |
|
110 |
|
111 |
|
112 //Capabilities required for SymbianTestDSACA |
|
113 const char *aBadCapabilities_symbianTestDSACA[]= |
|
114 { |
|
115 "NetworkServices", |
|
116 " ", |
|
117 "%#^$$&$" |
|
118 }; |
|
119 |
|
120 //Capabilities required for SymbianTestRSACA |
|
121 const char *aBadCapabilities_symbianTestRSACA[]= |
|
122 { |
|
123 " ", |
|
124 "%#^$$&$" |
|
125 }; |
|
126 |
|
127 |
|
128 /** |
|
129 Bad store writer |
|
130 */ |
|
131 BadConfigWriter::BadConfigWriter(const std::stringstream &aFileName) |
|
132 { |
|
133 std::string name = aFileName.str(); |
|
134 iFile.open(name.c_str(), std::ios_base::trunc | std::ios_base::out); |
|
135 if(iFile.fail()) |
|
136 { |
|
137 std::cout << "Failed to open '" << name.c_str()<< "' for output!" << std::endl; |
|
138 exit(-1); |
|
139 } |
|
140 } |
|
141 |
|
142 BadConfigWriter::~BadConfigWriter() |
|
143 { |
|
144 iFile.close(); |
|
145 } |
|
146 |
|
147 /** |
|
148 Class definition for creating cacerts |
|
149 */ |
|
150 FileBadCertStoreConfigWriter::FileBadCertStoreConfigWriter(const std::stringstream &aFileName) |
|
151 : BadConfigWriter(aFileName), iEntryCount(0) |
|
152 { |
|
153 iFile << "StartCertStoreEntries" << std::endl; |
|
154 } |
|
155 |
|
156 FileBadCertStoreConfigWriter::~FileBadCertStoreConfigWriter() |
|
157 { |
|
158 iFile << "EndCertStoreEntries" << std::endl; |
|
159 } |
|
160 |
|
161 void FileBadCertStoreConfigWriter::WriteFileEntry(const char *aBadLabel, |
|
162 const char *aBadDeletable, |
|
163 const char *aBadFormat, |
|
164 const char *aBadCertOwnerType, |
|
165 const char *aBadSubjectKeyId, |
|
166 const char *aBadIssuerKeyId, |
|
167 const char *aBadApplication, |
|
168 const char *aBadTrusted, |
|
169 const char *aBadInvalidPath) |
|
170 { |
|
171 ++iEntryCount; |
|
172 // Setup default values |
|
173 std::stringstream certName; |
|
174 certName << "cert" << iEntryCount << ".der"; |
|
175 |
|
176 if(!aBadLabel) aBadLabel = "\"TestLabel\""; |
|
177 if(!aBadDeletable) aBadDeletable = "\"true\""; |
|
178 if(!aBadFormat) aBadFormat = "\"EX509Certificate\""; |
|
179 if(!aBadCertOwnerType) aBadCertOwnerType = "\"ECACertificate\""; |
|
180 if(!aBadSubjectKeyId) aBadSubjectKeyId = "auto"; |
|
181 if(!aBadIssuerKeyId) aBadIssuerKeyId = "auto"; |
|
182 if(!aBadTrusted) aBadTrusted = "\"true\""; |
|
183 if(!aBadInvalidPath) aBadInvalidPath = "cert0.der"; |
|
184 |
|
185 iFile << "\t# Entry " << iEntryCount << std::endl; |
|
186 iFile << "\tStartEntry " << aBadLabel << std::endl; |
|
187 iFile << "\t\tDeletable " << aBadDeletable << std::endl; |
|
188 iFile << "\t\tFormat " << aBadFormat << std::endl; |
|
189 iFile << "\t\tCertOwnerType " << aBadCertOwnerType << std::endl; |
|
190 iFile << "\t\tSubjectKeyId " << aBadSubjectKeyId << std::endl; |
|
191 iFile << "\t\tIssuerKeyId " << aBadIssuerKeyId << std::endl; |
|
192 iFile << "\t\tStartApplicationList" << std::endl; |
|
193 // write down the applications |
|
194 for(int i = 0; i<2; i++) |
|
195 { |
|
196 iFile << "\t\t\t# Entry " << i << std::endl; |
|
197 if(!aBadApplication) |
|
198 { |
|
199 iFile << "\t\t\t\tApplication " << appNames[i]<< std::endl; |
|
200 } |
|
201 else |
|
202 { |
|
203 iFile << "\t\t\t\tApplication " << badApplications[i]<< std::endl; |
|
204 } |
|
205 } |
|
206 |
|
207 iFile << "\t\tEndApplicationList" << std::endl; |
|
208 iFile << "\t\tTrusted " << aBadTrusted << std::endl; |
|
209 iFile << "\t\tDataFileName " << aBadInvalidPath << std::endl; |
|
210 iFile << "\tEndEntry " <<std::endl; |
|
211 iFile <<std::endl; |
|
212 } |
|
213 |
|
214 |
|
215 /** |
|
216 Class definition for generating certclient files |
|
217 */ |
|
218 FileBadCertClientConfigWriter::FileBadCertClientConfigWriter(const std::stringstream &aFileName) |
|
219 : BadConfigWriter(aFileName) |
|
220 { |
|
221 iFile << "StartClientInfo" << std::endl; |
|
222 } |
|
223 |
|
224 FileBadCertClientConfigWriter::~FileBadCertClientConfigWriter() |
|
225 { |
|
226 iFile << "EndClientInfo" << std::endl; |
|
227 } |
|
228 |
|
229 void FileBadCertClientConfigWriter::WriteCertClientName(const char *aBadAppName) |
|
230 { |
|
231 iFile << "\tName "<< aBadAppName << std::endl; |
|
232 |
|
233 } |
|
234 |
|
235 void FileBadCertClientConfigWriter::WriteCertClientUid(const char *aBadUid) |
|
236 { |
|
237 iFile << "\tUid "<< aBadUid << std::endl; |
|
238 } |
|
239 |
|
240 |
|
241 /** |
|
242 Swi certstore writer |
|
243 */ |
|
244 SwiBadCertStoreConfigWriter::SwiBadCertStoreConfigWriter(const std::stringstream &aFileName) |
|
245 : BadConfigWriter(aFileName), iEntryCount(0) |
|
246 { |
|
247 iFile <<"StartSwiCertStoreEntries" << std::endl; |
|
248 } |
|
249 |
|
250 SwiBadCertStoreConfigWriter::~SwiBadCertStoreConfigWriter() |
|
251 { |
|
252 iFile << "EndSwiCertStoreEntries" << std::endl; |
|
253 } |
|
254 |
|
255 void SwiBadCertStoreConfigWriter::WriteSwiEntry(const char *aBadLabel, |
|
256 const char *aBadFormat, |
|
257 const char *aBadCertOwnerType, |
|
258 const char *aBadSubjectKeyId, |
|
259 const char *aBadIssuerKeyId, |
|
260 const char *aBadApplication, |
|
261 const char *aBadTrusted, |
|
262 const char *aBadDatafilePath, |
|
263 const char *aBadCapabilitySets, |
|
264 const char *aBadMandatory, |
|
265 const char *aBadSystemUpgrade) |
|
266 { |
|
267 ++iEntryCount; |
|
268 |
|
269 if(!aBadLabel) aBadLabel = "TestLabel"; |
|
270 if(!aBadFormat) aBadFormat = "EX509Certificate"; |
|
271 if(!aBadCertOwnerType) aBadCertOwnerType = "ECACertificate"; |
|
272 if(!aBadSubjectKeyId) aBadSubjectKeyId = "auto"; |
|
273 if(!aBadIssuerKeyId) aBadIssuerKeyId = "auto"; |
|
274 if(!aBadTrusted) aBadTrusted = "\"true\""; |
|
275 if(!aBadDatafilePath) aBadDatafilePath = "\"swicertstore_cert0.der\""; |
|
276 if(!aBadMandatory) aBadMandatory = "\"true\""; |
|
277 if(!aBadSystemUpgrade) aBadSystemUpgrade = "\"true\""; |
|
278 |
|
279 iFile << "\t#Entry " << iEntryCount << std::endl; |
|
280 iFile << "\tStartEntry " << aBadLabel << std::endl; |
|
281 iFile << "\t\tFormat " << aBadFormat << std::endl; |
|
282 iFile << "\t\tCertOwnerType " << aBadCertOwnerType << std::endl; |
|
283 iFile << "\t\tSubjectKeyId " << aBadSubjectKeyId << std::endl; |
|
284 iFile << "\t\tIssuerKeyId " << aBadIssuerKeyId << std::endl; |
|
285 iFile << "\t\tStartApplicationList" << std::endl; |
|
286 //write application |
|
287 for(int k = 0; k<2; k++) |
|
288 { |
|
289 iFile << "\t\t\t# Entry " << k << std::endl; |
|
290 if(!aBadApplication) |
|
291 { |
|
292 iFile << "\t\t\t\tApplication " << appNames[k]<< std::endl; |
|
293 } |
|
294 else |
|
295 { |
|
296 iFile << "\t\t\t\tApplication " << badApplications[k]<< std::endl; |
|
297 } |
|
298 } |
|
299 iFile << "\t\tEndApplicationList" << std::endl; |
|
300 iFile << "\t\tTrusted " << aBadTrusted << std::endl; |
|
301 iFile << "\t\tDataFileName " << aBadDatafilePath << std::endl; |
|
302 iFile << "\t\tCapabilitySet " << "{ "; |
|
303 for(int i = 0; i< 5; i++) |
|
304 { |
|
305 if(!aBadCapabilitySets) |
|
306 { |
|
307 iFile << capabilitySets[i]; |
|
308 } |
|
309 else |
|
310 { |
|
311 iFile << badCapabilitySets[i]; |
|
312 } |
|
313 iFile <<" "; |
|
314 } |
|
315 |
|
316 iFile <<"}" <<std::endl; |
|
317 iFile << "\t\tMandatory " << aBadMandatory << std::endl; |
|
318 iFile << "\t\tSystemUpgrade " << aBadSystemUpgrade << std::endl; |
|
319 iFile << "\tEndEntry " <<std::endl; |
|
320 iFile <<std::endl; |
|
321 } |
|
322 |
|
323 // End of file |