Hi everyone,
I’ve been working on storing keys and passwords in the macOS Keychain using the Keychain Services API. Specifically, I’m leveraging SecAccessControlCreateWithFlags to bind items to access control flags, and overall, it’s been working smoothly.
I have a question regarding the .applicationPassword flag of SecAccessControlCreateWithFlags. While it successfully prompts the user to input a password, there are no apparent password rules, even a simple “1” is accepted.
My questions are:
- Is there a way to enforce strong password requirements when using the .applicationPassword flag?
- If enforcing strong passwords isn’t possible, is there an alternative approach to provide a predefined strong password during the creation process, bypassing the need for user input?
- With SecAccessControlCreateWithFlags, I noticed the item isn’t stored in the traditional file-based Keychain but in an iOS-style Keychain, is there a way to store it in a file-based Keychain while marking it as unexportable?
I appreciate any insights or suggestions. Thank you!
Neil
There is not.
I think that’d made a fine enhancement request.
If you do file an ER, please post your bug number, just for the record.
No.
But I suspect I’m missing something here. Let’s say you could do this, what would the workflow look like? Would you expect the user to remember this high-complexity password? That seems rather… well… brittle.
Correct. This is officially known as the data protection keychain. I recommend that you read TN3137 On Mac keychain APIs and implementations, which explains the backstory here.
No. The data protection keychain uses a completely different access control mechanism than the file-based keychain, and SecAccessControl
is part of that data protection keychain model.
But, again, I suspect I’m missing some part of the big picture. What do you mean by “unexportable” here?
The file based keychain does support private keys where you can’t export the raw key bits, but that’s under a different name (extractable). And it only applies to keys, not passwords.
If you can explain more about your overall security goals, I may be able to offer better advice.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"