#ifndef DK_CMD_SCP_INITIALIZE_UPDATE_H
#define DK_CMD_SCP_INITIALIZE_UPDATE_H

#include <sec_apdu.h>

#include "dk_common.h"
#include "dk_scp_common.h"

DK_Result process_initialize_update();

/**
 * Generates an APDU with the Initialize Update command.
 * 
 * @param ctx The SCP context
 * @param cla The CLA byte for the APDU
 * @param key_version_number The current KVN used internally by the eSE SCP implementation
 * @param cpdu A buffer that will hold the command APDU
 * @param cpdu_len The length of the generated command APDU buffer
 * 
 * @return DK_SUCCESS on success, an error code otherwise
*/
DK_Result generate_initialize_update_cpdu(
    scp_context *ctx, 
    byte cla, 
    byte key_version_number, 
    byte *cpdu, 
    size_t *cpdu_len);

/**
 * Handles the response of the External Authenticate command.
 * 
 * @param ctx The SCP context
 * @param rpdu A buffer containing the response APDU
 * @param rpdu_len The length of the RPDU buffer
 * 
 * @return DK_SUCCESS on success, an error code otherwise
*/
DK_Result handle_initialize_update_rpdu(
    scp_context *ctx, 
    byte *rpdu, 
    size_t rpdu_len);

#ifdef DK_DEBUG
byte (*test_get_security_level_from_i)(byte i);
byte mock_get_security_level_from_i(byte i);
byte mock_get_security_level_from_i_full(byte i);
#endif

#endif