AES-256-XTS related question on a multithreaded program

Dim Xr dimxrss at
Wed Jul 19 21:21:27 UTC 2023

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the openssl-users mailing list