| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- /*
- *********************************************************************************************************
- * uC/Common
- * Common Features for Micrium Stacks
- *
- * Copyright 2013-2020 Silicon Laboratories Inc. www.silabs.com
- *
- * SPDX-License-Identifier: APACHE-2.0
- *
- * This software is subject to an open source license and is distributed by
- * Silicon Laboratories Inc. pursuant to the terms of the Apache License,
- * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
- *
- *********************************************************************************************************
- */
- /*
- *********************************************************************************************************
- *
- * uC/Common - Authentication Module (Auth)
- *
- * Filename : auth.h
- * Version : V1.02.00
- *********************************************************************************************************
- */
- /*
- *********************************************************************************************************
- *********************************************************************************************************
- * MODULE
- *
- * Note(s) : (1) This library header file is protected from multiple pre-processor inclusion through
- * use of the library module present pre-processor macro definition.
- *********************************************************************************************************
- *********************************************************************************************************
- */
- #ifndef AUTH_MODULE_PRESENT /* See Note #1. */
- #define AUTH_MODULE_PRESENT
- /*
- *********************************************************************************************************
- *********************************************************************************************************
- * INCLUDE FILES
- *********************************************************************************************************
- *********************************************************************************************************
- */
- #include <lib_mem.h>
- #include "common_err.h"
- /*
- *********************************************************************************************************
- *********************************************************************************************************
- * DEFINES
- *********************************************************************************************************
- *********************************************************************************************************
- */
- #define AUTH_PWD_MAX_LENGTH 32
- #define AUTH_NAME_MAX_LENGTH 32
- #define AUTH_NB_USERS_MAX 10
- #define AUTH_RIGHT_NONE DEF_BIT_NONE
- #define AUTH_RIGHT_0 DEF_BIT_00
- #define AUTH_RIGHT_1 DEF_BIT_01
- #define AUTH_RIGHT_2 DEF_BIT_02
- #define AUTH_RIGHT_3 DEF_BIT_03
- #define AUTH_RIGHT_4 DEF_BIT_04
- #define AUTH_RIGHT_5 DEF_BIT_05
- #define AUTH_RIGHT_6 DEF_BIT_06
- #define AUTH_RIGHT_7 DEF_BIT_07
- #define AUTH_RIGHT_8 DEF_BIT_08
- #define AUTH_RIGHT_9 DEF_BIT_09
- #define AUTH_RIGHT_10 DEF_BIT_10
- #define AUTH_RIGHT_11 DEF_BIT_11
- #define AUTH_RIGHT_12 DEF_BIT_12
- #define AUTH_RIGHT_13 DEF_BIT_13
- #define AUTH_RIGHT_14 DEF_BIT_14
- #define AUTH_RIGHT_15 DEF_BIT_15
- #define AUTH_RIGHT_16 DEF_BIT_16
- #define AUTH_RIGHT_17 DEF_BIT_17
- #define AUTH_RIGHT_18 DEF_BIT_18
- #define AUTH_RIGHT_19 DEF_BIT_19
- #define AUTH_RIGHT_20 DEF_BIT_20
- #define AUTH_RIGHT_21 DEF_BIT_21
- #define AUTH_RIGHT_22 DEF_BIT_22
- #define AUTH_RIGHT_23 DEF_BIT_23
- #define AUTH_RIGHT_24 DEF_BIT_24
- #define AUTH_RIGHT_25 DEF_BIT_25
- #define AUTH_RIGHT_26 DEF_BIT_26
- #define AUTH_RIGHT_27 DEF_BIT_27
- #define AUTH_RIGHT_RSVD_1 DEF_BIT_28
- #define AUTH_RIGHT_RSVD_2 DEF_BIT_29
- #define AUTH_RIGHT_MNG DEF_BIT_30
- #define AUTH_RIGHT_ROOT DEF_BIT_31
- /*
- *********************************************************************************************************
- *********************************************************************************************************
- * DATA TYPES
- *********************************************************************************************************
- *********************************************************************************************************
- */
- typedef CPU_INT32U AUTH_RIGHT; /* Auth right is a 32-bit bitmap. */
- typedef struct auth_user { /* --------------------- AUTH USER -------------------- */
- CPU_CHAR Name[AUTH_NAME_MAX_LENGTH]; /* Name of the user. */
- AUTH_RIGHT Rights; /* Rights associated to this user. */
- } AUTH_USER;
- /*
- *********************************************************************************************************
- *********************************************************************************************************
- * GLOBAL VARIABLES
- *********************************************************************************************************
- *********************************************************************************************************
- */
- extern AUTH_USER Auth_RootUser;
- /*
- *********************************************************************************************************
- *********************************************************************************************************
- * FUNCTION PROTOTYPES
- *********************************************************************************************************
- *********************************************************************************************************
- */
- CPU_BOOLEAN Auth_Init ( RTOS_ERR *p_err);
- CPU_BOOLEAN Auth_CreateUser (const CPU_CHAR *p_name,
- const CPU_CHAR *p_pwd,
- AUTH_USER *p_user,
- RTOS_ERR *p_err);
- CPU_BOOLEAN Auth_GetUser (const CPU_CHAR *p_name,
- AUTH_USER *p_user,
- RTOS_ERR *p_err);
- CPU_BOOLEAN Auth_ValidateCredentials (const CPU_CHAR *p_name,
- const CPU_CHAR *p_pwd,
- AUTH_USER *p_user,
- RTOS_ERR *p_err);
- CPU_BOOLEAN Auth_GrantRight ( AUTH_RIGHT right,
- AUTH_USER *p_user,
- AUTH_USER *p_as_user,
- RTOS_ERR *p_err);
- CPU_BOOLEAN Auth_RevokeRight ( AUTH_RIGHT right,
- AUTH_USER *p_user,
- AUTH_USER *p_as_user,
- RTOS_ERR *p_err);
- /*
- *********************************************************************************************************
- *********************************************************************************************************
- * MODULE END
- *********************************************************************************************************
- *********************************************************************************************************
- */
- #endif /* AUTH_MODULE_PRESENT */
|