forcedotcom/SalesforceMobileSDK-iOS — pull request #223 by khawkins (2013-02-07 00:32:51+00:00)
Title: Refactor to passcode provider, add PBKDF2 provider

This is the initial set of functionality for implementing passcode providers.

- Take a look at the new class `SFPasscodeProviderManager` static class. It does a couple of things:
- Defines the `SFPasscodeProvider` protocol, which sets the contract for the functionality that a passcode provider needs to implement.
- Implements the methods to manage the configuration of passcode providers.
- There are two implementations of SFPasscodeProvider at this point:
- `SFSHA256PasscodeProvider`, which is the implementation of the existing provider (essentially pulled in from `SFPasscodeManager`).
- `SFPBKDF2PasscodeProvider`, which implements a new provider, based on the PBKDF2 key derivation function approach to hashing keys. **Note:** There's no "automated" switch to this provider, yet. That will come in the next body of work.
- The `SFPasscodeProvider` protocol takes the same approach as the Android side, mandating a separate verification "key" and encryption "key". The encryption key is meant to live in memory, never persisted to storage.
- `SFPasscodeManager` now as before, is the arbiter of handling passcode verification, setting, resetting, etc. It just fronts the passcode provider manager now, which in turn fronts the management of the different providers.
- `SFCryptoUtils` is a new class that currently handles the creation of PBKDF2 data, based on inputs. the PBKDF2 provider uses this class, behind the scenes.
- Some notes about PBKDF2 data in the keychain:
- I pulled in the latest version of SalesforceCommonUtils, as it has updated keychain wrapper methods for getting and setting generic NSData objects in the keychain.
- `SFPBKDFData` is the new serializable class that holds information about a PBKDF key, which is stored wholesale in the keychain for verification passcodes, and all minus the derived key for the encryption passcode data.
- Tests have been added in the native project. SmartStore encryption tests have been updated to additionally consume the PBKDF2 provider as well.