Who doesn’t remember the date and time they first used a password?

Array

A few weeks ago a user of my Keychain framework noted that searches by creation or modification date just didn’t work. So I started digging around, and came to the conclusion eventually that the Security framework was playing funny buggers. Long story short, after a short thread on apple-cdsa Ken McLeod was able to confirm that the relevant functions were particular choosy when it came to their date formats… rather than use any of the standard date formats, they wanted curious old legacy things from the Classic MacOS days – dates expressed as seconds since January 1st, 1904. ‘course, as luck would have it, none of the NSDate/CFDate/etc stuff can trivially yield such a value. Ken was nice enough, though, to post some category methods in his reply that did all the dirty work for us. The end result being:

Testing: KeychainSearch by account.
Able to obtain results from blanket search (i.e. list) – passed.
Have at least one result – passed.
Randomly chose element at index 302
Item is: scs.msg.yahoo.com: wadetregaskis @ unknown://scs.msg.yahoo.com:443
Item’s account is: wadetregaskis
Able to refine search – passed.
There is at least one result from refined search – passed.
All results have the expected value – passed.
All expected results were returned – passed.
Testing: KeychainSearch.
Able to obtain results from blanket search (i.e. list) – passed.
Have at least one result – passed.
Randomly chose element at index 322
Item is: STANGG: WADETREGASKIS @ unknown://STANGG:139
Item’s creation date is: 2006-04-02 08:49:01 +1000 (1143931741.000000)
Able to refine search based on creation date – passed.
There is at least one result from refined search – passed.
All results have the expected creation date – passed.
All expected results were returned – passed.

Sweet. Now I just have to complete this test driver with tests of the other twenty or so different types of attributes… d’oh. 🙂

And of course, how useful these searches (creation & modification date) are, given they are exact matches with a resolution of seconds, remains to be seen. Still… no sense letting practicality get in the way of good code. 😉

Leave a Reply