Add a return value to mac_t.get_bytes()
This commit is contained in:
@@ -44,8 +44,10 @@ struct mac_t {
|
||||
*
|
||||
* @param data chunk of data to authenticate
|
||||
* @param out pointer where the generated bytes will be written
|
||||
* @return TRUE if mac generated successfully
|
||||
*/
|
||||
void (*get_mac)(mac_t *this, chunk_t data, u_int8_t *out);
|
||||
__attribute__((warn_unused_result))
|
||||
bool (*get_mac)(mac_t *this, chunk_t data, u_int8_t *out);
|
||||
|
||||
/**
|
||||
* Get the size of the resulting MAC.
|
||||
|
||||
@@ -38,23 +38,18 @@ struct private_prf_t {
|
||||
METHOD(prf_t, get_bytes, bool,
|
||||
private_prf_t *this, chunk_t seed, u_int8_t *buffer)
|
||||
{
|
||||
this->mac->get_mac(this->mac, seed, buffer);
|
||||
return TRUE;
|
||||
return this->mac->get_mac(this->mac, seed, buffer);
|
||||
}
|
||||
|
||||
METHOD(prf_t, allocate_bytes, bool,
|
||||
private_prf_t *this, chunk_t seed, chunk_t *chunk)
|
||||
{
|
||||
if (!chunk)
|
||||
{
|
||||
this->mac->get_mac(this->mac, seed, NULL);
|
||||
}
|
||||
else
|
||||
if (chunk)
|
||||
{
|
||||
*chunk = chunk_alloc(this->mac->get_mac_size(this->mac));
|
||||
this->mac->get_mac(this->mac, seed, chunk->ptr);
|
||||
return this->mac->get_mac(this->mac, seed, chunk->ptr);
|
||||
}
|
||||
return TRUE;
|
||||
return this->mac->get_mac(this->mac, seed, NULL);
|
||||
}
|
||||
|
||||
METHOD(prf_t, get_block_size, size_t,
|
||||
|
||||
@@ -43,37 +43,36 @@ struct private_signer_t {
|
||||
METHOD(signer_t, get_signature, bool,
|
||||
private_signer_t *this, chunk_t data, u_int8_t *buffer)
|
||||
{
|
||||
if (buffer == NULL)
|
||||
{
|
||||
this->mac->get_mac(this->mac, data, NULL);
|
||||
}
|
||||
else
|
||||
if (buffer)
|
||||
{
|
||||
u_int8_t mac[this->mac->get_mac_size(this->mac)];
|
||||
|
||||
this->mac->get_mac(this->mac, data, mac);
|
||||
if (!this->mac->get_mac(this->mac, data, mac))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
memcpy(buffer, mac, this->truncation);
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
return this->mac->get_mac(this->mac, data, NULL);
|
||||
}
|
||||
|
||||
METHOD(signer_t, allocate_signature, bool,
|
||||
private_signer_t *this, chunk_t data, chunk_t *chunk)
|
||||
{
|
||||
if (chunk == NULL)
|
||||
{
|
||||
this->mac->get_mac(this->mac, data, NULL);
|
||||
}
|
||||
else
|
||||
if (chunk)
|
||||
{
|
||||
u_int8_t mac[this->mac->get_mac_size(this->mac)];
|
||||
|
||||
this->mac->get_mac(this->mac, data, mac);
|
||||
|
||||
if (!this->mac->get_mac(this->mac, data, mac))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
*chunk = chunk_alloc(this->truncation);
|
||||
memcpy(chunk->ptr, mac, this->truncation);
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
return this->mac->get_mac(this->mac, data, NULL);
|
||||
}
|
||||
|
||||
METHOD(signer_t, verify_signature, bool,
|
||||
@@ -85,8 +84,8 @@ METHOD(signer_t, verify_signature, bool,
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
this->mac->get_mac(this->mac, data, mac);
|
||||
return memeq(signature.ptr, mac, this->truncation);
|
||||
return this->mac->get_mac(this->mac, data, mac) &&
|
||||
memeq(signature.ptr, mac, this->truncation);
|
||||
}
|
||||
|
||||
METHOD(signer_t, get_key_size, size_t,
|
||||
|
||||
Reference in New Issue
Block a user