From 0e66f2b8f1c4330d7d51754be42b40964da69ecd Mon Sep 17 00:00:00 2001 From: Luden Date: Sat, 12 Mar 2016 10:32:55 +0100 Subject: Ported keymaster_tuna to keymaster0 interface. keymaster_tuna.cpp almost exactly matches keymaster HAL 0 interface, only several small changes were needed. Note the change in the flags (KEYMASTER_BLOBS_ARE_STANDALONE): this is required for hardware backed storage of the disk encryption key to function, see keymaster_check_compatibility() function in system/vold/cryptfs.c Change-Id: I207455efeb73cee26f08d2cfd12aa4fb91ccec23 --- device.mk | 4 ++-- keymaster/Android.mk | 2 +- keymaster/keymaster_tuna.cpp | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/device.mk b/device.mk index 1afd8bd..7c2da43 100755 --- a/device.mk +++ b/device.mk @@ -62,8 +62,8 @@ PRODUCT_PACKAGES += \ PRODUCT_PROPERTY_OVERRIDES += \ media.aac_51_output_enabled=true -#PRODUCT_PACKAGES += \ -# keystore.tuna +PRODUCT_PACKAGES += \ + keystore.tuna # Init files PRODUCT_COPY_FILES += \ diff --git a/keymaster/Android.mk b/keymaster/Android.mk index 885812f..10846df 100644 --- a/keymaster/Android.mk +++ b/keymaster/Android.mk @@ -29,7 +29,7 @@ LOCAL_SRC_FILES := \ LOCAL_C_INCLUDES := \ libcore/include \ external/openssl/include \ - hardware/ti/omap4xxx/security/tf_sdk/include + hardware/ti/omap4/security/tf_sdk/include LOCAL_CFLAGS := -fvisibility=hidden -Wall -Werror diff --git a/keymaster/keymaster_tuna.cpp b/keymaster/keymaster_tuna.cpp index 4385f23..1c31355 100644 --- a/keymaster/keymaster_tuna.cpp +++ b/keymaster/keymaster_tuna.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -38,6 +38,8 @@ #include +typedef keymaster0_device keymaster_device_t; +typedef keymaster0_device keymaster_device; /** The size of a key ID in bytes */ #define ID_LENGTH 32 @@ -219,7 +221,7 @@ static ByteArray* bignum_to_array(const BIGNUM* bn) { Unique_CK_BYTE bytes(new CK_BYTE[bignumSize]); unsigned char* tmp = reinterpret_cast(bytes.get()); - if (BN_bn2bin(bn, tmp) != bignumSize) { + if (int(BN_bn2bin(bn, tmp)) != bignumSize) { ALOGE("public exponent size wasn't what was expected"); return NULL; } @@ -606,7 +608,7 @@ static int tee_import_keypair(const keymaster_device_t* dev, return keyblob_save(objId.get(), key_blob, key_blob_length); } -static int tee_get_keypair_public(const struct keymaster_device* dev, +static int tee_get_keypair_public(const keymaster_device* dev, const uint8_t* key_blob, const size_t key_blob_length, uint8_t** x509_data, size_t* x509_data_length) { @@ -708,7 +710,7 @@ static int tee_get_keypair_public(const struct keymaster_device* dev, return 0; } -static int tee_delete_keypair(const struct keymaster_device* dev, +static int tee_delete_keypair(const keymaster_device* dev, const uint8_t* key_blob, const size_t key_blob_length) { CryptoSession session(reinterpret_cast(dev->context)); @@ -896,7 +898,7 @@ static int tee_open(const hw_module_t* module, const char* name, dev->common.version = 1; dev->common.module = (struct hw_module_t*) module; dev->common.close = tee_close; - dev->flags = 0; + dev->flags = KEYMASTER_BLOBS_ARE_STANDALONE; dev->generate_keypair = tee_generate_keypair; dev->import_keypair = tee_import_keypair; -- cgit v1.1