/*
 *
 * (c) Copyright 2018 Samsung Research America, Inc.
 *                  All rights reserved
 *
 *                  MCL-B2B Lab
 *
 *
 * File: authenticate_cmd_tl.c
 * 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 SCRYPTO_CRYPTO_H
#define SCRYPTO_CRYPTO_H

#define AES256_GCM_TAG_SIZE             16
#define AES256_GCM_IV_SIZE              16

uint32_t DDAR_TZ_pbkdf_hmac256(uint8_t* pwd, uint32_t pwd_len, uint8_t* salt, uint32_t salt_len,
                  uint32_t iterations, uint8_t* out, uint32_t out_len);

uint32_t DDAR_TZ_aes_gcm256_encrypt(uint8_t *plaintext, uint32_t plaintext_len, uint8_t *aad,
			uint32_t aad_len, uint8_t *key, uint8_t *iv,
			uint8_t *ciphertext, uint32_t *ciphertextlen,
			uint8_t *tag);

uint32_t DDAR_TZ_aes_gcm256_decrypt(uint8_t *ciphertext, uint32_t ciphertext_len, uint8_t *aad,
			uint32_t aad_len, uint8_t *tag, uint8_t *key, uint8_t *iv,
			uint8_t *plaintext, uint32_t *plaintextlen);

uint32_t ecdh_sessionkey_gen(void *localkey, uint8_t *pubkey, uint32_t pubkey_len,
        uint8_t *secret, uint32_t *secret_len);

uint32_t ecdh_prep(void **localkey, uint8_t *pubkey, uint32_t *pubkey_len);
void ecdh_keyfree(void *localkey);

uint32_t DDAR_TZ_gen_rand_data(
	uint8_t * randomBuffer,
	uint32_t * randomLen
);

#endif //SCRYPTO_CRYPTO_H
