Add MAC service level tests
Adds end-to-end service tests for MAC operations provided
by a crypto provider.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I037f0b88348bcbd9bad367230509e72f41351ac6
diff --git a/components/service/crypto/client/cpp/crypto_client.h b/components/service/crypto/client/cpp/crypto_client.h
index 2b5a0f0..eb30655 100644
--- a/components/service/crypto/client/cpp/crypto_client.h
+++ b/components/service/crypto/client/cpp/crypto_client.h
@@ -148,6 +148,35 @@
virtual psa_status_t cipher_abort(
uint32_t op_handle) = 0;
+ /* MAC methods */
+ virtual size_t mac_max_update_size() const = 0;
+
+ virtual psa_status_t mac_sign_setup(
+ uint32_t *op_handle,
+ psa_key_id_t key,
+ psa_algorithm_t alg) = 0;
+
+ virtual psa_status_t mac_verify_setup(
+ uint32_t *op_handle,
+ psa_key_id_t key,
+ psa_algorithm_t alg) = 0;
+
+ virtual psa_status_t mac_update(
+ uint32_t op_handle,
+ const uint8_t *input, size_t input_length) = 0;
+
+ virtual psa_status_t mac_sign_finish(
+ uint32_t op_handle,
+ uint8_t *mac, size_t mac_size, size_t *mac_length) = 0;
+
+ virtual psa_status_t mac_verify_finish(
+ uint32_t op_handle,
+ const uint8_t *mac, size_t mac_length) = 0;
+
+ virtual psa_status_t mac_abort(
+ uint32_t op_handle) = 0;
+
+
protected:
crypto_client();
crypto_client(struct rpc_caller *caller);
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 edcac7b..694d9a0 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
@@ -255,3 +255,58 @@
return crypto_caller_cipher_abort(&m_client,
op_handle);
}
+
+/* MAC methods */
+size_t packedc_crypto_client::mac_max_update_size() const
+{
+ return crypto_caller_mac_max_update_size(&m_client);
+}
+
+psa_status_t packedc_crypto_client::mac_sign_setup(
+ uint32_t *op_handle,
+ psa_key_id_t key,
+ psa_algorithm_t alg)
+{
+ return crypto_caller_mac_sign_setup(&m_client,
+ op_handle, key, alg);
+}
+
+psa_status_t packedc_crypto_client::mac_verify_setup(
+ uint32_t *op_handle,
+ psa_key_id_t key,
+ psa_algorithm_t alg)
+{
+ return crypto_caller_mac_verify_setup(&m_client,
+ op_handle, key, alg);
+}
+
+psa_status_t packedc_crypto_client::mac_update(
+ uint32_t op_handle,
+ const uint8_t *input, size_t input_length)
+{
+ return crypto_caller_mac_update(&m_client,
+ op_handle, input, input_length);
+}
+
+psa_status_t packedc_crypto_client::mac_sign_finish(
+ uint32_t op_handle,
+ uint8_t *mac, size_t mac_size, size_t *mac_length)
+{
+ return crypto_caller_mac_sign_finish(&m_client,
+ op_handle, mac, mac_size, mac_length);
+}
+
+psa_status_t packedc_crypto_client::mac_verify_finish(
+ uint32_t op_handle,
+ const uint8_t *mac, size_t mac_length)
+{
+ return crypto_caller_mac_verify_finish(&m_client,
+ op_handle, mac, mac_length);
+}
+
+psa_status_t packedc_crypto_client::mac_abort(
+ uint32_t op_handle)
+{
+ return crypto_caller_mac_abort(&m_client,
+ op_handle);
+}
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 9c30372..32dbdc4 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
@@ -145,6 +145,34 @@
psa_status_t cipher_abort(
uint32_t op_handle);
+ /* MAC methods */
+ size_t mac_max_update_size() const;
+
+ psa_status_t mac_sign_setup(
+ uint32_t *op_handle,
+ psa_key_id_t key,
+ psa_algorithm_t alg);
+
+ psa_status_t mac_verify_setup(
+ uint32_t *op_handle,
+ psa_key_id_t key,
+ psa_algorithm_t alg);
+
+ psa_status_t mac_update(
+ uint32_t op_handle,
+ const uint8_t *input, size_t input_length);
+
+ psa_status_t mac_sign_finish(
+ uint32_t op_handle,
+ uint8_t *mac, size_t mac_size, size_t *mac_length);
+
+ psa_status_t mac_verify_finish(
+ uint32_t op_handle,
+ const uint8_t *mac, size_t mac_length);
+
+ psa_status_t mac_abort(
+ uint32_t op_handle);
+
};
#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 6c0fe76..0941857 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
@@ -844,3 +844,52 @@
{
return PSA_ERROR_NOT_SUPPORTED;
}
+
+/* MAC methods */
+size_t protobuf_crypto_client::mac_max_update_size() const
+{
+ return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::mac_sign_setup(
+ uint32_t *op_handle,
+ psa_key_id_t key,
+ psa_algorithm_t alg)
+{
+ return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::mac_verify_setup(
+ uint32_t *op_handle,
+ psa_key_id_t key,
+ psa_algorithm_t alg)
+{
+ return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::mac_update(
+ uint32_t op_handle,
+ const uint8_t *input, size_t input_length)
+{
+ return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::mac_sign_finish(
+ uint32_t op_handle,
+ uint8_t *mac, size_t mac_size, size_t *mac_length)
+{
+ return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::mac_verify_finish(
+ uint32_t op_handle,
+ const uint8_t *mac, size_t mac_length)
+{
+ return PSA_ERROR_NOT_SUPPORTED;
+}
+
+psa_status_t protobuf_crypto_client::mac_abort(
+ uint32_t op_handle)
+{
+ 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 d152f04..e9be6ea 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
@@ -145,6 +145,34 @@
psa_status_t cipher_abort(
uint32_t op_handle);
+ /* MAC methods */
+ size_t mac_max_update_size() const;
+
+ psa_status_t mac_sign_setup(
+ uint32_t *op_handle,
+ psa_key_id_t key,
+ psa_algorithm_t alg);
+
+ psa_status_t mac_verify_setup(
+ uint32_t *op_handle,
+ psa_key_id_t key,
+ psa_algorithm_t alg);
+
+ psa_status_t mac_update(
+ uint32_t op_handle,
+ const uint8_t *input, size_t input_length);
+
+ psa_status_t mac_sign_finish(
+ uint32_t op_handle,
+ uint8_t *mac, size_t mac_size, size_t *mac_length);
+
+ psa_status_t mac_verify_finish(
+ uint32_t op_handle,
+ const uint8_t *mac, size_t mac_length);
+
+ psa_status_t mac_abort(
+ uint32_t op_handle);
+
private: