/*
 *
 * (c) Copyright 2018 Samsung Research America, Inc.
 *                  All rights reserved
 *
 *                  MCL-B2B Lab
 *
 *
 * File: dualdar_globals.h
 * Author: r.kadir@samsung.com
 * Creation Date: Nov, 2018
 *
 */
/**
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
*
* Mobile Platform & Solutions Lab (MPS Lab),
* Samsung Electronics Co., Ltd.
*
* This software and its documentation are confidential and proprietary
* information of Samsung Electronics Co., Ltd.  No part of the software and
* documents may be copied, reproduced, transmitted, translated, or reduced to
* any electronic medium or machine-readable form without the prior written
* consent of Samsung Electronics.
*
* Samsung Electronics makes no representations with respect to the contents,
* and assumes no responsibility for any errors that might appear in the
* software and documents. This publication and the contents hereof are subject
* to change without notice.
*/

#ifndef DUALDAR_GLOBALS_H_
#define DUALDAR_GLOBALS_H_

#include "dualdar_api.h"
#include "dualdar_crypto_tl.h"
#include "DDAR_TZ_Vendor_tl.h"

//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////

#define WRAP_KEY_LEN			256
#define MAX_CRYPTO_LEN			8

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////

typedef struct tmp_data_ {
	tciMessage_t secureReqMsg;
	tciMessage_t secureRespMsg;

	uint8_t tmpCryptoBuf[DUALDAR_MAX_CRYPTO_TEMPBUF_SIZE];

    uint8_t tmpPassword[MAX_PASSWORD_LEN];
	uint8_t tmpEMasterKey[MAX_EMASTERKEY_LEN];
	uint8_t tmpMasterKey[MAX_MASTERKEY_LEN];
	uint8_t tmpSalt[MAX_WSALT_LEN];

	// Test Data // Do not commit this
#ifdef LOCAL_ECDH_TEST
    uint8_t ecdhpub1[MAX_ECDH_PUB_KEY_LEN];
    uint8_t ecdhpub2[MAX_ECDH_PUB_KEY_LEN];
    uint8_t secret1[MAX_ECDH_SESSION_KEY_LEN];
    uint8_t secret2[MAX_ECDH_SESSION_KEY_LEN];
    uint8_t testdata[9];
    uint8_t testedata[1024];
    void *ecdhlocalkey1;
    void *ecdhlocalkey2;
#endif

} __attribute__ ((packed)) tmp_data_t;

typedef struct dualdar_data_ {

	uint32_t initialized;

	tmp_data_t tmp_data;
	// These are temporary information that is invalid after every command

    void *ecdhlocalkey;
    uint8_t localecdhpub[MAX_ECDH_PUB_KEY_LEN];
    uint32_t localecdhpub_len;
    uint8_t remoteecdhpub[MAX_ECDH_PUB_KEY_LEN];
    uint32_t remoteecdhpub_len;
    uint8_t ecdhsecret[MAX_ECDH_SESSION_KEY_LEN];
    uint32_t ecdhsecret_len;

	char err_msg_buf[DUALDAR_MAX_ERROR_STR_LEN];
	char *err_msg_buf_index;

} __attribute__ ((packed)) dualdar_data_t;

extern dualdar_data_t gDualDarData;

#endif /* DUALDAR_GLOBALS_H_ */