core/acvp/acvp_proto_interface.h (29 lines of code) (raw):
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#ifndef ACVP_PROTO_INTERFACE_H_
#define ACVP_PROTO_INTERFACE_H_
#include <stddef.h>
#include <stdint.h>
#include "status/rot_status.h"
/**
* ACVP Proto interface.
*/
struct acvp_proto_interface {
/**
* Prepare for an ACVP test.
*
* @param acvp_proto ACVP Proto interface instance.
* @param total_size Total size of the test data to be received.
*
* @return 0 if the device is ready for an ACVP test or an error code.
*/
int (*init_test) (const struct acvp_proto_interface *acvp_proto, size_t total_size);
/**
* Add ACVP test request data.
*
* @param acvp_proto ACVP Proto interface instance.
* @param offset Offset to add test data to.
* @param data Data to add.
* @param length Length of data to add.
*
* @return Length of test data remaining to be received, or an error code. Use ROT_IS_ERROR to
* check the return value.
*/
int (*add_test_data) (const struct acvp_proto_interface *acvp_proto, size_t offset,
const uint8_t *data, size_t length);
/**
* Execute an ACVP test.
*
* @param acvp_proto ACVP Proto interface instance.
*
* @return The number of bytes in the test result response or an error code. Use ROT_IS_ERROR
* to check the return value.
*/
int (*execute_test) (const struct acvp_proto_interface *acvp_proto);
/**
* Retrieve the ACVP test response.
*
* @param acvp_proto ACVP Proto interface instance.
* @param offset Offset to read test results data from.
* @param results Output buffer to be filled with test results data.
* @param length Length of the results buffer.
*
* @return Length of the returned test results or an error code. Use ROT_IS_ERROR to check the
* return value.
*/
int (*get_test_results) (const struct acvp_proto_interface *acvp_proto, size_t offset,
uint8_t *results, size_t length);
};
#define ACVP_PROTO_ERROR(code) ROT_ERROR (ROT_MODULE_ACVP_PROTO, code)
/**
* Error codes that can be generated by the ACVP Proto interface.
*/
enum {
ACVP_PROTO_INVALID_ARGUMENT = ACVP_PROTO_ERROR (0x00), /**< Input parameter is null or not valid. */
ACVP_PROTO_NO_MEMORY = ACVP_PROTO_ERROR (0x01), /**< Memory allocation failed. */
ACVP_PROTO_INIT_NOT_READY = ACVP_PROTO_ERROR (0x02), /**< Device is not ready for an ACVP test. */
ACVP_PROTO_INIT_TOO_LARGE = ACVP_PROTO_ERROR (0x03), /**< Test data size is too large. */
ACVP_PROTO_INIT_FAILED = ACVP_PROTO_ERROR (0x04), /**< Failure during test initialization. */
ACVP_PROTO_ADD_TEST_DATA_TOO_MUCH_DATA = ACVP_PROTO_ERROR (0x05), /**< Attempt to add more data than expected. */
ACVP_PROTO_ADD_TEST_DATA_OFFSET_OUT_OF_RANGE = ACVP_PROTO_ERROR (0x06), /**< The offset for the test data is out of range. */
ACVP_PROTO_ADD_TEST_DATA_FAILED = ACVP_PROTO_ERROR (0x07), /**< Failure while adding test data. */
ACVP_PROTO_EXECUTE_TEST_NOT_READY = ACVP_PROTO_ERROR (0x08), /**< Attempt to execute test before complete test data was received. */
ACVP_PROTO_EXECUTE_TEST_FAILED = ACVP_PROTO_ERROR (0x09), /**< Failure while executing test. */
ACVP_PROTO_GET_TEST_RESULTS_OFFSET_OUT_OF_RANGE = ACVP_PROTO_ERROR (0x0a), /**< The offset for the test results is out of range. */
ACVP_PROTO_GET_TEST_RESULTS_FAILED = ACVP_PROTO_ERROR (0x0b), /**< Failure while getting test results. */
};
#endif /* ACVP_PROTO_INTERFACE_H_ */