Macros | Enumerations | Functions
DIGEST: Hash algorithms

This module provides optional support for message digest algorithms. It is intended to comply with RFC 3174. More...

Macros

#define MAIN_ERR_PREFIX   "DIGEST: "
 Message prefix for DIGEST module.
 
#define MAIN_ERR_PREFIX   "DIGEST: "
 

Enumerations

enum  digest_alg { DIGEST_ALG_SHA1_160, DIGEST_ALG_SHA2_256 }
 

Functions

int digest_sha1_160 (const char *text, size_t text_len, unsigned char *md)
 Secure Hash Algorithm SHA1-160. More...
 
int digest_sha2_256 (const char *text, size_t text_len, unsigned char *md)
 Secure Hash Algorithm SHA2-256. More...
 
void digest_init (void)
 Initialize message digest module.
 
void digest_exit (void)
 Shutdown message digest module.
 
int digest_randomart (const char *prefix, const char *buf, size_t len)
 Create randomart image of a key. More...
 

Lenght of message digests

#define DIGEST_SHA1_160_LEN   (size_t) 20
 160 bit
 
#define DIGEST_SHA2_256_LEN   (size_t) 32
 256 bit
 

Size of randomart images

#define DIGEST_RA_X   (size_t) 17
 Field width: 17 units.
 
#define DIGEST_RA_Y   (size_t) 9
 Field height: 9 units.
 

Detailed Description

This module provides optional support for message digest algorithms. It is intended to comply with RFC 3174.

Attention
This module currently works only if TLS support is available (because both share the cryptographic functions provided by OpenSSL).

Function Documentation

◆ digest_randomart()

int digest_randomart ( const char *  prefix,
const char *  buf,
size_t  len 
)

Create randomart image of a key.

Parameters
[in]prefixPrefix to prepend for each output line
[in]bufPointer to data buffer
[in]lenLength of data in buffer

The data from buf is hashed with the SHA2-256 algorithm to create a fingerprint. The first 16 bytes of this fingerprint are used to create a randomart image with the drunken bishop algorithm.

Returns
  • 0 on success
  • Negative value on error

Definition at line 180 of file drunken_bishop.c.

References digest_sha2_256(), DIGEST_SHA2_256_LEN, and enc_mime_encode_base64().

◆ digest_sha1_160()

int digest_sha1_160 ( const char *  text,
size_t  text_len,
unsigned char *  md 
)

Secure Hash Algorithm SHA1-160.

Parameters
[in]textMessage
[in]text_lenMessage length
[out]mdMessage digest

The values of paramater text_len must represent bytes.

On success, the result is written to md and has a length of DIGEST_SHA1_160_LEN bytes.

Returns
  • 0 on success
  • -1 on error

Definition at line 159 of file digest.c.

Referenced by core_get_cancel_lock().

◆ digest_sha2_256()

int digest_sha2_256 ( const char *  text,
size_t  text_len,
unsigned char *  md 
)

Secure Hash Algorithm SHA2-256.

Parameters
[in]textMessage
[in]text_lenMessage length
[out]mdMessage digest

The values of paramater text_len must represent bytes.

On success, the result is written to md and has a length of DIGEST_SHA2_256_LEN bytes.

Returns
  • 0 on success
  • -1 on error

Definition at line 182 of file digest.c.

Referenced by core_get_cancel_lock(), and digest_randomart().


Generated at 2024-04-27 using  doxygen