#ifndef TZ_SPAY_MSK_MSG_H_
#define TZ_SPAY_MSK_MSG_H_
#include "stdint.h"
#include "tz_msg.h"
#include "ta_log.h"

#define CMD_SPAY_MOVE_SERVICE_KEY	0x7FFFFFF3

#define TZ_SPAY_MSK_NO_ERROR 0x0
#define TZ_SPAY_MSK_NO_ERROR_STR "Success"

#define TZ_SPAY_MSK_PARAM_ERROR 0x1
#define TZ_SPAY_MSK_PARAM_ERROR_STR "Invalid params from NW"

#define TZ_SPAY_MSK_DECAP_ERROR 0x2
#define TZ_SPAY_MSK_DECAP_ERROR_STR "Could not decapsulate SKMM buffer"

#define TZ_SPAY_MSK_WRAP_ERROR 0x3
#define TZ_SPAY_MSK_WRAP_ERROR_STR "Could not custom wrap buffer"

#define TZ_SPAY_MSK_UNKNOWN_ERROR 0x4
#define TZ_SPAY_MSK_UNKNOWN_ERROR_STR "Unknown error"

#define TZ_SPAY_MAX_SK_LEN	8192
#define TZ_SPAY_MAX_ERROR_STR_LEN	TA_MAX_ERROR_STR_LEN

typedef struct tz_spay_msk_msg_cmd {
	struct {
		uint32_t len;
		uint8_t blob[TZ_SPAY_MAX_SK_LEN];
	} __attribute__ ((packed)) skmm_encap_msg;
} __attribute__ ((packed)) tz_spay_msk_msg_cmd_t;

typedef struct tz_spay_msk_msg_resp {
	uint32_t return_code;
	struct {
		uint32_t len;
		uint8_t data[TZ_SPAY_MAX_ERROR_STR_LEN];
	} __attribute__ ((packed)) error_msg;
	struct {
		uint32_t len;
		uint8_t blob[TZ_SPAY_MAX_SK_LEN];
	} __attribute__ ((packed)) wrapped_msg;
} __attribute__ ((packed)) tz_spay_msk_msg_resp_t;

typedef struct tz_spay_msk_msg_payload {
	union {
		tz_spay_msk_msg_cmd_t cmd;
		tz_spay_msk_msg_resp_t resp;
	} __attribute__ ((packed)) payload;
} __attribute__ ((packed)) tz_spay_msk_msg_payload_t;

#endif /* TZ_SPAY_MSK_MSG_H_ */
