Apologies for the seeming obviousness of this question, but for whatever reason I haven't been able to find a definitive answer in the Apple documentation about where and how Settings.bundle password info is stored. My question: if I need to store some credentials for an app, and I use a Settings.bundle so that the password is entered into a PSTextFieldSpecifier textfield in Apple's Settings area with IsSecure = YES, and then I access the value from my app using CFPreferencesCopyAppValue, never writing it out to NSUserDefaults and only sending it over the network securely, how secure is that storage and retrieval method when compared to storing and retrieving the password using the keychain in my own app settings? Thanks for your input.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- gactions CLI crashes on Windows when uploading goo
- “Zero out” sensitive String data in Swift
相关文章
- Windows - Android SDK manager not listing any plat
- Warning : HTML 1300 Navigation occured?
- Could I create “Call” button in HTML 5 IPhone appl
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
Don't save a user's password in the settings bundle.
It isn't secure.
Remember, you don't need to know what the original password is, you need to know if the password the user enters matches the original password. The correct way to deal with passwords in iOS is to either
NSUserDefaults
Of these options, encrypting the password and storing the hash+salt is by far the easiest. Here's what you do to store the password:
NSUserDefaults
-- these values can't be used by hackers to determine the original password, so there is no need to store them in a secure place.Now, when the user enters their password and you have to verify if it's correct, here's what you do:
NSUserDefaults
NSUserDefaults
NSUSerDefaults
. If they are the same, then the user entered the correct password.Here's the code to generate the salt and the forward-only hash:
Code for this example was found here: http://blog.securemacprogramming.com/2011/04/storing-and-testing-credentials-cocoa-touch-edition/
Keychain on the iPhone is going to be the most secure, unless you're using custom encryption, which is very difficult to do (and export). NSUserDefaults isn't considered secure.
CFPreferencesCopyAppValue
is just the Core Foundation way of accessing the same information you get when usingNSUserDefaults
. In terms of security, the features are exactly the same. That is, it's not encrypted. It's secure only in the sense that it's obscured. The "correct" answer is to use the keychain.The counter to that is that many applications use
NSUserDefaults
to store passwords. You could argue that unless the password controls access to information of any value then it's not worth the effort in trying to use the keychain. Which brings me to the second argument in favour of using a secure field in the Settings application: the keychain API is hideous and, in my experience at least, writing error-free code is tricky.