Re: AES-256-XTS related question on a multithreaded program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To answer my own question, after checking the documentation,
I think that the answer is NO, you can't give the same buffers
to multiple threads.

I would appreciate if anyone can confirm this, because I've faced
some pretty weird bugs (which are not deterministic, I mean in the
most cases my program seems to work correctly, but in some cases
it doesn't) and I can't find why!

"In particular, being configured for threads support does not
imply that all OpenSSL objects are thread-safe.
To emphasize: most objects are not safe for simultaneous use."

From: https://www.openssl.org/docs/man3.0/man7/openssl-threads.html

On Thu, Jul 20, 2023 at 12:21 AM Dim Xr <dimxrss@xxxxxxxxx> wrote:
Hi all!
At the moment I'm experimenting with OpenSSL-3.1.0, and I'm
trying to encrypt in parallel a block of data.

Let's say that I have a block of 4096 bytes stored in a buffer.

Can I pass to worker threads a pointer to this buffer (let' call
it input_buf), a pointer to an output buffer (let's call it output_buf)
 and a corresponding tweak value and let them work in parallel?

So each thread (in short) will compute something like (error handling
is abbreviated):

cipher = EVP_CIPHER_fetch(NULL, "AES-256-XTS", NULL);
EVP_EncryptInit_ex2(ctx, cipher, key, NULL, NULL);
EVP_EncryptInit_ex2(ctx, NULL, NULL, tweak, NULL);
EVP_EncryptUpdate(ctx, outbuf + relative_bytes, &encrypt_size,
input_buf + relative_bytes, inputsize);

To put it another way, can multiple threads work **on the same
input and output buffers** (but in different regions of course) in
parallel?

Thanks,
Dimitris




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux