Greenbone Vulnerability Management Libraries 22.18.1
authutils.c File Reference

Authentication mechanism(s). More...

#include "authutils.h"
#include <gcrypt.h>
#include <string.h>

Go to the source code of this file.

Macros

#define G_LOG_DOMAIN   "libgvm util"
 GLib logging domain.
 

Functions

int gvm_auth_ldap_enabled (void)
 Return whether libraries has been compiled with LDAP support.
 
int gvm_auth_radius_enabled (void)
 Return whether libraries has been compiled with RADIUS support.
 
const gchar * auth_method_name (auth_method_t method)
 Return name of auth_method_t.
 
int auth_method_name_valid (const gchar *name)
 Check if name is a valid auth method name.
 
int gvm_auth_init (void)
 Initializes Gcrypt.
 
gchar * digest_hex (int gcrypt_algorithm, const guchar *digest)
 Generate a hexadecimal representation of a message digest.
 
gchar * get_password_hashes (const gchar *password)
 Generate a pair of md5 hashes to be used in the "auth/hash" file for the user.
 
gchar * get_md5_hash_from_string (const gchar *string)
 Calculate the MD5 hash value for a given string.
 
int gvm_authenticate_classic (const gchar *username, const gchar *password, const gchar *hash_arg)
 Authenticate a credential pair against user file contents.
 

Variables

static const gchar * authentication_methods []
 Array of string representations of the supported authentication methods.
 
static gboolean initialized = FALSE
 Flag whether the config file was read.
 

Detailed Description

Authentication mechanism(s).

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "libgvm util"

GLib logging domain.

Function Documentation

◆ auth_method_name()

const gchar * auth_method_name ( auth_method_t method)

Return name of auth_method_t.

Keep in sync with authentication_methods and authentication_method .

Parameters
methodAuth method.
Returns
Name of auth method.

◆ auth_method_name_valid()

int auth_method_name_valid ( const gchar * name)

Check if name is a valid auth method name.

Parameters
nameName of auth method.
Returns
1 if valid, else 0.

◆ digest_hex()

gchar * digest_hex ( int gcrypt_algorithm,
const guchar * digest )

Generate a hexadecimal representation of a message digest.

Parameters
gcrypt_algorithmThe libgcrypt message digest algorithm used to create the digest (e.g. GCRY_MD_MD5; see the enum gcry_md_algos in gcrypt.h).
digestThe binary representation of the digest.
Returns
A pointer to the hexadecimal representation of the message digest or NULL if an unavailable message digest algorithm was selected.

◆ get_md5_hash_from_string()

gchar * get_md5_hash_from_string ( const gchar * string)

Calculate the MD5 hash value for a given string.

Parameters
stringThe String to be hashed
Returns
A pointer to a gchar containing the hash value as a hexadecimal string, has to be freed by the caller.

◆ get_password_hashes()

gchar * get_password_hashes ( const gchar * password)

Generate a pair of md5 hashes to be used in the "auth/hash" file for the user.

The "auth/hash" file consist of two hashes, h_1 and h_2. h_2 (the "seed") is the message digest of (currently) 256 bytes of random data. h_1 is the message digest of h_2 concatenated with the password in plaintext.

Parameters
passwordThe password in plaintext.
Returns
A pointer to a gchar containing the two hashes separated by a space or NULL if an unavailable message digest algorithm was selected.

◆ gvm_auth_init()

int gvm_auth_init ( void )

Initializes Gcrypt.

Returns
0 success, -1 error.

◆ gvm_auth_ldap_enabled()

int gvm_auth_ldap_enabled ( void )

Return whether libraries has been compiled with LDAP support.

Returns
1 if enabled, else 0.

◆ gvm_auth_radius_enabled()

int gvm_auth_radius_enabled ( void )

Return whether libraries has been compiled with RADIUS support.

Returns
1 if enabled, else 0.

◆ gvm_authenticate_classic()

int gvm_authenticate_classic ( const gchar * username,
const gchar * password,
const gchar * hash_arg )

Authenticate a credential pair against user file contents.

Parameters
usernameUsername.
passwordPassword.
hash_argHash.
Returns
0 authentication success, 1 authentication failure, -1 error.

Variable Documentation

◆ authentication_methods

const gchar* authentication_methods[]
static
Initial value:
= {"file", "ldap_connect",
"radius_connect", NULL}

Array of string representations of the supported authentication methods.

Warning
Beware to have it in sync with authentication_method.

◆ initialized

gboolean initialized = FALSE
static

Flag whether the config file was read.