/**
 * @file  tlapi_secdrv_keyman.h
 * @brief tlapi functions for key manager
 *
 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 *
 * This software is proprietary of Samsung Electronics.
 * No part of this software, either material or conceptual may be copied
 * or distributed, transmitted, transcribed, stored in a retrieval system
 * or translated into any human or computer language in any form by any means,
 * electronic, mechanical, manual or otherwise, or disclosed to third parties
 * without the express written permission of Samsung Electronics.
 */

#ifndef __TLAPI_SECDRV_KEYMAN_H__
#define __TLAPI_SECDRV_KEYMAN_H__

#include "TlApi/TlApiCommon.h"
#include "TlApi/TlApiError.h"

enum cipherMode_t {
	ENCRYPT,
	DECRYPT,
};

enum padding_t {
	NO_PADDING,
	PKCS_PADDING,
	CTS_PADDING,
};

enum cache_t {
	CACHEABLE,
	NON_CACHEABLE,
};

enum aesOpMode_t {
	ECB_MODE,
	CBC_MODE,
	CBC_CTS_MODE,
	CTR_MODE,
};

enum addrSpace_t {
	VIRTUAL,
	PHYSICAL,
};

typedef struct cm_data {
	uint8_t *addr;
	size_t	len;
	enum cache_t cache;
	enum addrSpace_t space;
} CM_DATA;

struct secSss_t {
	uint32_t key;
	uint32_t key_len;
	uint32_t iv;
	uint32_t iv_len;
	uint32_t block_offset;
	CM_DATA input;
	CM_DATA output;
	enum aesOpMode_t mode;
	enum cipherMode_t cipher_mode;
	enum padding_t pad;
};

_TLAPI_EXTERN_C tlApiResult_t tlApiDeriveKeyWithREK(
	uint8_t *input_data,  /* input data for keying material */
	size_t input_length,  /* input length of byte unit */
	uint8_t *output_data, /* derived key */
	size_t output_length, /* output length of byte unit */
	uint32_t lifetime);   /* reserved parameter for future use */

_TLAPI_EXTERN_C tlApiResult_t tlApiRunAES(
	struct secSss_t *secSss
);

#endif /* __TLAPI_SECDRV_KEYMAN_H__ */
