if (encrypted)
{
this->crypter->encrypt(this->crypter, plain, iv, &encr);
- this->signer->allocate_signature(this->signer, encr, &sig);
+ if (!this->signer->allocate_signature(this->signer, encr, &sig))
+ {
+ return FALSE;
+ }
*encrypted = chunk_cat("cmm", iv, encr, sig);
}
else
/* allocated signature */
data = chunk_create(vector->data, vector->len);
- signer->allocate_signature(signer, data, &mac);
+ if (!signer->allocate_signature(signer, data, &mac))
+ {
+ failed = TRUE;
+ }
if (mac.len != signer->get_block_size(signer))
{
failed = TRUE;
/* signature to existing buffer, using append mode */
if (data.len > 2)
{
- signer->allocate_signature(signer, chunk_create(data.ptr, 1), NULL);
+ if (!signer->allocate_signature(signer,
+ chunk_create(data.ptr, 1), NULL))
+ {
+ failed = TRUE;
+ }
signer->get_signature(signer, chunk_create(data.ptr + 1, 1), NULL);
if (!signer->verify_signature(signer, chunk_skip(data, 2),
chunk_create(vector->mac, mac.len)))
}
}
-METHOD(signer_t, allocate_signature, void,
+METHOD(signer_t, allocate_signature, bool,
private_signer_t *this, chunk_t data, chunk_t *chunk)
{
if (chunk == NULL)
*chunk = chunk_alloc(this->truncation);
memcpy(chunk->ptr, mac, this->truncation);
}
+ return TRUE;
}
METHOD(signer_t, verify_signature, bool,
*
* @param data a chunk containing the data to sign
* @param chunk chunk which will hold the allocated signature
+ * @return TRUE if signature allocated successfully
*/
- void (*allocate_signature) (signer_t *this, chunk_t data, chunk_t *chunk);
+ __attribute__((warn_unused_result))
+ bool (*allocate_signature) (signer_t *this, chunk_t data, chunk_t *chunk);
/**
* Verify a signature.
this->ops->hash(this->ops, data, buffer, this->block_size);
}
-METHOD(signer_t, allocate_signature, void,
+METHOD(signer_t, allocate_signature, bool,
private_af_alg_signer_t *this, chunk_t data, chunk_t *chunk)
{
if (chunk)
{
get_signature(this, data, NULL);
}
+ return TRUE;
}
METHOD(signer_t, verify_signature, bool,
sigheader(this->signer_out, this->seq_out, *type,
this->version, data->len);
- this->signer_out->allocate_signature(this->signer_out, *data, &mac);
+ if (!this->signer_out->allocate_signature(this->signer_out,
+ *data, &mac))
+ {
+ return FAILED;
+ }
if (this->crypter_out)
{
chunk_t padding, iv;