diff options
author | Christopher Tate <ctate@google.com> | 2011-07-19 16:32:49 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2011-07-28 16:01:20 -0700 |
commit | 2efd2dbbac9eac89620683696c6076463c3a1cd6 (patch) | |
tree | ca48adf4208daee43a4444a0fdb61fcb939858c5 /packages/SettingsProvider | |
parent | b7d95a46dfacf04896d5b084f13bcbe6eab33633 (diff) | |
download | frameworks_base-2efd2dbbac9eac89620683696c6076463c3a1cd6.zip frameworks_base-2efd2dbbac9eac89620683696c6076463c3a1cd6.tar.gz frameworks_base-2efd2dbbac9eac89620683696c6076463c3a1cd6.tar.bz2 |
Support full-backup encryption and global backup password
If the user has supplied a backup password in Settings, that password
is validated during the full backup process and is used as an encryption
key for encoding the backed-up data itself. This is the fundamental
mechanism whereby users can secure their data even against malicious
parties getting physical unlocked access to their device.
Technically the user-supplied password is not used as the encryption
key for the backed-up data itself. What is actually done is that a
random key is generated to use as the raw encryption key. THAT key,
in turn, is encrypted with the user-supplied password (after random
salting and key expansion with PBKDF2). The encrypted master key
and a checksum are stored in the backup header. At restore time,
the user supplies their password, which allows the system to decrypt
the master key, which in turn allows the decryption of the backup
data itself.
The checksum is part of the archive in order to permit validation
of the user-supplied password. The checksum is the result of running
the user-supplied password through PBKDF2 with a randomly selected
salt. At restore time, the proposed password is run through PBKDF2
with the salt described by the archive header. If the result does
not match the archive's stated checksum, then the user has supplied
the wrong decryption password.
Also, suppress backup consideration for a few packages whose
data is either nonexistent or inapplicable across devices or
factory reset operations.
Bug 4901637
Change-Id: Id0cc9d0fdfc046602b129f273d48e23b7a14df36
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java index 3a7a6e1..4f39e69 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java @@ -201,16 +201,22 @@ public class SettingsBackupAgent extends BackupAgentHelper { BufferedOutputStream bufstream = new BufferedOutputStream(filestream); DataOutputStream out = new DataOutputStream(bufstream); + if (DEBUG_BACKUP) Log.d(TAG, "Writing flattened data version " + FULL_BACKUP_VERSION); out.writeInt(FULL_BACKUP_VERSION); + if (DEBUG_BACKUP) Log.d(TAG, systemSettingsData.length + " bytes of settings data"); out.writeInt(systemSettingsData.length); out.write(systemSettingsData); + if (DEBUG_BACKUP) Log.d(TAG, secureSettingsData.length + " bytes of secure settings data"); out.writeInt(secureSettingsData.length); out.write(secureSettingsData); + if (DEBUG_BACKUP) Log.d(TAG, locale.length + " bytes of locale data"); out.writeInt(locale.length); out.write(locale); + if (DEBUG_BACKUP) Log.d(TAG, wifiSupplicantData.length + " bytes of wifi supplicant data"); out.writeInt(wifiSupplicantData.length); out.write(wifiSupplicantData); + if (DEBUG_BACKUP) Log.d(TAG, wifiConfigData.length + " bytes of wifi config data"); out.writeInt(wifiConfigData.length); out.write(wifiConfigData); @@ -241,28 +247,28 @@ public class SettingsBackupAgent extends BackupAgentHelper { int nBytes = in.readInt(); if (DEBUG_BACKUP) Log.d(TAG, nBytes + " bytes of settings data"); byte[] buffer = new byte[nBytes]; - in.read(buffer, 0, nBytes); + in.readFully(buffer, 0, nBytes); restoreSettings(buffer, nBytes, Settings.System.CONTENT_URI); // secure settings nBytes = in.readInt(); if (DEBUG_BACKUP) Log.d(TAG, nBytes + " bytes of secure settings data"); if (nBytes > buffer.length) buffer = new byte[nBytes]; - in.read(buffer, 0, nBytes); + in.readFully(buffer, 0, nBytes); restoreSettings(buffer, nBytes, Settings.Secure.CONTENT_URI); // locale nBytes = in.readInt(); if (DEBUG_BACKUP) Log.d(TAG, nBytes + " bytes of locale data"); if (nBytes > buffer.length) buffer = new byte[nBytes]; - in.read(buffer, 0, nBytes); + in.readFully(buffer, 0, nBytes); mSettingsHelper.setLocaleData(buffer, nBytes); // wifi supplicant nBytes = in.readInt(); if (DEBUG_BACKUP) Log.d(TAG, nBytes + " bytes of wifi supplicant data"); if (nBytes > buffer.length) buffer = new byte[nBytes]; - in.read(buffer, 0, nBytes); + in.readFully(buffer, 0, nBytes); int retainedWifiState = enableWifi(false); restoreWifiSupplicant(FILE_WIFI_SUPPLICANT, buffer, nBytes); FileUtils.setPermissions(FILE_WIFI_SUPPLICANT, @@ -277,7 +283,7 @@ public class SettingsBackupAgent extends BackupAgentHelper { nBytes = in.readInt(); if (DEBUG_BACKUP) Log.d(TAG, nBytes + " bytes of wifi config data"); if (nBytes > buffer.length) buffer = new byte[nBytes]; - in.read(buffer, 0, nBytes); + in.readFully(buffer, 0, nBytes); restoreFileData(mWifiConfigFile, buffer, nBytes); if (DEBUG_BACKUP) Log.d(TAG, "Full restore complete."); |