diff options
author | Paul Lawrence <paullawrence@google.com> | 2015-12-09 13:54:09 -0800 |
---|---|---|
committer | Paul Lawrence <paullawrence@google.com> | 2015-12-09 15:34:04 -0800 |
commit | 3045e27e894dd8a90faabc0177e080114b35af3b (patch) | |
tree | 0847b781be4a9b00ec3a8aa62d4a7070c5c20f70 /ext4_utils | |
parent | 89716a1586f9f8d0a76492c20df4ab30fa61575c (diff) | |
download | extras-3045e27e894dd8a90faabc0177e080114b35af3b.tar.gz |
Add createuserkey
Add createuserkey so we can create user0 key on first boot
Change-Id: I211a5a483c416da08239341f85eaf6eb99dca797
Diffstat (limited to 'ext4_utils')
-rw-r--r-- | ext4_utils/ext4_crypt_init_extensions.cpp | 13 | ||||
-rw-r--r-- | ext4_utils/ext4_crypt_init_extensions.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/ext4_utils/ext4_crypt_init_extensions.cpp b/ext4_utils/ext4_crypt_init_extensions.cpp index 50f4683d..ec8b9379 100644 --- a/ext4_utils/ext4_crypt_init_extensions.cpp +++ b/ext4_utils/ext4_crypt_init_extensions.cpp @@ -184,3 +184,16 @@ int e4crypt_set_user_crypto_policies(const char* dir) result.c_str()); return 0; } + +int e4crypt_create_user_key(userid_t user_id, int serial, bool ephemeral) +{ + auto command = std::string() + "cryptfs create_user_key " + + std::to_string(user_id) + " " + + std::to_string(serial) + " " + + (ephemeral ? "1" : "0"); + auto result = vold_command(command); + // ext4enc:TODO proper error handling + KLOG_INFO(TAG, "create_user_key returned with result %s\n", + result.c_str()); + return 0; +} diff --git a/ext4_utils/ext4_crypt_init_extensions.h b/ext4_utils/ext4_crypt_init_extensions.h index d02d181d..3bd19377 100644 --- a/ext4_utils/ext4_crypt_init_extensions.h +++ b/ext4_utils/ext4_crypt_init_extensions.h @@ -1,5 +1,6 @@ #include <sys/cdefs.h> #include <stdbool.h> +#include <cutils/multiuser.h> __BEGIN_DECLS @@ -12,5 +13,6 @@ int e4crypt_set_directory_policy(const char* path); bool e4crypt_non_default_key(const char* path); int do_policy_set(const char *directory, const char *policy, int policy_length); int e4crypt_set_user_crypto_policies(const char* path); +int e4crypt_create_user_key(userid_t user_id, int serial, bool ephemeral); __END_DECLS |