mardi 3 mars 2015

Determine size of decrypted data from gcry_cipher_decrypt?



I have the following call into libgcrypt:



#define COUNTOF(x) ( sizeof(x) / sizeof(x[0]) )
#define ROUNDUP(x, b) ( (x) ? (((x) + (b - 1)) / b) * b : b)

const byte cipher[] = { 0xD0,0x6D,0x69,0x0F ... };
byte recovered[ ROUNDUP(COUNTOF(cipher), 16) ];
...

err = gcry_cipher_decrypt(
handle, // gcry_cipher_hd_t
recovered, // void *
COUNTOF(recovered), // size_t
cipher, // const void *
COUNTOF(cipher)); // size_t


I've checked the Working with cipher handles reference, but the answer escapes me. I also checked the libgrcrypt self tests in tests/basic.c and tests/fipsdrv.c, but they use the same oversized buffer and never prune the buffer to the actual size.


How do I determine the size of the data returned to me in the recovered buffer?




Aucun commentaire:

Enregistrer un commentaire