gsasl  2.2.1
Macros | Functions
crypto.c File Reference
#include <config.h>
#include "internal.h"
#include "mechtools.h"
#include "gc.h"

Go to the source code of this file.

Macros

#define CLIENT_KEY   "Client Key"
 
#define SERVER_KEY   "Server Key"
 

Functions

int gsasl_nonce (char *data, size_t datalen)
 
int gsasl_random (char *data, size_t datalen)
 
size_t gsasl_hash_length (Gsasl_hash hash)
 
int gsasl_scram_secrets_from_salted_password (Gsasl_hash hash, const char *salted_password, char *client_key, char *server_key, char *stored_key)
 
int gsasl_scram_secrets_from_password (Gsasl_hash hash, const char *password, unsigned int iteration_count, const char *salt, size_t saltlen, char *salted_password, char *client_key, char *server_key, char *stored_key)
 

Macro Definition Documentation

◆ CLIENT_KEY

#define CLIENT_KEY   "Client Key"

◆ SERVER_KEY

#define SERVER_KEY   "Server Key"

Function Documentation

◆ gsasl_hash_length()

size_t gsasl_hash_length ( Gsasl_hash  hash)

gsasl_hash_length:

Parameters
hasha Gsasl_hash element, e.g., GSASL_HASH_SHA256.

Return the digest output size for hash function @hash. For example, gsasl_hash_length(GSASL_HASH_SHA256) returns GSASL_HASH_SHA256_SIZE which is 32.

Returns: size of supplied Gsasl_hash element.

Since: 1.10

Definition at line 73 of file crypto.c.

◆ gsasl_nonce()

int gsasl_nonce ( char *  data,
size_t  datalen 
)

gsasl_nonce:

Parameters
dataoutput array to be filled with unpredictable random data.
datalensize of output array.

Store unpredictable data of given size in the provided buffer.

Return value: Returns GSASL_OK iff successful.

Definition at line 39 of file crypto.c.

◆ gsasl_random()

int gsasl_random ( char *  data,
size_t  datalen 
)

gsasl_random:

Parameters
dataoutput array to be filled with strong random data.
datalensize of output array.

Store cryptographically strong random data of given size in the provided buffer.

Return value: Returns GSASL_OK iff successful.

Definition at line 55 of file crypto.c.

◆ gsasl_scram_secrets_from_password()

int gsasl_scram_secrets_from_password ( Gsasl_hash  hash,
const char *  password,
unsigned int  iteration_count,
const char *  salt,
size_t  saltlen,
char *  salted_password,
char *  client_key,
char *  server_key,
char *  stored_key 
)

gsasl_scram_secrets_from_password:

Parameters
hasha Gsasl_hash element, e.g., GSASL_HASH_SHA256.
passwordinput parameter with password.
iteration_countnumber of PBKDF2 rounds to apply.
saltinput character array of @saltlen length with salt for PBKDF2.
saltlenlength of @salt.
salted_passwordpre-allocated output array with derived salted password.
client_keypre-allocated output array with derived client key.
server_keypre-allocated output array with derived server key.
stored_keypre-allocated output array with derived stored key.

Helper function to generate SCRAM secrets from a password. The @salted_password, @client_key, @server_key, and @stored_key buffers must have room to hold digest for given @hash, use GSASL_HASH_MAX_SIZE which is sufficient for all hashes.

Return value: Returns GSASL_OK if successful, or error code.

Since: 1.10

Definition at line 156 of file crypto.c.

◆ gsasl_scram_secrets_from_salted_password()

int gsasl_scram_secrets_from_salted_password ( Gsasl_hash  hash,
const char *  salted_password,
char *  client_key,
char *  server_key,
char *  stored_key 
)

gsasl_scram_secrets_from_salted_password:

Parameters
hasha Gsasl_hash element, e.g., GSASL_HASH_SHA256.
salted_passwordinput array with salted password.
client_keypre-allocated output array with derived client key.
server_keypre-allocated output array with derived server key.
stored_keypre-allocated output array with derived stored key.

Helper function to derive SCRAM ClientKey/ServerKey/StoredKey. The @client_key, @server_key, and @stored_key buffers must have room to hold digest for given @hash, use GSASL_HASH_MAX_SIZE which is sufficient for all hashes.

Return value: Returns GSASL_OK if successful, or error code.

Since: 1.10

Definition at line 104 of file crypto.c.