OSDN Git Service

resolve merge conflicts of 7bf98aa8a0c122aec9f3262fe1a24238d57ae8d0 to pi-dev-plus...
authorLuis Hector Chavez <lhchavez@google.com>
Tue, 5 Jun 2018 17:10:08 +0000 (10:10 -0700)
committerLuis Hector Chavez <lhchavez@google.com>
Tue, 5 Jun 2018 17:10:08 +0000 (10:10 -0700)
BUG: None
Test: I solemnly swear I tested this conflict resolution.
Change-Id: I08252155f04e8b414f2149d8b29e5e2fff6bcc82

1  2 
cryptfs.cpp

diff --cc cryptfs.cpp
@@@ -1605,9 -1449,11 +1605,11 @@@ static int cryptfs_restart_internal(in
           */
          char ro_prop[PROPERTY_VALUE_MAX];
          property_get("ro.crypto.readonly", ro_prop, "");
 -        if (strlen(ro_prop) > 0 && atoi(ro_prop)) {
 -            struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT);
 +        if (strlen(ro_prop) > 0 && std::stoi(ro_prop)) {
 +            struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab_default, DATA_MNT_POINT);
-             rec->flags |= MS_RDONLY;
+             if (rec) {
+                 rec->flags |= MS_RDONLY;
+             }
          }
  
          /* If that succeeded, then mount the decrypted filesystem */
@@@ -2947,6 -2922,84 +2949,6 @@@ void cryptfs_clear_password(
  
  int cryptfs_isConvertibleToFBE()
  {
 -    struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT);
 +    struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab_default, DATA_MNT_POINT);
-     return fs_mgr_is_convertible_to_fbe(rec) ? 1 : 0;
+     return (rec && fs_mgr_is_convertible_to_fbe(rec)) ? 1 : 0;
  }
 -
 -int cryptfs_create_default_ftr(struct crypt_mnt_ftr* crypt_ftr, __attribute__((unused))int key_length)
 -{
 -    if (cryptfs_init_crypt_mnt_ftr(crypt_ftr)) {
 -        SLOGE("Failed to initialize crypt_ftr");
 -        return -1;
 -    }
 -
 -    if (create_encrypted_random_key(DEFAULT_PASSWORD, crypt_ftr->master_key,
 -                                    crypt_ftr->salt, crypt_ftr)) {
 -        SLOGE("Cannot create encrypted master key\n");
 -        return -1;
 -    }
 -
 -    //crypt_ftr->keysize = key_length / 8;
 -    return 0;
 -}
 -
 -int cryptfs_get_master_key(struct crypt_mnt_ftr* ftr, const char* password,
 -                           unsigned char* master_key)
 -{
 -    int rc;
 -
 -    unsigned char* intermediate_key = 0;
 -    size_t intermediate_key_size = 0;
 -
 -    if (password == 0 || *password == 0) {
 -        password = DEFAULT_PASSWORD;
 -    }
 -
 -    rc = decrypt_master_key(password, master_key, ftr, &intermediate_key,
 -                            &intermediate_key_size);
 -
 -    if (rc) {
 -        SLOGE("Can't calculate intermediate key");
 -        return rc;
 -    }
 -
 -    int N = 1 << ftr->N_factor;
 -    int r = 1 << ftr->r_factor;
 -    int p = 1 << ftr->p_factor;
 -
 -    unsigned char scrypted_intermediate_key[sizeof(ftr->scrypted_intermediate_key)];
 -
 -    rc = crypto_scrypt(intermediate_key, intermediate_key_size,
 -                       ftr->salt, sizeof(ftr->salt), N, r, p,
 -                       scrypted_intermediate_key,
 -                       sizeof(scrypted_intermediate_key));
 -
 -    free(intermediate_key);
 -
 -    if (rc) {
 -        SLOGE("Can't scrypt intermediate key");
 -        return rc;
 -    }
 -
 -    return memcmp(scrypted_intermediate_key, ftr->scrypted_intermediate_key,
 -                  intermediate_key_size);
 -}
 -
 -int cryptfs_set_password(struct crypt_mnt_ftr* ftr, const char* password,
 -                         const unsigned char* master_key)
 -{
 -    return encrypt_master_key(password, ftr->salt, master_key, ftr->master_key,
 -                              ftr);
 -}
 -
 -void cryptfs_get_file_encryption_modes(const char **contents_mode_ret,
 -                                       const char **filenames_mode_ret)
 -{
 -    struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT);
 -    if (!rec) {
 -        *contents_mode_ret = nullptr;
 -        *filenames_mode_ret = nullptr;
 -        return;
 -    }
 -    fs_mgr_get_file_encryption_modes(rec, contents_mode_ret, filenames_mode_ret);
 -}