OSDN Git Service

cryptfs: Don't use bare integers for key size
authorGreg Kaiser <gkaiser@google.com>
Thu, 15 Feb 2018 04:15:18 +0000 (20:15 -0800)
committerGreg Kaiser <gkaiser@google.com>
Thu, 15 Feb 2018 20:28:51 +0000 (12:28 -0800)
Rather than use an integer and have a comment, we use a named
constant for sizing these master key buffers.  This will help
avoid confusion when we switch to allowing different sized
master keys.

Bug: 73079191
Test: Build
Change-Id: Ifaffdd94d337bb2d5a178f818dfe00f9386ae03b

cryptfs.cpp

index f32bb42..d0de553 100644 (file)
@@ -1604,8 +1604,7 @@ static int do_crypto_complete(const char *mount_point)
 static int test_mount_encrypted_fs(struct crypt_mnt_ftr* crypt_ftr,
                                    const char *passwd, const char *mount_point, const char *label)
 {
-  /* Allocate enough space for a 256 bit key, but we may use less */
-  unsigned char decrypted_master_key[32];
+  unsigned char decrypted_master_key[KEY_LEN_BYTES];
   char crypto_blkdev[MAXPATHLEN];
   char real_blkdev[MAXPATHLEN];
   char tmp_mount_point[64];
@@ -1862,8 +1861,7 @@ int cryptfs_check_passwd(const char *passwd)
 int cryptfs_verify_passwd(const char *passwd)
 {
     struct crypt_mnt_ftr crypt_ftr;
-    /* Allocate enough space for a 256 bit key, but we may use less */
-    unsigned char decrypted_master_key[32];
+    unsigned char decrypted_master_key[KEY_LEN_BYTES];
     char encrypted_state[PROPERTY_VALUE_MAX];
     int rc;