]> git.saurik.com Git - apple/security.git/blob - OSX/sec/Security/Regressions/secitem/si-73-secpasswordgenerate.c
Security-57336.10.29.tar.gz
[apple/security.git] / OSX / sec / Security / Regressions / secitem / si-73-secpasswordgenerate.c
1 //
2 // si-73-secpasswordgenerate.c
3 // sec
4 //
5
6 #include <stdio.h>
7 #include <Security/SecPasswordGenerate.h>
8 #include <utilities/SecCFRelease.h>
9 #include "Security_regressions.h"
10
11 static void tests(void)
12 {
13 CFErrorRef error = NULL;
14 CFStringRef password = NULL;
15 CFMutableArrayRef requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
16 CFMutableDictionaryRef passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
17
18 //generates random digit string
19 is(true, (password = SecPasswordCreateWithRandomDigits(8, &error)) != NULL) ;
20 CFReleaseNull(password);
21
22 is(true, (password = SecPasswordCreateWithRandomDigits(7, &error)) != NULL) ;
23 CFReleaseNull(password);
24
25 is(true, (password = SecPasswordCreateWithRandomDigits(6, &error)) != NULL) ;
26 CFReleaseNull(password);
27
28 is(true, (password = SecPasswordCreateWithRandomDigits(5, &error)) != NULL) ;
29 CFReleaseNull(password);
30
31 CFCharacterSetRef uppercaseLetterCharacterSet = CFCharacterSetGetPredefined(kCFCharacterSetUppercaseLetter);
32 CFCharacterSetRef lowercaseLetterCharacterSet = CFCharacterSetGetPredefined(kCFCharacterSetLowercaseLetter);
33 CFCharacterSetRef decimalDigitCharacterSet = CFCharacterSetGetPredefined(kCFCharacterSetDecimalDigit);
34
35 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
36 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
37 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
38
39 CFDictionaryAddValue(passwordRequirements, kSecPasswordDefaultForType, CFSTR("true"));
40
41 //test default PIN
42 password = SecPasswordGenerate(kSecPasswordTypePIN, &error, passwordRequirements);
43 isnt(password, NULL);
44 ok(error == NULL);
45 CFReleaseNull(password);
46 error = NULL;
47
48 //test default icloud recovery code
49 password = SecPasswordGenerate(kSecPasswordTypeiCloudRecovery, &error, passwordRequirements);
50 isnt(password, NULL);
51 ok(error == NULL);
52 CFReleaseNull(password);
53 error = NULL;
54
55 //test default wifi
56 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
57 CFDictionaryAddValue(passwordRequirements, kSecPasswordDefaultForType, CFSTR("true"));
58 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
59 isnt(password, NULL);
60 ok(error == NULL);
61 CFReleaseNull(password);
62 error = NULL;
63 CFRelease(passwordRequirements);
64
65 //test default safari
66 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
67 CFDictionaryAddValue(passwordRequirements, kSecPasswordDefaultForType, CFSTR("true"));
68 password = SecPasswordGenerate(kSecPasswordTypeSafari, &error, passwordRequirements);
69 isnt(password, NULL);
70 ok(error == NULL);
71
72 error = NULL;
73 CFReleaseNull(password);
74 CFRelease(passwordRequirements);
75
76 //test icloud recovery code generation
77 password = SecPasswordGenerate(kSecPasswordTypeiCloudRecovery, &error, NULL);
78 isnt(password, NULL);
79 ok(error == NULL);
80
81 error = NULL;
82 CFReleaseNull(password);
83
84 //dictionary setup
85 int min = 20;
86 int max = 32;
87
88 CFNumberRef minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
89 CFNumberRef maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
90
91 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
92 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
93 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
94 CFStringRef allowedCharacters = CFSTR("abcdsefw2345");
95
96 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
97 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
98
99 //test wifi code generation
100 //test with min/max in range of default
101 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
102 isnt(password, NULL);
103 ok(error == NULL);
104
105 error = NULL;
106 CFReleaseNull(password);
107 CFRelease(passwordRequirements);
108 CFRelease(minRef);
109 CFRelease(maxRef);
110 CFRelease(allowedCharacters);
111
112
113 //test with max == min
114 min = 24;
115 max = 24;
116
117 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
118 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
119
120 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
121 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
122 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
123 allowedCharacters = CFSTR("abcdsefw2345");
124
125 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
126 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
127 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
128 isnt(password, NULL);
129 ok(error == NULL);
130
131 error = NULL;
132 CFReleaseNull(password);
133 CFRelease(passwordRequirements);
134 CFRelease(minRef);
135 CFRelease(maxRef);
136 CFRelease(allowedCharacters);
137
138 passwordRequirements = NULL;
139
140 //test disallowed characters
141 min = 24;
142 max = 56;
143
144 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
145 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
146
147 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
148 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
149 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
150 allowedCharacters = CFSTR("abcdefghijklmnopqrstuvwxyz0123456789");
151
152 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
153 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
154 CFDictionaryAddValue(passwordRequirements, kSecPasswordDisallowedCharacters, CFSTR("aidfl"));
155
156 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
157 isnt(password, NULL);
158 ok(error == NULL);
159
160 error = NULL;
161 CFReleaseNull(password);
162 CFRelease(passwordRequirements);
163 CFRelease(minRef);
164 CFRelease(maxRef);
165 CFRelease(allowedCharacters);
166 passwordRequirements = NULL;
167
168 //test can't start with characters
169 min = 24;
170 max = 56;
171
172 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
173 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
174
175 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
176 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
177 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
178 allowedCharacters = CFSTR("diujk");
179
180 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
181 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
182 CFDictionaryAddValue(passwordRequirements, kSecPasswordCantStartWithChars, CFSTR("d"));
183
184 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
185 isnt(password, NULL);
186 ok(error == NULL);
187
188 error = NULL;
189 CFReleaseNull(password);
190 CFRelease(passwordRequirements);
191 CFRelease(minRef);
192 CFRelease(maxRef);
193 CFRelease(allowedCharacters);
194 passwordRequirements = NULL;
195
196
197 //test can't end with characters
198 min = 24;
199 max = 56;
200
201 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
202 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
203
204 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
205 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
206 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
207 allowedCharacters = CFSTR("diujk89");
208
209 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
210 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
211 CFDictionaryAddValue(passwordRequirements, kSecPasswordCantEndWithChars, CFSTR("d"));
212
213 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
214 isnt(password, NULL);
215 ok(error == NULL);
216
217 error = NULL;
218 CFReleaseNull(password);
219 CFRelease(passwordRequirements);
220 CFRelease(minRef);
221 CFRelease(maxRef);
222 CFRelease(allowedCharacters);
223 passwordRequirements = NULL;
224
225
226 //test 4 digit pin generation
227 for(int i =0 ; i< 100; i++){
228 password = SecPasswordGenerate(kSecPasswordTypePIN, &error, passwordRequirements);
229 isnt(password, NULL);
230 ok(error == NULL);
231
232 error = NULL;
233 CFReleaseNull(password);
234 }
235
236 //test 6 digit pin
237 min = 4;
238 max = 6;
239
240 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
241 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
242
243 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
244 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
245 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
246 password = SecPasswordGenerate(kSecPasswordTypePIN, &error, passwordRequirements);
247 isnt(password, NULL);
248 ok(error == NULL);
249
250 error = NULL;
251 CFReleaseNull(password);
252 CFRelease(minRef);
253 CFRelease(maxRef);
254 CFRelease(passwordRequirements);
255
256 //test 5 digit pin
257 min = 4;
258 max = 5;
259
260 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
261 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
262
263 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
264 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
265 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
266 password = SecPasswordGenerate(kSecPasswordTypePIN, &error, passwordRequirements);
267 isnt(password, NULL);
268 ok(error == NULL);
269
270 error = NULL;
271 CFReleaseNull(password);
272 CFRelease(minRef);
273 CFRelease(maxRef);
274 CFRelease(passwordRequirements);
275 //test safari password
276 min = 20;
277 max = 32;
278
279 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
280 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
281
282 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
283 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
284 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
285 allowedCharacters = CFSTR("abcdsefw2345");
286 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
287 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
288 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
289 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
290
291 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
292 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
293
294 password = SecPasswordGenerate(kSecPasswordTypeSafari, &error, passwordRequirements);
295 isnt(password, NULL);
296 ok(error == NULL);
297
298 error = NULL;
299 CFReleaseNull(password);
300 CFRelease(passwordRequirements);
301 CFRelease(minRef);
302 CFRelease(maxRef);
303 CFRelease(allowedCharacters);
304 CFRelease(requiredCharacterSets);
305
306 //test flexible group size and number of groups in the password
307 //test safari password
308 min = 12;
309 max = 19;
310 int groupSize = 5;
311 int numberOfGroups = 23;
312
313 CFTypeRef groupSizeRef = CFNumberCreate(NULL, kCFNumberIntType, &groupSize);
314 CFTypeRef numberOfGroupsRef = CFNumberCreate(NULL, kCFNumberIntType, &numberOfGroups);
315
316 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
317 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
318
319 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
320 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
321 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
322 allowedCharacters = CFSTR("abcdsefw2345");
323 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
324 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
325 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
326 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
327
328 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
329 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
330 CFDictionaryAddValue(passwordRequirements, kSecPasswordGroupSize, groupSizeRef);
331 CFDictionaryAddValue(passwordRequirements, kSecPasswordNumberOfGroups, numberOfGroupsRef);
332 CFDictionaryAddValue(passwordRequirements, kSecPasswordSeparator, CFSTR("*"));
333
334 password = SecPasswordGenerate(kSecPasswordTypeSafari, &error, passwordRequirements);
335 isnt(password, NULL);
336 ok(error == NULL);
337
338 error = NULL;
339 CFReleaseNull(password);
340 CFRelease(passwordRequirements);
341 CFRelease(minRef);
342 CFRelease(maxRef);
343 CFRelease(allowedCharacters);
344 CFRelease(requiredCharacterSets);
345
346 //test at least N characters
347 //test safari password
348 min = 24;
349 max = 32;
350 int N = 5;
351
352 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
353 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
354 CFNumberRef threshold = CFNumberCreate(NULL, kCFNumberIntType, &N);
355
356 CFStringRef characters = CFSTR("ab");
357 CFMutableDictionaryRef atLeast = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
358 CFDictionaryAddValue(atLeast, kSecPasswordCharacters, characters);
359 CFDictionaryAddValue(atLeast, kSecPasswordCharacterCount, threshold);
360
361 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
362 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
363 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
364 allowedCharacters = CFSTR("abcdsefw2345");
365 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
366 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
367 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
368 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
369
370 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
371 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
372 CFDictionaryAddValue(passwordRequirements, kSecPasswordContainsAtLeastNSpecificCharacters, atLeast);
373
374 password = SecPasswordGenerate(kSecPasswordTypeSafari, &error, passwordRequirements);
375 isnt(password, NULL);
376 ok(error == NULL);
377
378 error = NULL;
379 CFReleaseNull(password);
380 CFRelease(passwordRequirements);
381 CFRelease(minRef);
382 CFRelease(maxRef);
383 CFRelease(allowedCharacters);
384 CFRelease(requiredCharacterSets);
385
386 //test no More than N characters
387 //test safari password
388 min = 24;
389 max = 32;
390 N = 5;
391
392
393 threshold = CFNumberCreate(NULL, kCFNumberIntType, &N);
394 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
395 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
396
397 CFMutableDictionaryRef noMoreThan = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
398 CFStringRef noMore = CFSTR("ab");
399 CFDictionaryAddValue(noMoreThan, kSecPasswordCharacters, noMore);
400 CFDictionaryAddValue(noMoreThan, kSecPasswordCharacterCount, threshold);
401
402 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
403 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
404 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
405 allowedCharacters = CFSTR("abcdsefw2345");
406 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
407 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
408 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
409 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
410
411 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
412 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
413 CFDictionaryAddValue(passwordRequirements, kSecPasswordContainsNoMoreThanNSpecificCharacters, noMoreThan);
414
415 password = SecPasswordGenerate(kSecPasswordTypeSafari, &error, passwordRequirements);
416 isnt(password, NULL);
417 ok(error == NULL);
418
419 error = NULL;
420 CFReleaseNull(password);
421 CFRelease(passwordRequirements);
422 CFRelease(minRef);
423 CFRelease(maxRef);
424 CFRelease(allowedCharacters);
425 CFRelease(requiredCharacterSets);
426
427 //test identical character threshold
428 //test safari password
429 min = 12;
430 max = 19;
431 N = 2;
432
433 threshold = CFNumberCreate(NULL, kCFNumberIntType, &N);
434 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
435 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
436
437 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
438 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
439 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
440 allowedCharacters = CFSTR("abcdsefw2345");
441 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
442 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
443 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
444 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
445
446 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
447 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
448 CFDictionaryAddValue(passwordRequirements, kSecPasswordContainsNoMoreThanNConsecutiveIdenticalCharacters, threshold);
449
450 password = SecPasswordGenerate(kSecPasswordTypeSafari, &error, passwordRequirements);
451 isnt(password, NULL);
452 ok(error == NULL);
453
454 error = NULL;
455 CFReleaseNull(password);
456 CFRelease(passwordRequirements);
457 CFRelease(minRef);
458 CFRelease(maxRef);
459 CFRelease(allowedCharacters);
460 CFRelease(requiredCharacterSets);
461
462 /////////////////now test all the error cases
463 //test with no required characters
464
465 min = 24;
466 max = 32;
467
468 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
469 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
470 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
471
472 allowedCharacters = CFSTR("abcdsefw2345");
473 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
474
475 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
476 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
477 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
478 ok(password == NULL);
479 ok(error != NULL);
480
481 CFRelease(error);
482 error = NULL;
483 CFRelease(minRef);
484 CFRelease(maxRef);
485 CFRelease(allowedCharacters);
486 CFRelease(passwordRequirements);
487
488 //test with no allowed characters
489 min = 24;
490 max = 32;
491
492 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
493 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
494
495 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
496 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
497 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
498 allowedCharacters = CFSTR("");
499
500 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
501 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
502 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
503 ok(password == NULL);
504 ok(error != NULL);
505
506 CFRelease(error);
507 error = NULL;
508 CFRelease(minRef);
509 CFRelease(maxRef);
510 CFRelease(passwordRequirements);
511
512 //test with min > max
513 min = 32;
514 max = 20;
515
516 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
517 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
518
519 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
520
521 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
522 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
523 allowedCharacters = CFSTR("abcdsefw2345");
524
525 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
526 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
527 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
528 ok(password == NULL);
529 ok(error != NULL);
530
531 error = NULL;
532 CFRelease(minRef);
533 CFRelease(maxRef);
534 CFRelease(allowedCharacters);
535 CFRelease(passwordRequirements);
536
537 //test by ommitting dictionary parameters
538
539 //omit max length
540 min = 20;
541 max = 32;
542
543 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
544 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
545
546 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
547
548 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
549 allowedCharacters = CFSTR("abcdsefw2345");
550
551 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
552 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
553 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
554 ok(password == NULL);
555 ok(error != NULL);
556
557 error = NULL;
558 CFRelease(minRef);
559 CFRelease(maxRef);
560 CFRelease(allowedCharacters);
561 CFRelease(passwordRequirements);
562
563 //omit min length
564 min = 20;
565 max = 32;
566
567 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
568 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
569
570 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
571
572 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
573 allowedCharacters = CFSTR("abcdsefw2345");
574
575 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
576 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
577 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
578 ok(password == NULL);
579 ok(error != NULL);
580
581 error = NULL;
582 CFRelease(minRef);
583 CFRelease(maxRef);
584 CFRelease(allowedCharacters);
585 CFRelease(passwordRequirements);
586
587 //omit allowed characters
588 min = 20;
589 max = 32;
590
591 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
592 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
593
594 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
595
596 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
597 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
598 allowedCharacters = CFSTR("abcdsefw2345");
599
600 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
601 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
602 ok(password == NULL);
603 ok(error != NULL);
604
605 error = NULL;
606 CFRelease(minRef);
607 CFRelease(maxRef);
608 CFRelease(allowedCharacters);
609 CFRelease(passwordRequirements);
610
611 //omit required characters
612 min = 20;
613 max = 32;
614
615 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
616 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
617
618 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
619
620 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
621 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
622 allowedCharacters = CFSTR("abcdsefw2345");
623
624 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
625 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
626 ok(password == NULL);
627 ok(error != NULL);
628
629 error = NULL;
630 CFRelease(minRef);
631 CFRelease(maxRef);
632 CFRelease(allowedCharacters);
633 CFRelease(passwordRequirements);
634
635 //pass in wrong type for min
636 min = 20;
637 max = 32;
638
639 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
640 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
641
642 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
643
644 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, allowedCharacters);
645 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
646 allowedCharacters = CFSTR("abcdsefw2345");
647 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
648 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
649 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
650 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
651
652 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
653 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
654
655 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
656 ok(password == NULL);
657 ok(error != NULL);
658
659 error = NULL;
660 CFRelease(passwordRequirements);
661 CFRelease(minRef);
662 CFRelease(maxRef);
663 CFRelease(allowedCharacters);
664
665 //pass in wrong type for max
666 min = 20;
667 max = 32;
668
669 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
670 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
671
672 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
673
674 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
675 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, allowedCharacters);
676 allowedCharacters = CFSTR("abcdsefw2345");
677
678 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
679 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
680
681 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
682 ok(password == NULL);
683 ok(error != NULL);
684
685 error = NULL;
686 CFRelease(passwordRequirements);
687 CFRelease(minRef);
688 CFRelease(maxRef);
689 CFRelease(allowedCharacters);
690
691 //pass in wrong type for allowed
692 min = 20;
693 max = 32;
694
695 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
696 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
697
698 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
699
700 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
701 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
702 allowedCharacters = CFSTR("abcdsefw2345");
703
704 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, minRef);
705 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
706
707 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
708 ok(password == NULL);
709 ok(error != NULL);
710
711 error = NULL;
712 CFRelease(passwordRequirements);
713 CFRelease(minRef);
714 CFRelease(maxRef);
715 CFRelease(allowedCharacters);
716
717 //pass in wrong type for required
718 min = 20;
719 max = 32;
720
721 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
722 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
723
724 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
725
726 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
727 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
728 allowedCharacters = CFSTR("abcdsefw2345");
729
730 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
731 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, minRef);
732 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
733 ok(password == NULL);
734 ok(error != NULL);
735
736 error = NULL;
737 CFRelease(passwordRequirements);
738 CFRelease(minRef);
739 CFRelease(maxRef);
740 CFRelease(allowedCharacters);
741
742 //pass in wrong type for no less than
743 min = 20;
744 max = 32;
745
746 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
747 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
748
749 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
750 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
751 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
752 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
753 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
754
755 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
756 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
757 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
758 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
759 allowedCharacters = CFSTR("abcdsefw2345");
760
761 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
762 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, minRef);
763 CFDictionaryAddValue(passwordRequirements, kSecPasswordContainsAtLeastNSpecificCharacters, CFSTR("hehe"));
764 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
765 ok(password == NULL);
766 ok(error != NULL);
767
768 error = NULL;
769 CFRelease(passwordRequirements);
770 CFRelease(minRef);
771 CFRelease(maxRef);
772 CFRelease(allowedCharacters);
773
774 //pass in wrong type for no more than
775 min = 20;
776 max = 32;
777
778 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
779 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
780
781 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
782 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
783 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
784 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
785 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
786
787 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
788 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
789 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
790 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
791 allowedCharacters = CFSTR("abcdsefw2345");
792
793 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
794 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, minRef);
795 CFDictionaryAddValue(passwordRequirements, kSecPasswordContainsNoMoreThanNSpecificCharacters, CFSTR("hehe"));
796
797 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
798 ok(password == NULL);
799 ok(error != NULL);
800
801 error = NULL;
802 CFRelease(passwordRequirements);
803 CFRelease(minRef);
804 CFRelease(maxRef);
805 CFRelease(allowedCharacters);
806
807 //pass in wrong disallowed characters
808 min = 20;
809 max = 32;
810
811 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
812 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
813
814 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
815 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
816 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
817 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
818 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
819
820 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
821 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
822 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
823 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
824 allowedCharacters = CFSTR("abcdsefw2345");
825
826 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
827 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, minRef);
828 CFDictionaryAddValue(passwordRequirements, kSecPasswordDisallowedCharacters, requiredCharacterSets);
829
830 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
831 ok(password == NULL);
832 ok(error != NULL);
833
834 error = NULL;
835 CFRelease(passwordRequirements);
836 CFRelease(minRef);
837 CFRelease(maxRef);
838 CFRelease(allowedCharacters);
839
840 //pass in wrong type for no more than's dictionary
841 min = 20;
842 max = 32;
843
844 minRef = CFNumberCreate(NULL, kCFNumberIntType, &min);
845 maxRef = CFNumberCreate(NULL, kCFNumberIntType, &max);
846
847 CFMutableDictionaryRef wrongCount = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
848 CFDictionaryAddValue(wrongCount, kSecPasswordCharacters, CFSTR("lkj"));
849 CFDictionaryAddValue(wrongCount, kSecPasswordCharacterCount, CFSTR("sdf"));
850
851 passwordRequirements = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
852 requiredCharacterSets = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
853 CFArrayAppendValue(requiredCharacterSets, uppercaseLetterCharacterSet);
854 CFArrayAppendValue(requiredCharacterSets, lowercaseLetterCharacterSet);
855 CFArrayAppendValue(requiredCharacterSets, decimalDigitCharacterSet);
856
857 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
858 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, requiredCharacterSets);
859 CFDictionaryAddValue(passwordRequirements, kSecPasswordMinLengthKey, minRef);
860 CFDictionaryAddValue(passwordRequirements, kSecPasswordMaxLengthKey, maxRef);
861 allowedCharacters = CFSTR("abcdsefw2345");
862
863 CFDictionaryAddValue(passwordRequirements, kSecPasswordAllowedCharactersKey, allowedCharacters);
864 CFDictionaryAddValue(passwordRequirements, kSecPasswordRequiredCharactersKey, minRef);
865 CFDictionaryAddValue(passwordRequirements, kSecPasswordContainsNoMoreThanNSpecificCharacters, wrongCount);
866
867 password = SecPasswordGenerate(kSecPasswordTypeWifi, &error, passwordRequirements);
868 ok(password == NULL);
869 ok(error != NULL);
870
871 error = NULL;
872 CFRelease(wrongCount);
873 CFRelease(passwordRequirements);
874 CFRelease(minRef);
875 CFRelease(maxRef);
876 CFRelease(allowedCharacters);
877
878 password = CFSTR("Apple1?");
879 isnt(true, SecPasswordIsPasswordWeak(password));
880 CFRelease(password);
881
882 password = CFSTR("Singhal190");
883 isnt(true, SecPasswordIsPasswordWeak(password));
884 CFRelease(password);
885
886 password = CFSTR("1Hollow2");
887 isnt(true, SecPasswordIsPasswordWeak(password));
888 CFRelease(password);
889
890 password = CFSTR("1Hollow/");
891 isnt(true, SecPasswordIsPasswordWeak(password));
892 CFRelease(password);
893
894 password = CFSTR("baj/paj1");
895 isnt(true, SecPasswordIsPasswordWeak(password));
896 CFRelease(password);
897
898 password = CFSTR("Zaxs1009?");
899 isnt(true, SecPasswordIsPasswordWeak(password));
900 CFRelease(password);
901
902 password = CFSTR("6666");
903 isnt(false, SecPasswordIsPasswordWeak(password));
904 CFRelease(password);
905
906 password = CFSTR("123456");
907 isnt(false, SecPasswordIsPasswordWeak(password));
908 CFRelease(password);
909
910 password = CFSTR("654321");
911 isnt(false, SecPasswordIsPasswordWeak(password));
912 CFRelease(password);
913
914 password = CFSTR("A");
915 isnt(false, SecPasswordIsPasswordWeak(password));
916 CFRelease(password);
917
918 password = CFSTR("password");
919 isnt(true, SecPasswordIsPasswordWeak(password));
920 CFRelease(password);
921
922 password = CFSTR("password1");
923 isnt(true, SecPasswordIsPasswordWeak(password));
924 CFRelease(password);
925
926 password = CFSTR("P@ssw0rd");
927 isnt(true, SecPasswordIsPasswordWeak(password));
928 CFRelease(password);
929
930 password = CFSTR("facebook!{}");
931 isnt(true, SecPasswordIsPasswordWeak(password));
932 CFRelease(password);
933
934 password = CFSTR("12345678");
935 isnt(false, SecPasswordIsPasswordWeak(password));
936 CFRelease(password);
937
938 bool isSimple = false;
939
940 password = CFSTR("Apple1?");
941 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
942 CFRelease(password);
943
944 password = CFSTR("Singhal190");
945 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
946 CFRelease(password);
947
948 password = CFSTR("1Hollow2");
949 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
950 CFRelease(password);
951
952 password = CFSTR("1Hollow/");
953 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
954 CFRelease(password);
955
956 password = CFSTR("baj/paj1");
957 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
958 CFRelease(password);
959
960 password = CFSTR("Zaxs1009?");
961 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
962 CFRelease(password);
963
964 password = CFSTR("6666");
965 is(true, SecPasswordIsPasswordWeak2(isSimple, password));
966 CFRelease(password);
967
968 password = CFSTR("1235");
969 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
970 CFRelease(password);
971
972 isSimple = true;
973 password = CFSTR("6666");
974 is(true, SecPasswordIsPasswordWeak2(isSimple, password));
975 CFRelease(password);
976
977 password = CFSTR("1235");
978 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
979 CFRelease(password);
980
981 isSimple = false;
982 password = CFSTR("123456");
983 is(true, SecPasswordIsPasswordWeak2(isSimple, password));
984 CFRelease(password);
985
986 password = CFSTR("654321");
987 is(true, SecPasswordIsPasswordWeak2(isSimple, password));
988 CFRelease(password);
989
990 password = CFSTR("1577326");
991 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
992 CFRelease(password);
993
994 password = CFSTR("A");
995 is(true, SecPasswordIsPasswordWeak2(isSimple, password));
996 CFRelease(password);
997
998 password = CFSTR("password");
999 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
1000 CFRelease(password);
1001
1002 password = CFSTR("password1");
1003 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
1004 CFRelease(password);
1005
1006 password = CFSTR("P@ssw0rd");
1007 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
1008 CFRelease(password);
1009
1010 password = CFSTR("facebook!{}");
1011 is(false, SecPasswordIsPasswordWeak2(isSimple, password));
1012 CFRelease(password);
1013
1014 password = CFSTR("12345678");
1015 is(true, SecPasswordIsPasswordWeak2(isSimple, password));
1016 CFRelease(password);
1017
1018 is(true, SecPasswordIsPasswordWeak2(true, CFSTR("666666")));
1019 is(true, SecPasswordIsPasswordWeak2(true, CFSTR("123456")));
1020 is(false, SecPasswordIsPasswordWeak2(true, CFSTR("666166")));
1021
1022 }
1023
1024 int si_73_secpasswordgenerate(int argc, char *const *argv)
1025 {
1026 plan_tests(305);
1027 tests();
1028
1029 return 0;
1030 }