Data Encryption with an OData Offline Store

By default, an OData Offline Store does not encrypt the data.

By default an OData offline store does not encrypt data. This may be fine for testing purpose or special use cases. However, prior to deployment, offline store encryption must be enabled to protect sensitive business or personal data. When the offline store is opened for the first time, an encryption key must be supplied to enable encryption through the class OfflineODataParameters. (SODataOfflineStoreOptions.storeEncryptionKey for iOS and ODataOfflineStoreOptions.storeEncryptionKey for Android). Once the offline store is encrypted, the encryption key cannot be recovered from the offline store itself and must be presented on subsequent opens. It is critical to securely store the key.

.SAP recommends that you enforce a mobile passcode to protect a mobile app from unauthorized access. The mobile passcode is used to derive an encryption key to secure a SecureKeyValueStore. The passcode is typically required during onboarding, subsequent application launches and returning to foreground. It is never stored and neither is the derived encryption key for the SecureKeyValueStore.

T The encryption key for the offline store can be stored securely in the SecureKeyValueStore. The requirement is that any time the offline store is opened, the SecureKeyValueStore must also be opened. Please refer to Foundation module documentation on SecureStore for more information.

Offline store is encrypted by an AES 256-bit cipher. The encryption key is used as an input to a password based key derivation function. The length and complexity of the encryption key is critical to ensure brute force guessing attack will not succeed.

Consider the following when creating a key:
  • Do not include semicolons in your key.
  • Do not put the key itself in quotes, or the quotes will be considered part of the key.
  • Lost or forgotten keys result in completely inaccessible stores.
// Initial open of offline store
// Generate a strong random password of at least 16 characters
String strongEncryptionKey = …;

// Assume that we have created and opened a secure key-value store when user enters passcode
appSecureKeyValueStore.put("OfflineStore1EncryptionKey", strongEncryptionKey);

On application relaunch, the offline store encryption key can be retrieved as follows:

// Assume that we have opened the secure key-value store as user enters passcode
String strongEncryptionKey = appSecureKeyValueStore.getString("OfflineStore1EncryptionKey");
…
offlineODataParameters.setStoreEncryptionKey(strongEncyrptionKey);
// open offline store