Nonce: Let get_nonce, allocate_nonce return boolean
This commit is contained in:
parent
f3ca96b2bf
commit
605985d122
|
@ -651,7 +651,12 @@ METHOD(phase1_t, add_nonce_ke, bool,
|
|||
DBG1(DBG_IKE, "no nonce generator found to create nonce");
|
||||
return FALSE;
|
||||
}
|
||||
nonceg->allocate_nonce(nonceg, NONCE_SIZE, &nonce);
|
||||
if (!nonceg->allocate_nonce(nonceg, NONCE_SIZE, &nonce))
|
||||
{
|
||||
DBG1(DBG_IKE, "nonce allocation failed");
|
||||
nonceg->destroy(nonceg);
|
||||
return FALSE;
|
||||
}
|
||||
nonceg->destroy(nonceg);
|
||||
|
||||
nonce_payload = nonce_payload_create(NONCE_V1);
|
||||
|
|
|
@ -328,7 +328,12 @@ static bool add_nonce(private_quick_mode_t *this, chunk_t *nonce,
|
|||
DBG1(DBG_IKE, "no nonce generator found to create nonce");
|
||||
return FALSE;
|
||||
}
|
||||
nonceg->allocate_nonce(nonceg, NONCE_SIZE, nonce);
|
||||
if (!nonceg->allocate_nonce(nonceg, NONCE_SIZE, nonce))
|
||||
{
|
||||
DBG1(DBG_IKE, "nonce allocation failed");
|
||||
nonceg->destroy(nonceg);
|
||||
return FALSE;
|
||||
}
|
||||
nonceg->destroy(nonceg);
|
||||
|
||||
nonce_payload = nonce_payload_create(NONCE_V1);
|
||||
|
|
|
@ -207,8 +207,14 @@ static status_t generate_nonce(private_child_create_t *this)
|
|||
DBG1(DBG_IKE, "no nonce generator found to create nonce");
|
||||
return FAILED;
|
||||
}
|
||||
nonceg->allocate_nonce(nonceg, NONCE_SIZE, &this->my_nonce);
|
||||
if (!nonceg->allocate_nonce(nonceg, NONCE_SIZE, &this->my_nonce))
|
||||
{
|
||||
DBG1(DBG_IKE, "nonce allocation failed");
|
||||
nonceg->destroy(nonceg);
|
||||
return FAILED;
|
||||
}
|
||||
nonceg->destroy(nonceg);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,12 @@ METHOD(task_t, build_i, status_t,
|
|||
DBG1(DBG_IKE, "no nonce generator found to create nonce");
|
||||
return FAILED;
|
||||
}
|
||||
nonceg->allocate_nonce(nonceg, NONCE_SIZE, &this->my_nonce);
|
||||
if (!nonceg->allocate_nonce(nonceg, NONCE_SIZE, &this->my_nonce))
|
||||
{
|
||||
DBG1(DBG_IKE, "nonce allocation failed");
|
||||
nonceg->destroy(nonceg);
|
||||
return FAILED;
|
||||
}
|
||||
nonceg->destroy(nonceg);
|
||||
}
|
||||
|
||||
|
@ -302,7 +307,12 @@ METHOD(task_t, process_r, status_t,
|
|||
DBG1(DBG_IKE, "no nonce generator found to create nonce");
|
||||
return FAILED;
|
||||
}
|
||||
nonceg->allocate_nonce(nonceg, NONCE_SIZE, &this->my_nonce);
|
||||
if (!nonceg->allocate_nonce(nonceg, NONCE_SIZE, &this->my_nonce))
|
||||
{
|
||||
DBG1(DBG_IKE, "nonce allocation failed");
|
||||
nonceg->destroy(nonceg);
|
||||
return FAILED;
|
||||
}
|
||||
nonceg->destroy(nonceg);
|
||||
|
||||
#ifdef ME
|
||||
|
|
|
@ -35,16 +35,18 @@ struct nonce_gen_t {
|
|||
*
|
||||
* @param size size of nonce in bytes
|
||||
* @param buffer pointer where the generated nonce will be written
|
||||
* @return TRUE if nonce allocation was succesful, FALSE otherwise
|
||||
*/
|
||||
void (*get_nonce) (nonce_gen_t *this, size_t size, u_int8_t *buffer);
|
||||
bool (*get_nonce) (nonce_gen_t *this, size_t size, u_int8_t *buffer);
|
||||
|
||||
/**
|
||||
* Generates a nonce and allocates space for it.
|
||||
*
|
||||
* @param size size of nonce in bytes
|
||||
* @param chunk chunk which will hold the generated nonce
|
||||
* @return TRUE if nonce allocation was succesful, FALSE otherwise
|
||||
*/
|
||||
void (*allocate_nonce) (nonce_gen_t *this, size_t size, chunk_t *chunk);
|
||||
bool (*allocate_nonce) (nonce_gen_t *this, size_t size, chunk_t *chunk);
|
||||
|
||||
/**
|
||||
* Destroys a nonce generator object.
|
||||
|
|
|
@ -35,16 +35,18 @@ struct private_nonce_nonceg_t {
|
|||
rng_t* rng;
|
||||
};
|
||||
|
||||
METHOD(nonce_gen_t, get_nonce, void,
|
||||
METHOD(nonce_gen_t, get_nonce, bool,
|
||||
private_nonce_nonceg_t *this, size_t size, u_int8_t *buffer)
|
||||
{
|
||||
this->rng->get_bytes(this->rng, size, buffer);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(nonce_gen_t, allocate_nonce, void,
|
||||
METHOD(nonce_gen_t, allocate_nonce, bool,
|
||||
private_nonce_nonceg_t *this, size_t size, chunk_t *chunk)
|
||||
{
|
||||
this->rng->allocate_bytes(this->rng, size, chunk);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(nonce_gen_t, destroy, void,
|
||||
|
|
Loading…
Reference in New Issue