예제 #1
0
TEE_Result ta_entry_set_operation_key(uint32_t param_type, TEE_Param params[4])
{
	ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
			  (TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
			   TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));

	return TEE_SetOperationKey((TEE_OperationHandle) params[0].value.a,
				   (TEE_ObjectHandle) params[0].value.b);
}
예제 #2
0
파일: cryp_taf.c 프로젝트: liuyq/optee_test
TEE_Result ta_entry_set_operation_key(uint32_t param_type, TEE_Param params[4])
{
	TEE_OperationHandle op = VAL2HANDLE(params[0].value.a);
	TEE_ObjectHandle key = VAL2HANDLE(params[0].value.b);

	ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
			  (TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
			   TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));

	return TEE_SetOperationKey(op, key);
}
예제 #3
0
void TEE_CopyOperation(TEE_OperationHandle dst_op, TEE_OperationHandle src_op)
{
	TEE_Result res;

	if (dst_op == TEE_HANDLE_NULL || src_op == TEE_HANDLE_NULL)
		TEE_Panic(0);
	if (dst_op->info.algorithm != src_op->info.algorithm)
		TEE_Panic(0);
	if (src_op->info.operationClass != TEE_OPERATION_DIGEST) {
		TEE_ObjectHandle key1 = TEE_HANDLE_NULL;
		TEE_ObjectHandle key2 = TEE_HANDLE_NULL;

		if (src_op->info.handleState & TEE_HANDLE_FLAG_KEY_SET) {
			key1 = src_op->key1;
			key2 = src_op->key2;
		}

		if ((src_op->info.handleState &
		     TEE_HANDLE_FLAG_EXPECT_TWO_KEYS) == 0) {
			TEE_SetOperationKey(dst_op, key1);
		} else {
			TEE_SetOperationKey2(dst_op, key1, key2);
		}
	}
	dst_op->info.handleState = src_op->info.handleState;
	dst_op->info.keySize = src_op->info.keySize;
	dst_op->operationState = src_op->operationState;

	if (dst_op->buffer_two_blocks != src_op->buffer_two_blocks ||
	    dst_op->block_size != src_op->block_size)
		TEE_Panic(0);

	if (dst_op->buffer != NULL) {
		if (src_op->buffer == NULL)
			TEE_Panic(0);

		memcpy(dst_op->buffer, src_op->buffer, src_op->buffer_offs);
		dst_op->buffer_offs = src_op->buffer_offs;
	} else if (src_op->buffer != NULL) {
		TEE_Panic(0);
	}

	res = utee_cryp_state_copy(dst_op->state, src_op->state);
	if (res != TEE_SUCCESS)
		TEE_Panic(res);
}
예제 #4
0
TEE_Result get_random_key_method2()
{
    TEE_Result res;
    TEE_OperationHandle operation = TEE_HANDLE_NULL;
    uint32_t algorithm            = TEE_ALG_HMAC_MD5;
    uint32_t mode                 = TEE_MODE_MAC;
    uint32_t maxKeySize           = 512;

    res = TEE_AllocateOperation(&operation, algorithm, mode, maxKeySize);
    if(res != TEE_SUCCESS) {
        TEE_Printf("[err] TEE_AllocateOperation\n");
        goto _ret_;
    }

    TEE_ObjectHandle hKeyObject  = TEE_HANDLE_NULL;
    TEE_ObjectType keyObjectType = TEE_TYPE_HMAC_MD5;
    uint32_t maxKeyObjectSize    = maxKeySize; 

    res = TEE_NewRandomKeyObject(keyObjectType, maxKeyObjectSize, &hKeyObject);
    if(res != TEE_SUCCESS) {
        TEE_Printf("[err] TEE_AllocateTransientObject\n");
        return 0;
    }   
    
    res = TEE_SetOperationKey(operation, hKeyObject);
    if(res != TEE_SUCCESS) {
        TEE_Printf("[err] TEE_SetOperationKey\n");
        goto _ret_;
    }

_ret_:
    if (operation) {
        TEE_FreeOperation(operation);   
    }
    if(hKeyObject) {
        TEE_FreeTransientObject(hKeyObject);
    }

    return res;
}