Topic: In-place aes CTR
Can i use the same buffer for input and output when calling wc_AesCtrEncrypt?
You are not logged in. Please login or register.
Please post questions or comments you have about wolfSSL products here. It is helpful to be as descriptive as possible when asking your questions.
ReferenceswolfSSL - Embedded SSL Library → wolfCrypt → In-place aes CTR
Can i use the same buffer for input and output when calling wc_AesCtrEncrypt?
Hi dbenor,
I had this question come up on another forum query recently. As a result I updated the wolfSSL API Reference document but those changes have not yet posted to the website.
The answer is NO you do not want to use the same buffer. Here is a code example of how to use wc_AesCtrEncrypt for both encryption and decryption:
Aes enc;
Aes dec;
/* initialize enc and dec with AesSetKeyDirect, using direction AES_ENCRYPTION
* since the underlying API only calls Encrypt and by default calling encrypt on
* a cipher results in a decryption of the cipher
*/
byte msg[AES_BLOCK_SIZE * n]; //n being a positive integer making msg some multiple of 16 bytes
// fill plain with message text
byte cipher[AES_BLOCK_SIZE * n];
byte decrypted[AES_BLOCK_SIZE * n];
wc_AesCtrEncrypt(&enc, cipher, msg, sizeof(msg)); // encrypt plain
wc_AesCtrEncrypt(&dec, decrypted, cipher, sizeof(cipher)); // decrypt cipher text
Regards,
Kaleb
wolfSSL - Embedded SSL Library → wolfCrypt → In-place aes CTR
Powered by PunBB, supported by Informer Technologies, Inc.
Generated in 0.017 seconds (90% PHP - 10% DB) with 9 queries