opsick
user.h
Go to the documentation of this file.
1/*
2 Copyright 2020 Raphael Beck
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef OPSICK_USER_H
18#define OPSICK_USER_H
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
30#include <stdint.h>
31#include <cecies/types.h>
32
37{
41 uint64_t id;
42
46 char pw[256];
47
51 char totps[48 + 1];
52
56 uint64_t iat_utc;
57
61 uint64_t exp_utc;
62
66 uint64_t lastmod_utc;
67
71 char body_sha512[128 + 1];
72
76 struct cecies_curve25519_key public_key_ed25519;
77
82
86 struct cecies_curve448_key public_key_curve448;
87
92};
93
99static inline int opsick_user_has_2fa_enabled(struct opsick_user_metadata* user_metadata)
100{
101 if (!user_metadata)
102 {
103 return 0;
104 }
105
106 for (int i = 0; i < sizeof(user_metadata->totps); i++)
107 {
108 if (user_metadata->totps[i] != '\0')
109 {
110 return 1;
111 }
112 }
113
114 return 0;
115}
116
117#ifdef __cplusplus
118} // extern "C"
119#endif
120
121#endif // OPSICK_USER_H
Definition: user.h:37
struct cecies_curve25519_key public_key_ed25519
Definition: user.h:76
uint64_t iat_utc
Definition: user.h:56
uint64_t lastmod_utc
Definition: user.h:66
char totps[48+1]
Definition: user.h:51
char encrypted_private_key_ed25519[256]
Definition: user.h:81
char pw[256]
Definition: user.h:46
uint64_t id
Definition: user.h:41
uint64_t exp_utc
Definition: user.h:61
char encrypted_private_key_curve448[256]
Definition: user.h:91
char body_sha512[128+1]
Definition: user.h:71
struct cecies_curve448_key public_key_curve448
Definition: user.h:86
static int opsick_user_has_2fa_enabled(struct opsick_user_metadata *user_metadata)
Definition: user.h:99