Greenbone Vulnerability Management Libraries 21.4.1
passwordbasedauthentication.h
Go to the documentation of this file.
1/* Copyright (C) 2020-2021 Greenbone Networks GmbH
2 *
3 * SPDX-License-Identifier: GPL-3.0-or-later
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef _GVM_PASSWORDBASEDAUTHENTICATION_H
19#define _GVM_PASSWORDBASEDAUTHENTICATION_H
20
21/* max amount of applied pepper */
22#define MAX_PEPPER_SIZE 4
23/* is used when count is 0 on init*/
24#define COUNT_DEFAULT 20000
25/* sha512 */
26#define PREFIX_DEFAULT "$6$"
27
35{
36 char pepper[MAX_PEPPER_SIZE]; /* is statically applied to the random salt */
37 unsigned int count; /* controls the computational cost of the hash */
38 char *prefix; /* controls which hash function will be used */
39};
52struct PBASettings *
53pba_init (const char *pepper, unsigned int pepper_size, unsigned int count,
54 char *prefix);
55
56/* return values for pba pba_verify_hash */
58{
59 VALID, /* hash and password are correct */
60 UPDATE_RECOMMENDED, /* password is correct but in an outdated format*/
61 INVALID, /* password is incorrect */
62 ERR, /* unexpected error */
63};
64
69char *
70pba_hash (struct PBASettings *setting, const char *password);
71
81enum pba_rc
82pba_verify_hash (const struct PBASettings *settings, const char *hash,
83 const char *password);
84
85void
86pba_finalize (struct PBASettings *settings);
87
88#endif
void pba_finalize(struct PBASettings *settings)
Definition: passwordbasedauthentication.c:161
enum pba_rc pba_verify_hash(const struct PBASettings *settings, const char *hash, const char *password)
Definition: passwordbasedauthentication.c:224
char * pba_hash(struct PBASettings *setting, const char *password)
Definition: passwordbasedauthentication.c:177
struct PBASettings * pba_init(const char *pepper, unsigned int pepper_size, unsigned int count, char *prefix)
Definition: passwordbasedauthentication.c:142
pba_rc
Definition: passwordbasedauthentication.h:58
@ ERR
Definition: passwordbasedauthentication.h:62
@ VALID
Definition: passwordbasedauthentication.h:59
@ UPDATE_RECOMMENDED
Definition: passwordbasedauthentication.h:60
@ INVALID
Definition: passwordbasedauthentication.h:61
#define MAX_PEPPER_SIZE
Definition: passwordbasedauthentication.h:22
Definition: passwordbasedauthentication.h:35
char pepper[MAX_PEPPER_SIZE]
Definition: passwordbasedauthentication.h:36
char * prefix
Definition: passwordbasedauthentication.h:38
unsigned int count
Definition: passwordbasedauthentication.h:37