Should we use TKSmartCardSlotManager for this?
It depends on what your actual goals are:
-
If you only want to sign or decrypt data using the digital identities stored on tokens, you don’t need to use CryptoTokenKit at all. You can find and use token-based digital identities using just Security framework APIs.
-
If you want to do more sophisticated things with smart cards, you can use CryptoTokenKit APIs for that purpose.
For example, I have a smart card signing test project where the vast bulk of the code is based on Security framework, but I use TKTokenWatcher
to learn about smart cards coming and going so that I can update my UI.
Do you think this is correct implementation?
It’s hard to offer a big-picture opinion without knowing what your specific goals are.
However, there’s one obvious small-picture problem: You’re using a Dispatch global concurrent queue. This is a bad idea in general — see Avoid Dispatch Global Concurrent Queues — but it’s particularly bad here because you’re permanently tying down one of Dispatch’s limited number of worker threads.
A better way to listen for changes in the token setup is with the TKTokenWatcher
class. And for smart cards specifically, you can use KVO to observe:
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"