]> git.ozlabs.org Git - petitboot/blob - lib/crypt/crypt.h
lib/crypt: Add helpers for operating on /etc/shadow
[petitboot] / lib / crypt / crypt.h
1 /*
2  *  Copyright (C) 2018 IBM Corporation
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; version 2 of the License.
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU General Public License for more details.
12  *
13  */
14 #ifndef CRYPT_H
15 #define CRYPT_H
16
17 #include "config.h"
18
19 #ifdef CRYPT_SUPPORT
20
21 char *crypt_get_hash(void *ctx);
22 bool crypt_check_password(const char *password);
23 int crypt_set_password(void *ctx, const char *password);
24 int crypt_set_password_hash(void *ctx, const char *hash);
25
26 #else
27
28 static inline char *crypt_get_hash(void *ctx __attribute__((unused)))
29 {
30         return NULL;
31 }
32 static inline bool crypt_check_password(
33                 const char *password __attribute__((unused)))
34 {
35         return false;
36 }
37 static inline int crypt_set_password(void *ctx __attribute__((unused)),
38                 const char *password __attribute__((unused)))
39 {
40         return -1;
41 }
42 static inline int crypt_set_password_hash(void *ctx __attribute__((unused)),
43                 const char *hash __attribute__((unused)))
44 {
45         return -1;
46 }
47
48 #endif
49 #endif /* CRYPT_H */