Next: , Previous: Available hash algorithms, Up: Hashing


7.2 Hash algorithm modules

Libgcrypt makes it possible to load additional `message digest modules'; these digests can be used just like the message digest algorithms that are built into the library directly. For an introduction into extension modules, see See Modules.

— Data type: gcry_md_spec_t

This is the `module specification structure' needed for registering message digest modules, which has to be filled in by the user before it can be used to register a module. It contains the following members:

const char *name
The primary name of this algorithm.
unsigned char *asnoid
Array of bytes that form the ASN OID.
int asnlen
Length of bytes in `asnoid'.
gcry_md_oid_spec_t *oids
A list of OIDs that are to be associated with the algorithm. The list's last element must have it's `oid' member set to NULL. See below for an explanation of this type. See below for an explanation of this type.
int mdlen
Length of the message digest algorithm. See below for an explanation of this type.
gcry_md_init_t init
The function responsible for initializing a handle. See below for an explanation of this type.
gcry_md_write_t write
The function responsible for writing data into a message digest context. See below for an explanation of this type.
gcry_md_final_t final
The function responsible for `finalizing' a message digest context. See below for an explanation of this type.
gcry_md_read_t read
The function responsible for reading out a message digest result. See below for an explanation of this type.
size_t contextsize
The size of the algorithm-specific `context', that should be allocated for each handle.

— Data type: gcry_md_oid_spec_t

This type is used for associating a user-provided algorithm implementation with certain OIDs. It contains the following members:

const char *oidstring
Textual representation of the OID.

— Data type: gcry_md_init_t

Type for the `init' function, defined as: void (*gcry_md_init_t) (void *c)

— Data type: gcry_md_write_t

Type for the `write' function, defined as: void (*gcry_md_write_t) (void *c, unsigned char *buf, size_t nbytes)

— Data type: gcry_md_final_t

Type for the `final' function, defined as: void (*gcry_md_final_t) (void *c)

— Data type: gcry_md_read_t

Type for the `read' function, defined as: unsigned char *(*gcry_md_read_t) (void *c)

— Function: gcry_error_t gcry_md_register (gcry_md_spec_t *digest, unsigned int *algorithm_id, gcry_module_t *module)

Register a new digest module whose specification can be found in digest. On success, a new algorithm ID is stored in algorithm_id and a pointer representing this module is stored in module.

— Function: void gcry_md_unregister (gcry_module_t module)

Unregister the digest identified by module, which must have been registered with gcry_md_register.

— Function: gcry_error_t gcry_md_list (int *list, int *list_length)

Get a list consisting of the IDs of the loaded message digest modules. If list is zero, write the number of loaded message digest modules to list_length and return. If list is non-zero, the first *list_length algorithm IDs are stored in list, which must be of according size. In case there are less message digests modules than *list_length, *list_length is updated to the correct number.