-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.h
175 lines (143 loc) · 8.23 KB
/
auth.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
*********************************************************************************************************
* 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 */