Commit graph

93 commits

Author SHA1 Message Date
Shawn Willden
47ba10d6d5 Pad object to proper size before signing.
Correct implementations of keymaster should reject using an n-bit
RSA key to sign less than n bits of data, because we specify that
keymaster should not perform padding.

Change-Id: Ibdff1bbfbee84fd5bdbfb3149a124dbbaa7827fc
2014-09-05 10:43:02 -06:00
Paul Lawrence
74f29f1df7 Don't test mount when we can use the crypto footer to test the password
Note that this also changes the boot sequence, and moves the test for corrupted
data to cryptfs_restart_internal.

Bug: 17213613
Change-Id: I0f86e8fe3d482e2d1373bd0f4d0d861e63ad8904
2014-08-29 08:31:10 -07:00
Paul Lawrence
00786076cd Merge "Don't reboot after default encrypting" into lmp-dev 2014-08-25 20:28:46 +00:00
Paul Lawrence
715775046c Show correct remaining time
In field reports, sometimes the remaining time gets stuck for many
minutes. This has to be caused by a spurious low reading early on which
cannot be overridded because of old logic.

Solution: allow time to increase but only by large amounts (avoid time
jittering up and down).

Bug: 16973374
Change-Id: I49d23ae8c54ded416cbedf383a3c03b33dc02e1c
2014-08-25 18:36:07 +00:00
Paul Lawrence
b6672e135a Don't reboot after default encrypting
Instead trigger normal default encryption mount

Requires matching change to system/core: https://googleplex-android-review.git.corp.google.com/#/c/527286/

Bug: 17041092

Change-Id: Ifcf023386e08325db7dce61395fbb056f7d9815b
2014-08-18 20:07:01 +00:00
Daniel Rosenberg
e82df164e8 Revert "Revert "cryptfs: Added support for f2fs fast encryption""
This reverts commit a70abc6009.

Change-Id: Ic41d1924638586cf9b2297f91ed5417f3b0303c6
2014-08-15 22:19:23 +00:00
Jim Miller
a70abc6009 Revert "cryptfs: Added support for f2fs fast encryption"
This reverts commit 74c01201de.

Change-Id: Ib397a2b5812179ee2e2b68de5d718077563adc1c
2014-08-15 02:00:45 +00:00
Daniel Rosenberg
74c01201de cryptfs: Added support for f2fs fast encryption
Bug: 15749466
Change-Id: I25452a05e1cbe90ac6603a89db9b720c7ab17e55
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2014-08-15 00:12:06 +00:00
Paul Lawrence
d0c7b17070 Wipe userdata when password is good but it won't mount
Store salted scrypt of intermediate key in crypto header

When mount fails, check if matches, and if it does return error
code prompting a wipe

Bug: 11477689
Change-Id: I3dcf9e0c64f2a01c8ba8eaf58df82cbe717d421b
2014-08-13 19:41:30 +00:00
Paul Lawrence
6bfed20c77 When encryption fails, reboot into recovery
Set flag on starting encryption to say it failed, and only clear
when we get into a recoverable state (partially or fully encrypted.)

Go to recovery on seeing this flag on boot

Bug: 16552363
Change-Id: I7e452b653edf3a087ecfaba8f81f41765a1c8daf
2014-08-07 13:14:35 -07:00
Elliott Hughes
231bdba012 Fix an accidental PRId64 to PRIx64.
Change-Id: Ic5313289d826bac74c3466b33f1f167a8f0955ad
2014-06-25 18:36:19 -07:00
Elliott Hughes
cb33f5741c resolved conflicts for merge of afa60cee to master
Change-Id: I1568def8839bed4d4d2dadbd97194d5603edc627
2014-06-25 18:31:47 -07:00
Elliott Hughes
7373716c6d Fix vold %lld to PRId64.
Change-Id: I6eb9f21fff124b8b22f4fae2ac74c2b41d93b384
2014-06-25 17:27:42 -07:00
JP Abgrall
62c7af38f2 cryptfs: makefs F2FS if the partition type is F2FS.
When a crypto is enabled with a wipe flag (obsolete?),
it will correctly handle the fstab's choice for the fs type.

Remove the dead code for FAT_FS which was un-invocable.

Change-Id: I8d141a0d4d14df9fe84d3b131484e9696fcd8870
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-16 13:01:23 -07:00
Paul Lawrence
73d7a02dc6 On low power turn off rather than rebooting to allow device to charge
The code was using encrypted_upto == 0 as an indicator that encryption
has succeeded. This meant that if no encryption happened, we would reboot
continually.

We now set encrypted_upto to fs_size when encryption is complete.

Also don't start to encrypt unless we are at 10% power. Stop when we
get to 5% power. This should lead to partial encryptions only very
rarely.

Bug: 15513202
Change-Id: I6214d78579d1fbbe2f63ee8862473d86a89d29b3
2014-06-09 15:15:32 -07:00
Paul Lawrence
a96d9c9b38 Calculate time to go while encrypting
@bug 15159008

Change-Id: I6a96eeab180dceb0613202ba5d252036a0d5376f
2014-06-05 19:44:57 +00:00
Paul Lawrence
58c58cf7ef Show correct percentage when encrypting used blocks only
Bug: 12975202
Change-Id: I7e4adfa2c4951055bbb2c11986a7784f465f586f
2014-06-05 19:44:07 +00:00
Paul Lawrence
8c00839714 Fix encryption on Nakasi
We need to make sure we don't try to read the flags on keymaster
version 2 or below, or we get random junk.

Requires
  https://googleplex-android-review.git.corp.google.com/#/c/460689/

Bug: 14384714
Change-Id: I5a4ede1bec0347b8319cedaae6535201c122cf48
2014-05-06 22:16:16 +00:00
Paul Lawrence
69f4ebd81e Add keymaster support to cryptfs
Use keymaster to wrap the cryptfs keys.

Requires selinux change
  https://googleplex-android-review.git.corp.google.com/#/c/449411

Bug: 9467042
Change-Id: If25a01cb85ed193a271d61382de0560d85553b7e
2014-04-18 11:40:13 -07:00
Paul Lawrence
45f10533f8 Revert "Revert "Encrypt phone even if pattern or no keyguard""
Don't block based on keyguard type, and pass type to encryption function.

Requires:
  https://googleplex-android-review.git.corp.google.com/#/c/444201/
or encryption will no longer work.

This reverts commit efec3f2927.

Change-Id: I431589a56eb11118027e0a5a84f55e973b1084aa
2014-04-10 14:30:31 +00:00
Paul Lawrence
efec3f2927 Revert "Encrypt phone even if pattern or no keyguard"
This reverts commit 5cc86c5741.

Without two more commits, this will break encryption. I'll re-commit when the other two pass code review.

Change-Id: I71720d065c16cf0f7f534e74ffe883f1e113c477
2014-04-03 20:55:47 +00:00
Paul Lawrence
5cc86c5741 Encrypt phone even if pattern or no keyguard
Add option to enablecrypto to take type, allowing us to set type
when encrypting.

Bug: 13749169
Change-Id: If22fcfa93f1ebd1a5bd3b0077bb3bd8ae71fe819
2014-04-03 19:20:28 +00:00
Paul Lawrence
0798707334 Merge "Fix setfield/getfield" 2014-03-24 17:51:59 +00:00
Paul Lawrence
cc215381dd Merge "Store password in vold" 2014-03-21 20:40:36 +00:00
Paul Lawrence
87999173dd Don't corrupt ssd when encrypting and power fails
Stop encryption when battery is low, mark position, and continue on reboot.

Note - support for multiple encrypted volumes removed as no devices seem
to exist with an fstab that uses this feature. If you want support for such
a device, contact me and we will re-add it with appropriate testing.

Bug: 13284213
Change-Id: I1f7178e4f7dd8ea816cbc03ab5c4f6543e98acaa
2014-03-21 18:30:26 +00:00
Paul Lawrence
399317ede4 Store password in vold
If we are not to double prompt, we need to pass the password from
CryptKeeper to KeyStore. Since the entire framework is taken down
and restarted, we must store the password in a secure system daemon.
There seems no better way than holding it in vold.

Change-Id: Ia60f2f051fc3f87c4b6468465f17b655f43f97de
2014-03-21 11:15:39 -07:00
Paul Lawrence
8561b5c9f5 Fix setfield/getfield
Check for versions >= feature version, not equal

Bug: 13526708
Change-Id: Ie07f6334e6b7c5ca0d7f83ba00827a508e2c2963
2014-03-18 10:52:14 -07:00
Paul Lawrence
684dbdf316 Infrastructure to securely allow only one prompt at boot when encrypted
Add a call to vold that says if we decrypted the data partition. Reset the
flag so that it only returns true the first time.

Bug: 12990752
Change-Id: Ib00be87137c00fb8ad29205c85a3ea187764b702
2014-02-14 17:41:18 +00:00
Paul Lawrence
1348603357 Enable auto-encrypt drive at startup
Modify enablecrypto command to make the password optional. When it is
not there, default encrypt the device.

Remove a warning by making at least some parts of this file const-correct.

Bug: 11985952
Change-Id: Ie27da4c4072386d9d6519d97ff46c6dc4ed188dc
2014-02-14 09:34:44 -08:00
Paul Lawrence
931f15d050 Merge "Support default, pattern, pin and password encryption types" 2014-02-14 15:24:13 +00:00
Mark Salyzyn
2c1bbe0c44 am 49dd24c2: am 1dc1fb4a: Merge "vold: suppress unused argument warning messages"
* commit '49dd24c238e86c57e97f919af7fbf8ee3d79b737':
  vold: suppress unused argument warning messages
2014-02-13 00:19:54 +00:00
Paul Lawrence
f4faa575c9 Support default, pattern, pin and password encryption types
Store encryption type in crypto footer, and provide functions to
manipulate it. Add mount_default_encrypted command to vdc to allow
mounting of default encrypted volumes at boot time.

Bug: 8769627
Change-Id: Ie41848f258e128b48b579e09789abfa24c95e2b2
2014-02-12 14:54:40 -08:00
Mark Salyzyn
5eecc449cc vold: suppress unused argument warning messages
(cherry picked from commit 3e971277db)

Change-Id: Ic1ab533f756fbd44b1f2e5ae12e2f5736ace7740
2014-02-12 14:27:51 -08:00
Mark Salyzyn
3e971277db vold: suppress unused argument warning messages
Change-Id: Ic1ab533f756fbd44b1f2e5ae12e2f5736ace7740
2014-02-12 20:18:28 +00:00
Colin Cross
88948cd60c am e985c9ab: am 1d8e3ce8: Merge "vold: fix errors inside ALOGV"
* commit 'e985c9ab10fed452b97138170b4d69288d076b06':
  vold: fix errors inside ALOGV
2014-02-10 12:51:31 +00:00
Colin Cross
59846b654e vold: fix errors inside ALOGV
Fix errors exposed by adding compile-time checking to disabled ALOGVs.

Change-Id: I29bd6e9a7648ccca02e0e9a96b79ee0ea7b5cfc6
2014-02-06 20:34:29 -08:00
Paul Lawrence
ae59fe6c19 Fast ext4 encryption
For ext4 filesystems, only encrypt blocks in use.

Needs matching ext4 utils changes from
 https://googleplex-android-review.git.corp.google.com/#/c/409575

Bug: 11985952
Change-Id: I89df051c25105daf3f469cc980195202f8be6786
2014-01-29 22:29:10 +00:00
Doug Zongker
6fd5771337 allow encrypted filesystems to be mounted readonly
By setting ro.crypto.readonly to 1, cryptfs will mount an encrypted
filesystem that is normally mounted read-write as read-only instead.
To be used when recovery mounts /data.

Bug: 12188746
Change-Id: If3f3f9a3024f29ebc4ad721a48546a332cb92b6b
2013-12-17 09:43:23 -08:00
JP Abgrall
dbf5b6652c am 46f8c2b9: am 7bdfa52d: vold: cryptfs: Don\'t update KDF without validating pwd/key.
* commit '46f8c2b954e11c2266871b8110b74bd6a11f3661':
  vold: cryptfs: Don't update KDF without validating pwd/key.
2013-11-15 14:25:37 -08:00
JP Abgrall
7bdfa52d93 vold: cryptfs: Don't update KDF without validating pwd/key.
Prior to this, the Key derivation function would get
 blindly updated even if the user entered the wrong password.
Now, we only attempt to upgrade the KDF if the pwd/key have
been verified (i.e. after a successful mount).

Bug: 11460197
Change-Id: I0469228cc9b87c47754e8ca3c7146651da177da5
2013-11-15 13:42:56 -08:00
JP Abgrall
502dc74153 vold: cryptfs: Retry encryption after killing processes using /data
Currently, if a non-framework process or service is using /data,
unmounting will fail as nothing will kill it.
Instead of rebooting on unmount failure, we now kill all processes
using /data, then try one more time.

Bug: 11291208
Change-Id: I6c5276c78aa55965914ace96e1db74dc80fca3c1
2013-11-01 13:08:46 -07:00
Ken Sumrall
e550f78a3f Use android_fork_execvp() instead of system(3) to format filesystems
With the recent selinux changes imposed on vold, it no longer has
permission to run a shell, so invoking the filesystem formatting
commands with system(3) gives an error.  So change to using
android_fork_execvp().

Bug: 10279958

Change-Id: Ifa18b28867618858ec7c5cfcc67935e377de38fb
2013-08-21 11:30:16 -07:00
Kenny Root
2947e34e41 Initialize iterator
Iterator wasn't initialized in scrypt parameter scanning.

Bug: 10330227
Change-Id: If41fc25d9f827106fa8329bdb5966b7d786fddcb
2013-08-14 23:26:19 +00:00
Ken Sumrall
558830c38a Merge "vold: Use the new method of rebooting by asking init to do it" 2013-06-28 02:47:46 +00:00
Ken Sumrall
adfba3626e vold: Use the new method of rebooting by asking init to do it
Change-Id: I7fd5f1048c3cf43fa14597f079c929690cac367c
2013-06-26 17:51:44 -07:00
Kenny Root
c4c70f15bb Change key derivation to scrypt
scrypt is a sequential memory-hard key derivation algorithm that makes
it more difficult for adversaries to brute force passwords using
specialized equipment. See http://www.tarsnap.com/scrypt/scrypt.pdf for
more details of the algorithm.

This adds support for initializing disk encryption using scrypt and
upgrading from the previous PBKDF2 algorithm.

Change-Id: I1d26db4eb9d27fea7310be3e49c8e6219e6d2c3b
2013-06-24 09:40:54 -07:00
Kenny Root
c96a5f8edf Extract some version constants to header
In order to make it easier to upgrade the crypto footer, extract some
constants to a header file instead. Then the header can control what the
current version is and the upgrade_crypto_ftr code should be the only
thing that needs to be updated.

Change-Id: I3ed5a7d3b640419cd8af91388d94a00de8cc09db
2013-06-14 12:50:02 -07:00
Kenny Root
7434b3111b Change upgrade code to allow multiple versions
In the future, we'd like to have the ability to upgrade from any
supported version to any future version. Change the upgrade function
slightly to support this.

Change-Id: I3b20ccfff51c4c86f1e5e08690c263dc95ff5ce4
2013-06-14 11:32:18 -07:00
Ken Sumrall
9caab76c6b vold: Add an optional wipe paramter to the volume format command
The new wipe option to the vold format command will invoke BLKDISCARD
on the partition before invoking newfs_msdos.  This will be used whenever
a full wipe of the device is wanted, as this is more secure than just
doing newfs_msdos.

Bug: 9392982
Change-Id: Ie106f1b9cc70abc61206006d1821641c27c7ccae
2013-06-12 18:42:02 -07:00
Ken Sumrall
e88e1eb745 am c587269c: vold: Increase timeout due to selinux changes
* commit 'c587269c5a34d4e7412ff42e53ed6312359a8505':
  vold: Increase timeout due to selinux changes
2013-05-14 19:19:22 -07:00