crypter_t api supports in-place encryption using NULL as output parameter

This commit is contained in:
Martin Willi
2008-04-30 14:02:25 +00:00
parent d691080cfc
commit f5475fa440
4 changed files with 57 additions and 17 deletions
+15 -4
View File
@@ -1345,9 +1345,16 @@ static void decrypt(private_aes_crypter_t *this, chunk_t data, chunk_t iv,
const u_int32_t *iv_i;
u_int8_t *in, *out;
*decrypted = chunk_alloc(data.len);
if (decrypted)
{
*decrypted = chunk_alloc(data.len);
out = decrypted->ptr;
}
else
{
out = data.ptr;
}
in = data.ptr;
out = decrypted->ptr;
pos = data.len-16;
in += pos;
@@ -1384,9 +1391,13 @@ static void encrypt (private_aes_crypter_t *this, chunk_t data, chunk_t iv,
const u_int32_t *iv_i;
u_int8_t *in, *out;
*encrypted = chunk_alloc(data.len);
in = data.ptr;
out = encrypted->ptr;
out = data.ptr;
if (encrypted)
{
*encrypted = chunk_alloc(data.len);
out = encrypted->ptr;
}
pos=0;
while(pos<data.len)