Greenbone Vulnerability Management Libraries: util/passwordbasedauthentication.h File Reference

Greenbone Vulnerability Management Libraries 23.7.0

Data Structures | Macros | Enumerations | Functions
passwordbasedauthentication.h File Reference

Go to the source code of this file.

## Data Structures
struct | PBASettings

## Macros
#define | MAX_PEPPER_SIZE 4
#define | COUNT_DEFAULT 20000
#define | PREFIX_DEFAULT "$6$"

## Enumerations
enum | pba_rc { VALID , UPDATE_RECOMMENDED , INVALID , ERR }

## Functions
struct PBASettings * | pba_init (const char *pepper, unsigned int pepper_size, unsigned int count, char *prefix)
| Init PBA.
char * | pba_hash (struct PBASettings *setting, const char *password)
| Create a password hash.
enum pba_rc | pba_verify_hash (const struct PBASettings *settings, const char *hash, const char *password)
| Verify a password hash.
void | pba_finalize (struct PBASettings *settings)
| Cleanup PBA settings.

## Macro Definition Documentation

## ◆ COUNT_DEFAULT

#define COUNT_DEFAULT 20000

## ◆ MAX_PEPPER_SIZE

#define MAX_PEPPER_SIZE 4

## ◆ PREFIX_DEFAULT

#define PREFIX_DEFAULT "$6$"

## Enumeration Type Documentation

## ◆ pba_rc

enum pba_rc

Enumerator
VALID |
UPDATE_RECOMMENDED |
INVALID |
ERR |

## Function Documentation

## ◆ pba_finalize()

void pba_finalize | ( | struct PBASettings * | settings | ) |

Cleanup PBA settings.

Parameters

  [in] | settings | PBA settings.

## ◆ pba_hash()

char * pba_hash | ( | struct PBASettings * | setting,
|  | const char * | password )

Create a password hash.

pba_hash tries to create a hash based SETTING and PASSWORD. Returns a hash on success or a NULL pointer on failure

Parameters

  [in] | setting | PBA settings.
  [in] | password | Password.

Returns
  Hash. Must be freed with free().

## ◆ pba_init()

struct PBASettings * pba_init | ( | const char * | pepper,
|  | unsigned int | pepper_size,
|  | unsigned int | count,
|  | char * | prefix )

Init PBA.

Intitializes PBASettings with given PEPPER, PREFIX, COUNT.

PEPPER_SIZE must be lower or equal MAX_PEPPER_SIZE when PEPPER is set, when PEPPER is a NULL pointer, no pepper will be used and PEPPER_SIZE is ignored.

COUNT is set to COUNT_DEFAULT when it is 0, PREFIX is set to PREFIX_DEFAULT when prefix is a nullpointer.

Returns a pointer to PBASettings on success or NULL on failure.

Parameters

  [in] | pepper | A static hidden addition to the randomly generated salt.
  [in] | pepper_size | The size of pepper; it must not be larger than MAX_PEPPER_SIZE.
  [in] | count | Number of rounds used to calculate the hash. 0 to use COUNT_DEFAULT.
  [in] | prefix | The algorithm used, if NULL then the most secure available algorithm will be used.

Returns
  Settings, or NULL on error. Free with pba_finalize.

## ◆ pba_verify_hash()

enum pba_rc pba_verify_hash | ( | const struct PBASettings * | setting,
|  | const char * | hash,
|  | const char * | password )

Verify a password hash.

pba_verify_hash tries to create hash based on PASSWORD and settings found via HASH and compares that with HASH.

Returns VALID if HASH and PASSWORD are correct; UPDATE_RECOMMENDED when the HASH and PASSWORD are correct but based on a deprecated algorithm; IVALID if HASH does not match PASSWORD; ERR if an unexpected error occurs.

Parameters

  [in] | setting | PBA settings.
  [in] | hash | Hash.
  [in] | password | Password.

Returns
  Validity. VALID, UPDATE_RECOMMENDED, ...