Add a return value to crypter_t.decrypt()

This commit is contained in:
Martin Willi
2012-07-16 14:53:38 +02:00
parent e35abbe588
commit 3b96189a2a
17 changed files with 72 additions and 35 deletions
+1 -2
View File
@@ -105,8 +105,7 @@ METHOD(aead_t, decrypt, bool,
DBG1(DBG_LIB, "MAC verification failed");
return FALSE;
}
this->crypter->decrypt(this->crypter, encrypted, iv, plain);
return TRUE;
return this->crypter->decrypt(this->crypter, encrypted, iv, plain);
}
METHOD(aead_t, get_block_size, size_t,
+3 -1
View File
@@ -106,8 +106,10 @@ struct crypter_t {
* @param data data to decrypt
* @param iv initializing vector
* @param encrypted chunk to allocate decrypted data, or NULL
* @return TRUE if decryption successful
*/
void (*decrypt) (crypter_t *this, chunk_t data, chunk_t iv,
__attribute__((warn_unused_result))
bool (*decrypt) (crypter_t *this, chunk_t data, chunk_t iv,
chunk_t *decrypted);
/**
+12 -4
View File
@@ -164,8 +164,10 @@ static u_int bench_crypter(private_crypto_tester_t *this,
{
runs++;
}
crypter->decrypt(crypter, buf, chunk_from_thing(iv), NULL);
runs++;
if (crypter->decrypt(crypter, buf, chunk_from_thing(iv), NULL))
{
runs++;
}
}
free(buf.ptr);
crypter->destroy(crypter);
@@ -226,7 +228,10 @@ METHOD(crypto_tester_t, test_crypter, bool,
failed = TRUE;
}
/* inline decryption */
crypter->decrypt(crypter, cipher, iv, NULL);
if (!crypter->decrypt(crypter, cipher, iv, NULL))
{
failed = TRUE;
}
if (!memeq(vector->plain, cipher.ptr, cipher.len))
{
failed = TRUE;
@@ -234,7 +239,10 @@ METHOD(crypto_tester_t, test_crypter, bool,
free(cipher.ptr);
/* allocated decryption */
cipher = chunk_create(vector->cipher, vector->len);
crypter->decrypt(crypter, cipher, iv, &plain);
if (!crypter->decrypt(crypter, cipher, iv, &plain))
{
failed = TRUE;
}
if (!memeq(vector->plain, plain.ptr, plain.len))
{
failed = TRUE;
+5 -1
View File
@@ -639,7 +639,11 @@ end:
/* decrypt the content */
crypter->set_key(crypter, symmetric_key);
crypter->decrypt(crypter, encrypted_content, iv, &this->data);
if (!crypter->decrypt(crypter, encrypted_content, iv, &this->data))
{
success = FALSE;
goto failed;
}
DBG4(DBG_LIB, "decrypted content with padding: %B", &this->data);
/* remove the padding */