I am collecting sensitive form user input which, when the input has finished, I want to encrypt using asymmetric encryption.
I do not know the length of the data beforehand. I dont't want the data to be swapped out (because it is sensitive).
So I would think, that a something like a stringstream with an allocator based on libsodium_malloc/libsoium_free would be the right choice. Now in the libsodium documentation on secure memory it says:
The returned address will not be aligned if the allocation size is not a multiple of the required alignment.
For this reason, sodium_malloc() should not be used with packed structure or variable-length structures, unless the size given to sodium_malloc() is rounded up in order to ensure proper alignment.
I am not really sure what this means and if it applies to me. Why would I care for proper alignment?
Is my approach the right way to do it at all?