|
Greenbone Vulnerability Management Libraries 22.32.0
|
#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) |
| Check if a prefix is supported. | |
| static int | get_random (char *buf, size_t buflen) |
| Try to get random bytes. | |
| char * | crypt_gensalt_r (const char *prefix, unsigned long count, const char *rbytes, int nrbytes, char *output, int output_size) |
| Generate string suitable for use as setting when hashing a passphrase. | |
| struct PBASettings * | pba_init (const char *pepper, unsigned int pepper_size, unsigned int count, char *prefix) |
| Init PBA. | |
| void | pba_finalize (struct PBASettings *settings) |
| Cleanup PBA settings. | |
| static int | pba_is_phc_compliant (const char *setting) |
| Check if a PBA settings is PHC compliant. | |
| char * | pba_hash (struct PBASettings *setting, const char *password) |
| Create a password hash. | |
| enum pba_rc | pba_verify_hash (const struct PBASettings *setting, const char *hash, const char *password) |
| Verify a password hash. | |
Variables | |
| const char | ascii64 [] |
| #define __USE_GNU |
Definition at line 16 of file passwordbasedauthentication.c.
| #define CRYPT_GENSALT_OUTPUT_SIZE 192 |
Definition at line 24 of file passwordbasedauthentication.c.
Referenced by pba_hash().
| #define CRYPT_OUTPUT_SIZE 384 |
Definition at line 28 of file passwordbasedauthentication.c.
Referenced by pba_hash(), and pba_verify_hash().
| #define INVALID_HASH "1234567890$" |
Definition at line 22 of file passwordbasedauthentication.c.
Referenced by pba_verify_hash().
| char * crypt_gensalt_r | ( | const char * | prefix, |
| unsigned long | count, | ||
| const char * | rbytes, | ||
| int | nrbytes, | ||
| char * | output, | ||
| int | output_size ) |
Generate string suitable for use as setting when hashing a passphrase.
If prefix is a NULL pointer, the current best default is used; if rbytes is a NULL pointer, random data will be retrieved from the operating system if possible.
| [in] | prefix | Controls which hash function will be used. |
| [in] | count | Controls the computional cost of the hash. |
| [in] | rbytes | Should point to nrbytes bytes of random data. |
| [in] | nrbytes | Number of bytes in rbytes. |
| [out] | output | The generated setting string is written here. |
| [in] | output_size | Length of output. Must be at least CRYPT_GENSALT_OUTPUT_SIZE. |
output, else NULL. Definition at line 104 of file passwordbasedauthentication.c.
References ascii64, get_random(), is_prefix_supported(), and PREFIX_DEFAULT.
Referenced by pba_hash().


|
static |
Try to get random bytes.
| [in] | buf | Destination for bytes. |
| [in] | buflen | Number of bytes to get. |
Definition at line 63 of file passwordbasedauthentication.c.
Referenced by crypt_gensalt_r().

|
static |
Check if a prefix is supported.
| [in] | id | Prefix. |
Definition at line 39 of file passwordbasedauthentication.c.
References PREFIX_DEFAULT.
Referenced by crypt_gensalt_r(), pba_hash(), pba_init(), and pba_verify_hash().

| void pba_finalize | ( | struct PBASettings * | settings | ) |
Cleanup PBA settings.
| [in] | settings | PBA settings. |
Definition at line 189 of file passwordbasedauthentication.c.
Referenced by Ensure(), Ensure(), and Ensure().

| char * pba_hash | ( | struct PBASettings * | setting, |
| const char * | password ) |
Create a password hash.
| [in] | setting | PBA settings. |
| [in] | password | Password. |
Definition at line 220 of file passwordbasedauthentication.c.
References PBASettings::count, CRYPT_GENSALT_OUTPUT_SIZE, crypt_gensalt_r(), CRYPT_OUTPUT_SIZE, is_prefix_supported(), MAX_PEPPER_SIZE, PBASettings::pepper, and PBASettings::prefix.
Referenced by Ensure(), Ensure(), Ensure(), and Ensure().


| struct PBASettings * pba_init | ( | const char * | pepper, |
| unsigned int | pepper_size, | ||
| unsigned int | count, | ||
| char * | prefix ) |
Init PBA.
| [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. |
Definition at line 165 of file passwordbasedauthentication.c.
References PBASettings::count, COUNT_DEFAULT, is_prefix_supported(), MAX_PEPPER_SIZE, PBASettings::pepper, PBASettings::prefix, and PREFIX_DEFAULT.
Referenced by Ensure(), Ensure(), and Ensure().


|
static |
Check if a PBA settings is PHC compliant.
| [in] | setting | Setting. |
Definition at line 202 of file passwordbasedauthentication.c.
Referenced by Ensure(), Ensure(), and pba_verify_hash().

| enum pba_rc pba_verify_hash | ( | const struct PBASettings * | setting, |
| const char * | hash, | ||
| const char * | password ) |
Verify a password hash.
| [in] | setting | PBA settings. |
| [in] | hash | Hash. |
| [in] | password | Password. |
Definition at line 276 of file passwordbasedauthentication.c.
References CRYPT_OUTPUT_SIZE, ERR, gvm_auth_init(), gvm_authenticate_classic(), initialized, INVALID, INVALID_HASH, is_prefix_supported(), MAX_PEPPER_SIZE, pba_is_phc_compliant(), PBASettings::pepper, PBASettings::prefix, UPDATE_RECOMMENDED, and VALID.
Referenced by Ensure(), Ensure(), and Ensure().


| const char ascii64[] |
Definition at line 51 of file passwordbasedauthentication.c.
Referenced by crypt_gensalt_r().