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 /services/java/com/android/server/SystemBackupAgent.java | |
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 'services/java/com/android/server/SystemBackupAgent.java')
-rw-r--r-- | services/java/com/android/server/SystemBackupAgent.java | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/services/java/com/android/server/SystemBackupAgent.java b/services/java/com/android/server/SystemBackupAgent.java index 950f3b6..da97089 100644 --- a/services/java/com/android/server/SystemBackupAgent.java +++ b/services/java/com/android/server/SystemBackupAgent.java @@ -21,6 +21,7 @@ import android.app.backup.BackupDataInput; import android.app.backup.BackupDataOutput; import android.app.backup.BackupAgentHelper; import android.app.backup.FullBackup; +import android.app.backup.FullBackupDataOutput; import android.app.backup.WallpaperBackupHelper; import android.content.Context; import android.os.ParcelFileDescriptor; @@ -53,13 +54,6 @@ public class SystemBackupAgent extends BackupAgentHelper { @Override public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException { - if (oldState == null) { - // Ah, it's a full backup dataset, being restored piecemeal. Just - // pop over to the full restore handling and we're done. - runFullBackup(data); - return; - } - // We only back up the data under the current "wallpaper" schema with metadata WallpaperManagerService wallpaper = (WallpaperManagerService)ServiceManager.getService( Context.WALLPAPER_SERVICE); @@ -74,19 +68,21 @@ public class SystemBackupAgent extends BackupAgentHelper { super.onBackup(oldState, data, newState); } - private void runFullBackup(BackupDataOutput output) { - fullWallpaperBackup(output); + @Override + public void onFullBackup(FullBackupDataOutput data) throws IOException { + // At present we back up only the wallpaper + fullWallpaperBackup(data); } - private void fullWallpaperBackup(BackupDataOutput output) { + private void fullWallpaperBackup(FullBackupDataOutput output) { // Back up the data files directly. We do them in this specific order -- // info file followed by image -- because then we need take no special // steps during restore; the restore will happen properly when the individual // files are restored piecemeal. FullBackup.backupToTar(getPackageName(), FullBackup.ROOT_TREE_TOKEN, null, - WALLPAPER_INFO_DIR, WALLPAPER_INFO, output); + WALLPAPER_INFO_DIR, WALLPAPER_INFO, output.getData()); FullBackup.backupToTar(getPackageName(), FullBackup.ROOT_TREE_TOKEN, null, - WALLPAPER_IMAGE_DIR, WALLPAPER_IMAGE, output); + WALLPAPER_IMAGE_DIR, WALLPAPER_IMAGE, output.getData()); } @Override |