[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Libgcrypt makes it possible to install so called `handler functions', which get called by Libgcrypt in case of certain events.
4.1 Progress handler | Using a progress handler function. | |
4.2 Allocation handler | Using special memory allocation functions. | |
4.3 Error handler | Using error handler functions. | |
4.4 Logging handler | Using a special logging function. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
It is often useful to retrieve some feedback while long running operations are performed.
Progress handler functions have to be of the type
gcry_handler_progress_t
, which is defined as:
void (*gcry_handler_progress_t) (void *, const char *, int, int, int)
The following function may be used to register a handler function for this purpose.
This function installs cb as the `Progress handler' function. It may be used only during initialization. cb must be defined as follows:
void my_progress_handler (void *cb_data, const char *what, int printchar, int current, int total) { /* Do something. */ } |
A description of the arguments of the progress handler function follows.
The argument provided in the call to gcry_set_progress_handler
.
A string identifying the type of the progress output. The following values for what are defined:
need_entropy
Not enough entropy is available. total holds the number of required bytes.
primegen
Values for printchar:
\n
Prime generated.
!
Need to refresh the pool of prime numbers.
<, >
Number of bits adjusted.
^
Searching for a generator.
.
Fermat test on 10 candidates failed.
:
Restart with a new random value.
+
Rabin Miller test passed.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
It is possible to make Libgcrypt use special memory allocation functions instead of the built-in ones.
Memory allocation functions are of the following types:
This type is defined as: void *(*gcry_handler_alloc_t) (size_t n)
.
This type is defined as: int *(*gcry_handler_secure_check_t) (const void *)
.
This type is defined as: void *(*gcry_handler_realloc_t) (void *p, size_t n)
.
This type is defined as: void *(*gcry_handler_free_t) (void *)
.
Special memory allocation functions can be installed with the following function:
Install the provided functions and use them instead of the built-in functions for doing memory allocation. Using this function is in general not recommended because the standard Libgcrypt allocation functions are guaranteed to zeroize memory if needed.
This function may be used only during initialization and may not be used in fips mode.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following functions may be used to register handler functions that
are called by Libgcrypt in case certain error conditions occur. They
may and should be registered prior to calling gcry_check_version
.
This type is defined as: int (*gcry_handler_no_mem_t) (void *, size_t, unsigned int)
This function registers func_no_mem as `out-of-core handler', which means that it will be called in the case of not having enough memory available. The handler is called with 3 arguments: The first one is the pointer cb_data as set with this function, the second is the requested memory size and the last being a flag. If bit 0 of the flag is set, secure memory has been requested. The handler should either return true to indicate that Libgcrypt should try again allocating memory or return false to let Libgcrypt use its default fatal error handler.
This type is defined as: void (*gcry_handler_error_t) (void *, int, const char *)
This function registers func_error as `error handler', which means that it will be called in error conditions.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This type is defined as: void (*gcry_handler_log_t) (void *, int, const char *, va_list)
This function registers func_log as `logging handler', which means
that it will be called in case Libgcrypt wants to log a message. This
function may and should be used prior to calling
gcry_check_version
.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by root on November, 19 2009 using texi2html 1.78.