Use bytes instead of bits in TEE_InitRefAttribute 55/170255/2
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 15 Feb 2018 15:28:14 +0000 (16:28 +0100)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 16 Feb 2018 10:47:18 +0000 (11:47 +0100)
According to TEE Internal Core API spec TEE_InitRefAttribute expects a buffer
length, so bytes instead of bits.

Change-Id: Ie5348a357b83cb727ffbfff9e5be633c5b8b1da9

ta/src/internal.c

index 92ab330f3ea89c0d2573e44615300bf8a3c262f0..3c58806246e0392801a378540e6cc200e6b5e5bb 100644 (file)
@@ -74,9 +74,7 @@ TEE_Result KM_CreateKey(uint32_t tee_key_type, uint32_t key_bits_size, void *key
        TEE_Attribute attr;
        TEE_Result ret = TEE_SUCCESS;
 
-       // TODO According to tef-simulator, here we should provide size in bits,
-       //      not bytes. Is it the same on other TEF implementations?
-       TEE_InitRefAttribute(&attr, TEE_ATTR_SECRET_VALUE, key, key_bits_size);
+       TEE_InitRefAttribute(&attr, TEE_ATTR_SECRET_VALUE, key, (key_bits_size + 7)/8);
        ret = TEE_AllocateTransientObject(tee_key_type, key_bits_size, hndl);
        if (TEE_SUCCESS != ret) {
                LOG("TEE_AllocateTransientObject has failed with=%x. Arguments=(tee_key_type=%X, "