Add key derivation service level tests

Adds end-to-end service tests for key derivation operations
provided by a crypto provider.

Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I1fa0f0f269d9f32fc05ee116edf0ccea618dd17f
diff --git a/components/service/crypto/client/cpp/crypto_client.h b/components/service/crypto/client/cpp/crypto_client.h
index eb30655..2a5e5b9 100644
--- a/components/service/crypto/client/cpp/crypto_client.h
+++ b/components/service/crypto/client/cpp/crypto_client.h
@@ -176,6 +176,51 @@
 	virtual psa_status_t mac_abort(
 		uint32_t op_handle) = 0;
 
+	/* Key derivation methods */
+	virtual psa_status_t key_derivation_setup(
+		uint32_t *op_handle,
+		psa_algorithm_t alg) = 0;
+
+	virtual psa_status_t key_derivation_get_capacity(
+		const uint32_t op_handle,
+		size_t *capacity) = 0;
+
+	virtual psa_status_t key_derivation_set_capacity(
+		uint32_t op_handle,
+		size_t capacity) = 0;
+
+	virtual psa_status_t key_derivation_input_bytes(
+		uint32_t op_handle,
+		psa_key_derivation_step_t step,
+		const uint8_t *data, size_t data_length) = 0;
+
+	virtual psa_status_t key_derivation_input_key(
+		uint32_t op_handle,
+		psa_key_derivation_step_t step,
+		psa_key_id_t key) = 0;
+
+	virtual psa_status_t key_derivation_output_bytes(
+		uint32_t op_handle,
+		uint8_t *output, size_t output_length) = 0;
+
+	virtual psa_status_t key_derivation_output_key(
+		const psa_key_attributes_t *attributes,
+		uint32_t op_handle,
+		psa_key_id_t *key) = 0;
+
+	virtual psa_status_t key_derivation_abort(
+		uint32_t op_handle) = 0;
+
+	virtual psa_status_t key_derivation_key_agreement(
+		uint32_t op_handle,
+		psa_key_derivation_step_t step,
+		psa_key_id_t private_key,
+		const uint8_t *peer_key, size_t peer_key_length) = 0;
+
+	virtual psa_status_t raw_key_agreement(psa_algorithm_t alg,
+		psa_key_id_t private_key,
+		const uint8_t *peer_key, size_t peer_key_length,
+		uint8_t *output, size_t output_size, size_t *output_length) = 0;
 
 protected:
 	crypto_client();
diff --git a/components/service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.cpp b/components/service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.cpp
index 694d9a0..4d9d8f4 100644
--- a/components/service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.cpp
+++ b/components/service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.cpp
@@ -310,3 +310,91 @@
 	return crypto_caller_mac_abort(&m_client,
 		op_handle);
 }
+
+/* Key derivation methods */
+psa_status_t packedc_crypto_client::key_derivation_setup(
+	uint32_t *op_handle,
+	psa_algorithm_t alg)
+{
+	return crypto_caller_key_derivation_setup(&m_client,
+		op_handle, alg);
+}
+
+psa_status_t packedc_crypto_client::key_derivation_get_capacity(
+	const uint32_t op_handle,
+	size_t *capacity)
+{
+	return crypto_caller_key_derivation_get_capacity(&m_client,
+		op_handle, capacity);
+}
+
+psa_status_t packedc_crypto_client::key_derivation_set_capacity(
+	uint32_t op_handle,
+	size_t capacity)
+{
+	return crypto_caller_key_derivation_set_capacity(&m_client,
+		op_handle, capacity);
+}
+
+psa_status_t packedc_crypto_client::key_derivation_input_bytes(
+	uint32_t op_handle,
+	psa_key_derivation_step_t step,
+	const uint8_t *data, size_t data_length)
+{
+	return crypto_caller_key_derivation_input_bytes(&m_client,
+		op_handle, step, data, data_length);
+}
+
+psa_status_t packedc_crypto_client::key_derivation_input_key(
+	uint32_t op_handle,
+	psa_key_derivation_step_t step,
+	psa_key_id_t key)
+{
+	return crypto_caller_key_derivation_input_key(&m_client,
+		op_handle, step, key);
+}
+
+psa_status_t packedc_crypto_client::key_derivation_output_bytes(
+	uint32_t op_handle,
+	uint8_t *output, size_t output_length)
+{
+	return crypto_caller_key_derivation_output_bytes(&m_client,
+		op_handle, output, output_length);
+}
+
+psa_status_t packedc_crypto_client::key_derivation_output_key(
+	const psa_key_attributes_t *attributes,
+	uint32_t op_handle,
+	psa_key_id_t *key)
+{
+	return crypto_caller_key_derivation_output_key(&m_client,
+		attributes, op_handle, key);
+}
+
+psa_status_t packedc_crypto_client::key_derivation_abort(
+	uint32_t op_handle)
+{
+	return crypto_caller_key_derivation_abort(&m_client,
+		op_handle);
+}
+
+psa_status_t packedc_crypto_client::key_derivation_key_agreement(
+	uint32_t op_handle,
+	psa_key_derivation_step_t step,
+	psa_key_id_t private_key,
+	const uint8_t *peer_key, size_t peer_key_length)
+{
+	return crypto_caller_key_derivation_key_agreement(&m_client,
+		op_handle, step, private_key,
+		peer_key, peer_key_length);
+}
+
+psa_status_t packedc_crypto_client::raw_key_agreement(psa_algorithm_t alg,
+	psa_key_id_t private_key,
+	const uint8_t *peer_key, size_t peer_key_length,
+	uint8_t *output, size_t output_size, size_t *output_length)
+{
+	return crypto_caller_raw_key_agreement(&m_client,
+		alg, private_key, peer_key, peer_key_length,
+		output, output_size, output_length);
+}
diff --git a/components/service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.h b/components/service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.h
index 32dbdc4..377b51d 100644
--- a/components/service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.h
+++ b/components/service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.h
@@ -173,6 +173,52 @@
 	psa_status_t mac_abort(
 		uint32_t op_handle);
 
+	/* Key derivation methods */
+	psa_status_t key_derivation_setup(
+		uint32_t *op_handle,
+		psa_algorithm_t alg);
+
+	psa_status_t key_derivation_get_capacity(
+		const uint32_t op_handle,
+		size_t *capacity);
+
+	psa_status_t key_derivation_set_capacity(
+		uint32_t op_handle,
+		size_t capacity);
+
+	psa_status_t key_derivation_input_bytes(
+		uint32_t op_handle,
+		psa_key_derivation_step_t step,
+		const uint8_t *data, size_t data_length);
+
+	psa_status_t key_derivation_input_key(
+		uint32_t op_handle,
+		psa_key_derivation_step_t step,
+		psa_key_id_t key);
+
+	psa_status_t key_derivation_output_bytes(
+		uint32_t op_handle,
+		uint8_t *output, size_t output_length);
+
+	psa_status_t key_derivation_output_key(
+		const psa_key_attributes_t *attributes,
+		uint32_t op_handle,
+		psa_key_id_t *key);
+
+	psa_status_t key_derivation_abort(
+		uint32_t op_handle);
+
+	psa_status_t key_derivation_key_agreement(
+		uint32_t op_handle,
+		psa_key_derivation_step_t step,
+		psa_key_id_t private_key,
+		const uint8_t *peer_key, size_t peer_key_length);
+
+	psa_status_t raw_key_agreement(psa_algorithm_t alg,
+		psa_key_id_t private_key,
+		const uint8_t *peer_key, size_t peer_key_length,
+		uint8_t *output, size_t output_size, size_t *output_length);
+
 };
 
 #endif /* PACKEDC_CRYPTO_CLIENT_H */
diff --git a/components/service/crypto/client/cpp/protocol/protobuf/protobuf_crypto_client.cpp b/components/service/crypto/client/cpp/protocol/protobuf/protobuf_crypto_client.cpp
index 0941857..e53420f 100644
--- a/components/service/crypto/client/cpp/protocol/protobuf/protobuf_crypto_client.cpp
+++ b/components/service/crypto/client/cpp/protocol/protobuf/protobuf_crypto_client.cpp
@@ -893,3 +893,79 @@
 {
 	return PSA_ERROR_NOT_SUPPORTED;
 }
+
+/* Key derivation methods */
+psa_status_t protobuf_crypto_client::key_derivation_setup(
+	uint32_t *op_handle,
+	psa_algorithm_t alg)
+{
+	return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::key_derivation_get_capacity(
+	const uint32_t op_handle,
+	size_t *capacity)
+{
+	return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::key_derivation_set_capacity(
+	uint32_t op_handle,
+	size_t capacity)
+{
+	return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::key_derivation_input_bytes(
+	uint32_t op_handle,
+	psa_key_derivation_step_t step,
+	const uint8_t *data, size_t data_length)
+{
+	return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::key_derivation_input_key(
+	uint32_t op_handle,
+	psa_key_derivation_step_t step,
+	psa_key_id_t key)
+{
+	return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::key_derivation_output_bytes(
+	uint32_t op_handle,
+	uint8_t *output, size_t output_length)
+{
+	return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::key_derivation_output_key(
+	const psa_key_attributes_t *attributes,
+	uint32_t op_handle,
+	psa_key_id_t *key)
+{
+	return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::key_derivation_abort(
+	uint32_t op_handle)
+{
+	return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::key_derivation_key_agreement(
+	uint32_t op_handle,
+	psa_key_derivation_step_t step,
+	psa_key_id_t private_key,
+	const uint8_t *peer_key, size_t peer_key_length)
+{
+	return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::raw_key_agreement(psa_algorithm_t alg,
+	psa_key_id_t private_key,
+	const uint8_t *peer_key, size_t peer_key_length,
+	uint8_t *output, size_t output_size, size_t *output_length)
+{
+	return PSA_ERROR_NOT_SUPPORTED;
+}
diff --git a/components/service/crypto/client/cpp/protocol/protobuf/protobuf_crypto_client.h b/components/service/crypto/client/cpp/protocol/protobuf/protobuf_crypto_client.h
index e9be6ea..085d9cf 100644
--- a/components/service/crypto/client/cpp/protocol/protobuf/protobuf_crypto_client.h
+++ b/components/service/crypto/client/cpp/protocol/protobuf/protobuf_crypto_client.h
@@ -173,6 +173,51 @@
 	psa_status_t mac_abort(
 		uint32_t op_handle);
 
+	/* Key derivation methods */
+	psa_status_t key_derivation_setup(
+		uint32_t *op_handle,
+		psa_algorithm_t alg);
+
+	psa_status_t key_derivation_get_capacity(
+		const uint32_t op_handle,
+		size_t *capacity);
+
+	psa_status_t key_derivation_set_capacity(
+		uint32_t op_handle,
+		size_t capacity);
+
+	psa_status_t key_derivation_input_bytes(
+		uint32_t op_handle,
+		psa_key_derivation_step_t step,
+		const uint8_t *data, size_t data_length);
+
+	psa_status_t key_derivation_input_key(
+		uint32_t op_handle,
+		psa_key_derivation_step_t step,
+		psa_key_id_t key);
+
+	psa_status_t key_derivation_output_bytes(
+		uint32_t op_handle,
+		uint8_t *output, size_t output_length);
+
+	psa_status_t key_derivation_output_key(
+		const psa_key_attributes_t *attributes,
+		uint32_t op_handle,
+		psa_key_id_t *key);
+
+	psa_status_t key_derivation_abort(
+		uint32_t op_handle);
+
+	psa_status_t key_derivation_key_agreement(
+		uint32_t op_handle,
+		psa_key_derivation_step_t step,
+		psa_key_id_t private_key,
+		const uint8_t *peer_key, size_t peer_key_length);
+
+	psa_status_t raw_key_agreement(psa_algorithm_t alg,
+		psa_key_id_t private_key,
+		const uint8_t *peer_key, size_t peer_key_length,
+		uint8_t *output, size_t output_size, size_t *output_length);
 
 private: