#include <openssl/ssl.h>
Go to the source code of this file.
|
void | qdremrand (QDREMRAND *qdr) |
| Initializes a QDREMRAND structure.
|
|
int | qdremrand_verbose (QDREMRAND *qdr, int verbose) |
| Sets the verbose flag for a QDREMRAND instance.
|
|
int | qdremrand_connect (QDREMRAND *qdr, const char *rem_host, const char *rem_port, const char *peer_cert_file, const char *my_chain_file, const char *my_key_file) |
| Connects to the specified Quantum Dice randomness server.
|
|
ssize_t | qdremrand_getrand (QDREMRAND *qdr, unsigned char *randbuf, size_t randlen) |
| Retrieves random data from the Quantum Dice randomness server.
|
|
ssize_t | qdremrand_getrand_ce (QDREMRAND *qdr, struct qdrandom *randbuf, size_t randlen) |
| Retrieves random data with certification and entropy information from the Quantum Dice randomness server.
|
|
void | qdremrand_dtor (QDREMRAND *qdr) |
| Destructor for the QDREMRAND structure.
|
|
◆ qdremrand()
Initializes a QDREMRAND structure.
This function must be called to initialize a QDREMRAND structure before using it with any other functions in the library.
- Parameters
-
qdr | Pointer to the QDREMRAND structure to be initialized. |
◆ qdremrand_connect()
int qdremrand_connect |
( |
QDREMRAND * | qdr, |
|
|
const char * | rem_host, |
|
|
const char * | rem_port, |
|
|
const char * | peer_cert_file, |
|
|
const char * | my_chain_file, |
|
|
const char * | my_key_file ) |
Connects to the specified Quantum Dice randomness server.
This function establishes a connection to a Quantum Dice randomness server using the provided parameters and SSL certificates for authentication.
- Parameters
-
qdr | Pointer to a QDREMRAND structure, which must have been initialized with qdremrand() and not previously connected. |
rem_host | The hostname or IP address of the server. |
rem_port | The port number on the server. |
peer_cert_file | Path to the file containing the server's certificate, used to verify the legitimacy of the server. |
my_chain_file | Path to the client's certificate file, used for authenticating the client to the server. |
my_key_file | Path to the client's private key file, used for authenticating the client to the server. |
- Returns
- 0 on successful connection, non-zero on failure. Error information is printed to stderr in case of failure.
◆ qdremrand_dtor()
Destructor for the QDREMRAND structure.
This function cleans up and frees resources associated with a QDREMRAND structure. It should be called when the QDREMRAND object is no longer needed.
- Parameters
-
qdr | Pointer to a QDREMRAND structure that has been initialized with qdremrand(). |
- Note
- The qdr parameter must have been previously initialized using the qdremrand() function. Calling this function on an uninitialized QDREMRAND structure may lead to undefined behavior.
◆ qdremrand_getrand()
ssize_t qdremrand_getrand |
( |
QDREMRAND * | qdr, |
|
|
unsigned char * | randbuf, |
|
|
size_t | randlen ) |
Retrieves random data from the Quantum Dice randomness server.
This function attempts to obtain random data from a connected Quantum Dice randomness server. The QDREMRAND structure must be properly initialized and connected before calling this function.
- Parameters
-
qdr | Pointer to a QDREMRAND structure that has been initialized with qdremrand() and successfully connected using qdremrand_connect(). |
randbuf | Pointer to a buffer where the random data will be written. |
randlen | The number of random bytes requested. |
- Returns
- The number of bytes successfully written to randbuf, or -1 on error. If the return value is less than randlen, it indicates that the connection to the server was lost during the operation, but some data was still retrieved.
- Note
- In case of an error or partial read, check errno for more information about the nature of the failure.
◆ qdremrand_getrand_ce()
ssize_t qdremrand_getrand_ce |
( |
QDREMRAND * | qdr, |
|
|
struct qdrandom * | randbuf, |
|
|
size_t | randlen ) |
Retrieves random data with certification and entropy information from the Quantum Dice randomness server.
This function attempts to obtain random data along with certification and entropy information from a connected Quantum Dice randomness server. The QDREMRAND structure must be properly initialized and connected before calling this function.
- Parameters
-
qdr | Pointer to a QDREMRAND structure that has been initialized with qdremrand() and successfully connected using qdremrand_connect(). |
randbuf | Pointer to an array of qdrandom structures where the random data and associated metadata will be written. |
randlen | The number of qdrandom structures to fill (i.e., the length of the randbuf array). |
- Returns
- The number of qdrandom structures successfully filled, or -1 on error. If the return value is less than randlen, it indicates that the connection to the server was lost during the operation, but some data was still retrieved.
- Note
- In case of an error or partial read, check errno for more information about the nature of the failure. Each qdrandom structure contains 8 bytes of random data along with certification and entropy information.
◆ qdremrand_verbose()
int qdremrand_verbose |
( |
QDREMRAND * | qdr, |
|
|
int | verbose ) |
Sets the verbose flag for a QDREMRAND instance.
When the verbose flag is non-zero, information about each new connection will be printed. This can be useful for debugging or monitoring purposes.
- Parameters
-
qdr | Pointer to the QDREMRAND structure. |
verbose | The new value for the verbose flag (0 for off, non-zero for on). |
- Returns
- The previous value of the verbose flag.
◆ qdremrand_version
const char qdremrand_version[] |
|
extern |