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);
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);
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;
}
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);
}
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
*
* @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.
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,