// SPDX-License-Identifier: BSD-2-Clause
/*
 * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 */

#ifndef __JETSON_EKB_EXTRACTION_T264_H__
#define __JETSON_EKB_EXTRACTION_T264_H__
#include "drivers/tegra/tegra_se_keyslot.h"

struct ekb_header {
	uint32_t ekb_size;
	char ekb_magic[8];
	uint16_t ver_maj;
	uint16_t ver_min;
	uint8_t reserved[16];
};

struct ekb_content_header {
	uint32_t enc_data_len;
	char ekb_content_magic[4];
	uint8_t reserved[8];
};

struct ekb_content {
	uint8_t ekb_cmac[TEGRA_SE_AES_BLOCK_SIZE];
	struct ekb_content_header content_header;
	uint8_t random_iv[TEGRA_SE_AES_IV_SIZE];
	uint8_t ekb_ciphertext[0];
};

TEE_Result jetson_derive_keys(void);

TEE_Result jetson_ekb_authenticate_mac(struct ekb_content *ekb);

TEE_Result jetson_ekb_decrypt_content(struct ekb_content *ekb, uint8_t *decrypted_ekb_content);

#endif /* __JETSON_EKB_EXTRACTION_T264_H__ */
