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