I enabled device encryption but android didn't gave me the chance to choose a new password instead it used the lock screen's. I came back to screen lock settings and changed the password and encryption password has changed automatically. But that happened instantly, my device didn't go through any process of encryption

Question is: Does changing encryption password require any kind of long re-encryption process? In other words, is my device still secure and data is encrypted securely?

Device: Xperia E4 Dual

Android version: 4.4.2 sony stock

1 Answer 1


From the Official Android Source:

Upon first boot, the device creates a randomly generated 128-bit master key and then hashes it with a default password and stored salt. (The default password is: "default_password").
However, the resultant hash is also signed through a TEE (such as TrustZone), which uses a hash of the signature to encrypt the master key.

When the user sets the PIN/pass or password on the device, only the 128-bit key is re-encrypted and stored. (ie. user PIN/pass/pattern changes do NOT cause re-encryption of userdata.)

What this means is that, essentially, there are two keys to be understood:

  1. The master key
  2. The user_encryption key (or just 'key')

The master key is generated during the first boot only, and never ever changes (unless maybe a factory reset or wiping userdata partition is done). The data in the /data partition is encrypted or decrypted only using the master key. The master key cannot be stored as it is (it's not safe to do so, right?), so it is encrypted using another key said below.

The user_encryption key is the key using which the encrypted master key can be decrypted, because only using the master key, the encrypted data can be decrypted. (This key is computed based on your PIN/password/whatever.)

People often tend to think both these keys as one and the same, which is not the case here.

When you change your unlock PIN/password, only the user_encryption key changes, not the master key, so the data is not re-encrypted.

  • The statement "uses a hash of the signature to encrypt the master key" is confusing. If the master key is encrypted using a hash of the signature of the hash that was generated from the master key, a salt, and a password, then how can the master key be decrypted?
    – Melab
    Oct 16, 2019 at 17:38
  • I agree, it's confusing, and the block-quoted text is still present in the Android docs verbatim.
    – Gokul NC
    Oct 17, 2019 at 4:38
  • This is my guees (augmenting my above explanation): the so-called user_encryption key which I have mentioned above is computed as hash_128(sign(hash(master_key_hash, password/pin, salt), TEE_key)). Now this key is computed on the go everytime you unlock the phone. This is the key using which the master key is encrypted. So, the same key is required to decrypt & get the master key and, use that master key to decrypt your userdata.
    – Gokul NC
    Oct 17, 2019 at 4:43
  • @Melab so to answer your question, maybe they also have the hash of the master_key stored somewhere (not the master_key itself). I maybe wrong, the only way to find out would be going through the source code. If you do so and find that my explanation is incorrect, please feel free to correct/edit it.
    – Gokul NC
    Oct 17, 2019 at 4:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .