return TEE_SUCCESS;
}
+static TEE_Result KM_ToTeeEcdhAlgo(uint32_t curve, uint32_t *algo)
+{
+ switch(curve) {
+ case EC_NIST_P192: *algo = TEE_ALG_ECDH_P192; break;
+ case EC_NIST_P256: *algo = TEE_ALG_ECDH_P256; break;
+ case EC_NIST_P384: *algo = TEE_ALG_ECDH_P384; break;
+ default: return TEE_ERROR_BAD_PARAMETERS;
+ }
+ return TEE_SUCCESS;
+}
+
static TEE_Result KM_ToKeyBitSize(uint32_t curve, uint32_t *bitsize)
{
switch(curve) {
TEE_ObjectHandle tmp_secret_handl = TEE_HANDLE_NULL;
TEE_Attribute ecdhParams[2];
uint32_t priv_curve = 0, pub_curve = 0, b = 0;
+ uint32_t ecdh_algo = 0;
uint32_t maxKeySizeBits = 0;
TEE_GetObjectInfo(prv_key, &info);
return TEE_ERROR_BAD_PARAMETERS;
}
+ ret = KM_ToTeeEcdhAlgo(curve, &ecdh_algo);
+ if (ret) {
+ LOG("Failed to convert curve to ecdh_algo, input = %d", curve);
+ return TEE_ERROR_BAD_PARAMETERS;
+ }
+
ret = TEE_AllocateTransientObject(TEE_TYPE_GENERIC_SECRET, maxKeySizeBits, &tmp_secret_handl);
if (TEE_SUCCESS != ret) {
LOG("TEE_AllocateTransientObject has failed with=%x. key_type = %x max_key_bits_size = %u",
ecdh_key = prv_key;
}
- ret = KM_CreateOperation(ecdh_key, TEE_ALG_ECDH_DERIVE_SHARED_SECRET, TEE_MODE_DERIVE, &operation);
+ ret = KM_CreateOperation(ecdh_key, ecdh_algo, TEE_MODE_DERIVE, &operation);
if (TEE_SUCCESS != ret) {
LOG("KM_CreateOperation() has failed with=%x", ret);
goto clean;