The manual page for /usr/bin/security
on OS X 10.9 indicates that there is a -x
option for security import
to specify that private keys are non-extractable after being imported
.
How is this implemented? Are the private keys imported through such means really become completely non-extractable, or is there still a way to get a hold of them through some kind of memory dump? How do applications still use such keys for their crypto?
I'm not sure how the applications still use such keys, but as per https://reverseengineering.stackexchange.com/questions/6043/extract-non-extractable-private-key-from-os-x-keychain, it appears that this is simply implemented as a bit attribute for CSSM_KEYATTR_FLAGS keyAttributes
of struct SecKeyImportExportParameters
named CSSM_KEYATTR_EXTRACTABLE
.
As per the above, when the import is done, this attribute is specifically omitted when the -x
option is specified to security import
.
According to SecItem.h, this kSecAttrIsExtractable
has been introduced with OS X 10.6.
Subsequently, when trying to do a wrapped export, several places within the Security framework appear to check to make sure that this CSSM_KEYATTR_EXTRACTABLE
bit is set prior to doing any kind of export, and return an error in case the attribute is not set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With