Greenbone Vulnerability Management Libraries 22.12.2
passwordbasedauthentication.c File Reference
#include "passwordbasedauthentication.h"
#include "authutils.c"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <crypt.h>

Go to the source code of this file.

Macros

#define __USE_GNU
 
#define INVALID_HASH   "1234567890$"
 
#define CRYPT_GENSALT_OUTPUT_SIZE   192
 
#define CRYPT_OUTPUT_SIZE   384
 

Functions

static int is_prefix_supported (const char *id)
 
static int get_random (char *buf, size_t buflen)
 
char * crypt_gensalt_r (const char *prefix, unsigned long count, const char *rbytes, int nrbytes, char *output, int output_size)
 
struct PBASettingspba_init (const char *pepper, unsigned int pepper_size, unsigned int count, char *prefix)
 
void pba_finalize (struct PBASettings *settings)
 
static int pba_is_phc_compliant (const char *setting)
 
char * pba_hash (struct PBASettings *setting, const char *password)
 
enum pba_rc pba_verify_hash (const struct PBASettings *setting, const char *hash, const char *password)
 

Variables

const char ascii64 [64]
 

Macro Definition Documentation

◆ __USE_GNU

#define __USE_GNU

◆ CRYPT_GENSALT_OUTPUT_SIZE

#define CRYPT_GENSALT_OUTPUT_SIZE   192

◆ CRYPT_OUTPUT_SIZE

#define CRYPT_OUTPUT_SIZE   384

◆ INVALID_HASH

#define INVALID_HASH   "1234567890$"

Function Documentation

◆ crypt_gensalt_r()

char * crypt_gensalt_r ( const char * prefix,
unsigned long count,
const char * rbytes,
int nrbytes,
char * output,
int output_size )

◆ get_random()

static int get_random ( char * buf,
size_t buflen )
static

◆ is_prefix_supported()

static int is_prefix_supported ( const char * id)
static

◆ pba_finalize()

void pba_finalize ( struct PBASettings * settings)

◆ pba_hash()

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

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

◆ pba_init()

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

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.

◆ pba_is_phc_compliant()

static int pba_is_phc_compliant ( const char * setting)
static

◆ pba_verify_hash()

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

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.

Variable Documentation

◆ ascii64

const char ascii64[64]
Initial value:
=
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"