/**
 * @file       authentication.h
 * @brief      Authentication module
 * @details    Provide authentication NWd process by pid and additional rules
 * @author     Ivan Vorobiov (i.vorobiov@samsung.com)
 * @version    1.0
 * @date       Created Jul 6, 2016
 * @copyright  In Samsung Ukraine R&D Center (SURC) under a contract between
 * @copyright  LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine) and
 * @copyright  "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
 * @copyright  Copyright: (c) Samsung Electronics Co, Ltd 2016. All rights reserved.
**/
#ifndef PA_TZ_DRV_SRC_AUTHENTICATION_H_
#define PA_TZ_DRV_SRC_AUTHENTICATION_H_

#include "pa_tz_api.h"
#include "task.h"

/**
 * @brief Checks rights for signing for current task
 * @param [in] task Task of NWd application that called this API (issuer)
 * @return ::PA_TZ_SUCCESS in case of success, ::PA_TZ_GENERAL_ERROR
 */
PaTzResult CheckIntegritySigningRights(const TaskInfo *task);

/**
 * @brief Checks whether FIVE returns weak status for current task
 * @param [in] task Task of NWd application that called this API (issuer)
 * @return ::PA_TZ_SUCCESS in case of success, ::PA_TZ_GENERAL_ERROR
 */
PaTzResult CheckIntegrityWeak(const TaskInfo *task);

/**
 * @brief Check integration value provided by FIVE
 * @param [in] task Task info
 * @return ::PA_TZ_SUCCESS task is authenticated,
 *         ::PA_TZ_AF_INTEGRITY_IS_NONE task is not authenticated,
 *         ::PA_TZ_AF_INTEGRITY_IS_NOT_READY integrity status has not been defined by FIVE,
 *         ::PA_TZ_GENERAL_ERROR cannot parse extra info
 */
PaTzResult CheckIntegrityValue(const TaskInfo *task);

/**
 * @brief Authenticate process
 * @param [in] task Task info
 * @param [in] process_names Names of the process in the task structure
 * (NULL-terminated string), can be NULL
 * @param [in] process_names_size Size of all process names
 * @param [in] memory Check that memory is owned by process, can be NULL
 * @return ::PA_TZ_SUCCESS if process is authenticated successfully,
 *         ::PA_TZ_AUTHENTICATION_FAILED if process is not authenticated,
 *         ::PA_TZ_GENERAL_ERROR if input parameter is invalid
 */
PaTzResult ProcessAuthentication(const TaskInfo *task, const char *process_names,
                                 const size_t process_names_size,
                                 const PaTzMemoryRange *memory);

#endif /* PA_TZ_DRV_SRC_AUTHENTICATION_H_ */
