dest->content.value.a = src->content.value.a;
dest->content.value.b = src->content.value.b;
} else {
- int buf_size = (src->content.ref.length + 7) / 8;
+ int buf_size = src->content.ref.length;
void* buffer = OsaMalloc(buf_size);
if (!buffer) {
return TEE_ERROR_OUT_OF_MEMORY;
size += 2 * sizeof(uint32_t);
} else {
size += sizeof(size_t);
- size += (attrs[i].content.ref.length + 7) / 8;
+ size += attrs[i].content.ref.length;
}
}
return size;
memcpy(buf, &(attrs[i].content.ref.length), 4);
buf += 4;
memcpy(buf, (void*)attrs[i].content.ref.buffer,
- (attrs[i].content.ref.length + 7) / 8);
- buf += (attrs[i].content.ref.length + 7) / 8;
+ attrs[i].content.ref.length);
+ buf += attrs[i].content.ref.length;
}
}
return TEE_SUCCESS;
} else {
memcpy((void*)&attrs[i].content.ref.length, buf, 4);
buf += 4;
- void* buffer = OsaMalloc((attrs[i].content.ref.length + 7) / 8);
+ void* buffer = OsaMalloc(attrs[i].content.ref.length);
if (!buffer) {
return TEE_ERROR_OUT_OF_MEMORY;
}
- memcpy(buffer, buf, (attrs[i].content.ref.length + 7) / 8);
+ memcpy(buffer, buf, attrs[i].content.ref.length);
attrs[i].content.ref.buffer = buffer;
- buf += (attrs[i].content.ref.length + 7) / 8;
+ buf += attrs[i].content.ref.length;
}
}
return TEE_SUCCESS;
TEE_Panic(0);
}
//len = ((obj->attr.attr_array[n].content.ref.length & 0x7FFFFFFF) + 7) >> 3 ;
- len = (obj->attr.attr_array[n].content.ref.length + 7) >> 3;
+ len = obj->attr.attr_array[n].content.ref.length;
// out buffer is too small
if (len > *size) {
TEE_Attribute* curr_attr = &tr->attr.attr_array[tr->attr.attr_number];
for (i = 0; i < attrCount; i++) {
- if (attrs[i].content.ref.length > tr->info.maxObjectSize) {
+ if (attrs[i].content.ref.length * 8 > tr->info.maxObjectSize) {
TZ_ERROR("operation error line = %d,%s\n", __LINE__, __func__);
TEE_Panic(0);
}
copy_attribute(&curr_attr[i], (TEE_Attribute*)&attrs[i]);
tr->attr.attr_number++;
tr->info.objectSize =
- tr->info.objectSize > attrs[i].content.ref.length ?
- tr->info.objectSize : attrs[i].content.ref.length;
+ tr->info.objectSize > attrs[i].content.ref.length * 8 ?
+ tr->info.objectSize : attrs[i].content.ref.length * 8;
}
switch (tr->info.objectType) {
case TEE_TYPE_GENERIC_SECRET:
// generate 1 random key
gen_random((unsigned char*)key, (keySize + 7) / 8);
- TEE_InitRefAttribute(&attrs[0], TEE_ATTR_SECRET_VALUE, key, keySize);
+ TEE_InitRefAttribute(&attrs[0], TEE_ATTR_SECRET_VALUE, key, (keySize + 7) / 8);
TEE_PopulateTransientObject(object, attrs, 1);
break;
case TEE_TYPE_RSA_KEYPAIR: {
uci_context_free(uh);
TEE_InitRefAttribute(&attrs[0], TEE_ATTR_RSA_MODULUS, uci_key.ucik_rsa_n,
- keySize);
+ (keySize + 7) / 8);
TEE_InitRefAttribute(&attrs[1], TEE_ATTR_RSA_PUBLIC_EXPONENT,
- uci_key.ucik_rsa_e, keySize);
+ uci_key.ucik_rsa_e, (keySize + 7) / 8);
TEE_InitRefAttribute(&attrs[2], TEE_ATTR_RSA_PRIVATE_EXPONENT,
- uci_key.ucik_rsa_d, keySize);
+ uci_key.ucik_rsa_d, (keySize + 7) / 8);
TEE_PopulateTransientObject(object, attrs, 3);
OsaFree(uci_key.ucik_rsa_n);
for (i = 0; i < paramCount; i++) {
if (params[i].attributeID == TEE_ATTR_DSA_PRIME) {
up.ucip_dsa_p = (unsigned char*)params[i].content.ref.buffer;
- up.ucip_dsa_p_len = (params[i].content.ref.length + 7) / 8;
+ up.ucip_dsa_p_len = params[i].content.ref.length;
check |= 0x01;
} else if (params[i].attributeID == TEE_ATTR_DSA_BASE) {
up.ucip_dsa_g = (unsigned char*)params[i].content.ref.buffer;
- up.ucip_dsa_g_len = (params[i].content.ref.length + 7) / 8;
+ up.ucip_dsa_g_len = params[i].content.ref.length;
check |= 0x02;
} else if (params[i].attributeID == TEE_ATTR_DSA_SUBPRIME) {
up.ucip_dsa_q = (unsigned char*)params[i].content.ref.buffer;
- up.ucip_dsa_q_len = (params[i].content.ref.length + 7) / 8;
+ up.ucip_dsa_q_len = params[i].content.ref.length;
check |= 0x04;
}
}
params[i].content.ref.buffer, params[i].content.ref.length);
}
TEE_InitRefAttribute(&attrs[3], TEE_ATTR_DSA_PUBLIC_VALUE,
- uci_key.ucik_dsa_pubkey, uci_key.ucik_dsa_pubk_len * 8);
+ uci_key.ucik_dsa_pubkey, uci_key.ucik_dsa_pubk_len);
TEE_InitRefAttribute(&attrs[4], TEE_ATTR_DSA_PRIVATE_VALUE,
- uci_key.ucik_dsa_privkey, uci_key.ucik_dsa_privk_len * 8);
+ uci_key.ucik_dsa_privkey, uci_key.ucik_dsa_privk_len);
TEE_PopulateTransientObject(object, attrs, 5);
OsaFree(uci_key.ucik_dsa_pubkey);
OsaFree(uci_key.ucik_dsa_privkey);
if (params[i].attributeID == TEE_ATTR_DH_PRIME) {
check |= 0x01;
uciparam.ucip_dh_prime = (unsigned char*)params[i].content.ref.buffer;
- uciparam.ucip_dh_len = (params[i].content.ref.length + 7) / 8;
+ uciparam.ucip_dh_len = params[i].content.ref.length;
} else if (params[i].attributeID == TEE_ATTR_DH_BASE) {
check |= 0x02;
uciparam.ucip_dh_generator = (unsigned char*)params[i].content.ref
params[i].content.ref.buffer, params[i].content.ref.length);
}
TEE_InitRefAttribute(&attrs[2], TEE_ATTR_DH_PRIVATE_VALUE, privKey,
- keySize);
+ (keySize + 7) / 8);
TEE_InitRefAttribute(&attrs[3], TEE_ATTR_DH_PUBLIC_VALUE, pubKey,
- keySize);
+ (keySize + 7) / 8);
TEE_PopulateTransientObject(object, attrs, 4);
OsaFree(privKey);