Add nonce generator interface
Nonce generators (nonce_gen_t) can be used to get or allocate nonces. Users can request nonce generators from the crypto factory while nonce plugins register/remove themselves to/from the crypto factory.
This commit is contained in:
committed by
Tobias Brunner
parent
80c5b17d1a
commit
e2fc09c186
@@ -30,6 +30,7 @@ typedef struct crypto_factory_t crypto_factory_t;
|
||||
#include <crypto/hashers/hasher.h>
|
||||
#include <crypto/prfs/prf.h>
|
||||
#include <crypto/rngs/rng.h>
|
||||
#include <crypto/nonce_gen.h>
|
||||
#include <crypto/diffie_hellman.h>
|
||||
#include <crypto/transform.h>
|
||||
|
||||
@@ -65,6 +66,11 @@ typedef prf_t* (*prf_constructor_t)(pseudo_random_function_t algo);
|
||||
*/
|
||||
typedef rng_t* (*rng_constructor_t)(rng_quality_t quality);
|
||||
|
||||
/**
|
||||
* Constructor function for nonce generators
|
||||
*/
|
||||
typedef nonce_gen_t* (*nonce_gen_constructor_t)();
|
||||
|
||||
/**
|
||||
* Constructor function for diffie hellman
|
||||
*
|
||||
@@ -131,6 +137,13 @@ struct crypto_factory_t {
|
||||
*/
|
||||
rng_t* (*create_rng)(crypto_factory_t *this, rng_quality_t quality);
|
||||
|
||||
/**
|
||||
* Create a nonce generator instance.
|
||||
*
|
||||
* @return nonce_gen_t instance, NULL if not supported
|
||||
*/
|
||||
nonce_gen_t* (*create_nonce_gen)(crypto_factory_t *this);
|
||||
|
||||
/**
|
||||
* Create a diffie hellman instance.
|
||||
*
|
||||
@@ -252,6 +265,23 @@ struct crypto_factory_t {
|
||||
*/
|
||||
void (*remove_rng)(crypto_factory_t *this, rng_constructor_t create);
|
||||
|
||||
/**
|
||||
* Register a nonce generator.
|
||||
*
|
||||
* @param plugin_name plugin that registered this algorithm
|
||||
* @param create constructor function for that nonce generator
|
||||
*/
|
||||
void (*add_nonce_gen)(crypto_factory_t *this, const char *plugin_name,
|
||||
nonce_gen_constructor_t create);
|
||||
|
||||
/**
|
||||
* Unregister a nonce generator.
|
||||
*
|
||||
* @param create constructor function to unregister
|
||||
*/
|
||||
void (*remove_nonce_gen)(crypto_factory_t *this,
|
||||
nonce_gen_constructor_t create);
|
||||
|
||||
/**
|
||||
* Register a diffie hellman constructor.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user