avr-fw-modules/core/src/access_authorize.c

56 lines
998 B
C
Executable File

#include <hwo/access.h>
#include <hwo/bits.h>
/**
* @defgroup hwo_core Core-Funktionen des hwo-Systems
* @brief Core-Funktionen.
*
* @{
*/
/**
* @defgroup hwo_core_auth Zugriffsauthorisierung
* @brief Zugriffsauthorisierung.
*
* @{
*/
/*! \brief Prüfen der Zugriffsberechtigung.
*
* Prüft Format der übergebenen Struct access und liefert
* Zugriffsrechte oder Null zurück. Setzt effective_rights-Feld
*/
int32_t access_authorize(struct _access* access)
{
union bits32 bits;
int32_t ac;
if (!access)
return 0;
ac = access->access_code;
bits.i32 = access->service_partner_id;
bits.i32 = rol32(bits.i32,13);
bits.i32 ^= access->staff_id;
bits.i32 = rol32(bits.i32,23);
bits.i32 ^= ac;
bits.i32 = rol32(bits.i32,5);
bits.i32 ^= access->magic1;
bits.i32 = rol32(bits.i32,27);
bits.i32 ^= access->passcode;
if (bits.i32)
access->effective_rights = 0;
else
access->effective_rights = ac;
return access->effective_rights;
};
/** @}
*/
/** @}
*/