Snap for 5180536 from 2ab3b948d7
to pi-platform-release
Change-Id: Idc5557adef8d2cbc60a594ab3ea1aa3669140926
This commit is contained in:
commit
c03435f532
1 changed files with 6 additions and 30 deletions
36
cryptfs.cpp
36
cryptfs.cpp
|
@ -62,14 +62,11 @@
|
|||
#include "Process.h"
|
||||
#include "Keymaster.h"
|
||||
#include "android-base/properties.h"
|
||||
#include "android-base/stringprintf.h"
|
||||
#include <bootloader_message/bootloader_message.h>
|
||||
extern "C" {
|
||||
#include <crypto_scrypt.h>
|
||||
}
|
||||
|
||||
using android::base::StringPrintf;
|
||||
|
||||
#define UNUSED __attribute__((unused))
|
||||
|
||||
#define DM_CRYPT_BUF_SIZE 4096
|
||||
|
@ -320,10 +317,6 @@ constexpr CryptoType default_crypto_type = CryptoType()
|
|||
|
||||
constexpr CryptoType supported_crypto_types[] = {
|
||||
default_crypto_type,
|
||||
CryptoType()
|
||||
.set_property_name("adiantum")
|
||||
.set_crypto_name("xchacha12,aes-adiantum-plain64")
|
||||
.set_keysize(32),
|
||||
// Add new CryptoTypes here. Order is not important.
|
||||
};
|
||||
|
||||
|
@ -1079,21 +1072,6 @@ static std::string extra_params_as_string(const std::vector<std::string>& extra_
|
|||
return extra_params;
|
||||
}
|
||||
|
||||
// Only adds parameters if the property is set.
|
||||
static void add_sector_size_param(std::vector<std::string>* extra_params_vec) {
|
||||
constexpr char DM_CRYPT_SECTOR_SIZE[] = "ro.crypto.fde_sector_size";
|
||||
char sector_size[PROPERTY_VALUE_MAX];
|
||||
|
||||
if (property_get(DM_CRYPT_SECTOR_SIZE, sector_size, "") > 0) {
|
||||
std::string param = StringPrintf("sector_size:%s", sector_size);
|
||||
extra_params_vec->push_back(std::move(param));
|
||||
|
||||
// With this option, IVs will match the sector numbering, instead
|
||||
// of being hard-coded to being based on 512-byte sectors.
|
||||
extra_params_vec->emplace_back("iv_large_sectors");
|
||||
}
|
||||
}
|
||||
|
||||
static int create_crypto_blk_dev(struct crypt_mnt_ftr* crypt_ftr, const unsigned char* master_key,
|
||||
const char* real_blk_name, char* crypto_blk_name, const char* name,
|
||||
uint32_t flags) {
|
||||
|
@ -1139,7 +1117,6 @@ static int create_crypto_blk_dev(struct crypt_mnt_ftr* crypt_ftr, const unsigned
|
|||
if (flags & CREATE_CRYPTO_BLK_DEV_FLAGS_ALLOW_ENCRYPT_OVERRIDE) {
|
||||
extra_params_vec.emplace_back("allow_encrypt_override");
|
||||
}
|
||||
add_sector_size_param(&extra_params_vec);
|
||||
load_count = load_crypto_mapping_table(crypt_ftr, master_key, real_blk_name, name, fd,
|
||||
extra_params_as_string(extra_params_vec).c_str());
|
||||
if (load_count < 0) {
|
||||
|
@ -2567,25 +2544,24 @@ int cryptfs_changepw(int crypt_type, const char *newpw)
|
|||
static unsigned int persist_get_max_entries(int encrypted) {
|
||||
struct crypt_mnt_ftr crypt_ftr;
|
||||
unsigned int dsize;
|
||||
unsigned int max_persistent_entries;
|
||||
|
||||
/* If encrypted, use the values from the crypt_ftr, otherwise
|
||||
* use the values for the current spec.
|
||||
*/
|
||||
if (encrypted) {
|
||||
if (get_crypt_ftr_and_key(&crypt_ftr)) {
|
||||
/* Something is wrong, assume no space for entries */
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
dsize = crypt_ftr.persist_data_size;
|
||||
} else {
|
||||
dsize = CRYPT_PERSIST_DATA_SIZE;
|
||||
}
|
||||
|
||||
if (dsize > sizeof(struct crypt_persist_data)) {
|
||||
return (dsize - sizeof(struct crypt_persist_data)) / sizeof(struct crypt_persist_entry);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
max_persistent_entries = (dsize - sizeof(struct crypt_persist_data)) /
|
||||
sizeof(struct crypt_persist_entry);
|
||||
|
||||
return max_persistent_entries;
|
||||
}
|
||||
|
||||
static int persist_get_key(const char *fieldname, char *value)
|
||||
|
|
Loading…
Reference in a new issue