My question is about key fobs in iOS (iPhone, iPad, ...). I think (but not sure) that implementing keychains under Mac OS X poses the same question with the same answer.
iOS provides five types (classes) of keychain elements. You must select one of these five values โโfor the kSecClass key to determine the type:
kSecClassGenericPassword used to store a generic password kSecClassInternetPassword used to store an internet password kSecClassCertificate used to store a certificate kSecClassKey used to store a kryptographic key kSecClassIdentity used to store an identity (certificate + private key)
After a long time reading apple documentation, blogs and forum posts, I found out that the keychain element of type kSecClassGenericPassword gets its uniqueness from the attributes kSecAttrAccessGroup , kSecAttrAccount and kSecAttrService .
If these three attributes in request 1 are the same as in request 2, you get the same common key password element, regardless of any other attributes. If one (or two or all) of these attributes changes its value, you get different elements.
But kSecAttrService is only available for elements of type kSecClassGenericPassword , so it cannot be part of the "unique key" of an element of any other type, and there seems to be no documentation that clearly indicates which attributes uniquely identify the keychain element.
The sample code in the "KeychainItemWrapper" class from "GenericKeychain" uses the kSecAttrGeneric attribute to make the element unique, but this is a mistake. Two entries in this example are saved only as two different entries because their kSecAttrAccessGroup is different (one has a group of access groups and the other is freed). If you try to add a second password without an access group using the Apple KeychainItemWrapper , you will fail.
So please answer my questions:
- Is it true that the combination of
kSecAttrAccessGroup , kSecAttrAccount and kSecAttrService is the "unique key" of the keychain element whose kSecClass is kSecClassGenericPassword ? - What attributes make a keychain element unique if its
kSecClass not kSecClassGenericPassword ?
ios objective-c keychain macos
Hubert Schรถlnast Jul 23 '12 at 14:00 2012-07-23 14:00
source share