]>
Commit | Line | Data |
---|---|---|
6b945d70 LP |
1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
2 | #pragma once | |
3 | ||
4 | #include "strv.h" | |
5 | #include "user-record.h" | |
6 | ||
7 | typedef struct PasswordCache { | |
d26cdde3 LP |
8 | /* Passwords acquired from the kernel keyring */ |
9 | char **keyring_passswords; | |
10 | ||
6b945d70 LP |
11 | /* Decoding passwords from security tokens is expensive and typically requires user interaction, |
12 | * hence cache any we already figured out. */ | |
13 | char **pkcs11_passwords; | |
14 | char **fido2_passwords; | |
15 | } PasswordCache; | |
16 | ||
17 | void password_cache_free(PasswordCache *cache); | |
18 | ||
19 | static inline bool password_cache_contains(const PasswordCache *cache, const char *p) { | |
20 | if (!cache) | |
21 | return false; | |
22 | ||
d26cdde3 LP |
23 | return strv_contains(cache->pkcs11_passwords, p) || |
24 | strv_contains(cache->fido2_passwords, p) || | |
25 | strv_contains(cache->keyring_passswords, p); | |
6b945d70 | 26 | } |
d26cdde3 LP |
27 | |
28 | void password_cache_load_keyring(UserRecord *h, PasswordCache *cache); |