Add a return value to prf_plus_t.get_bytes()

This commit is contained in:
Martin Willi
2012-07-16 14:53:33 +02:00
parent 5d79e6c6b4
commit 8207fe3eb3
2 changed files with 7 additions and 7 deletions
+4 -6
View File
@@ -57,7 +57,7 @@ struct private_prf_plus_t {
chunk_t buffer; chunk_t buffer;
}; };
METHOD(prf_plus_t, get_bytes, void, METHOD(prf_plus_t, get_bytes, bool,
private_prf_plus_t *this, size_t length, u_int8_t *buffer) private_prf_plus_t *this, size_t length, u_int8_t *buffer)
{ {
size_t round, written = 0; size_t round, written = 0;
@@ -87,6 +87,7 @@ METHOD(prf_plus_t, get_bytes, void,
this->used += round; this->used += round;
written += round; written += round;
} }
return TRUE;
} }
METHOD(prf_plus_t, allocate_bytes, bool, METHOD(prf_plus_t, allocate_bytes, bool,
@@ -95,12 +96,9 @@ METHOD(prf_plus_t, allocate_bytes, bool,
if (length) if (length)
{ {
*chunk = chunk_alloc(length); *chunk = chunk_alloc(length);
get_bytes(this, length, chunk->ptr); return get_bytes(this, length, chunk->ptr);
}
else
{
*chunk = chunk_empty;
} }
*chunk = chunk_empty;
return TRUE; return TRUE;
} }
+3 -1
View File
@@ -36,8 +36,10 @@ struct prf_plus_t {
* *
* @param length number of bytes to get * @param length number of bytes to get
* @param buffer pointer where the generated bytes will be written * @param buffer pointer where the generated bytes will be written
* @return TRUE if bytes generated successfully
*/ */
void (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer); __attribute__((warn_unused_result))
bool (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer);
/** /**
* Allocate pseudo random bytes. * Allocate pseudo random bytes.