Ok, I figured out what the issue was and I have found a solution to fix it.
TL;DR: The max stack size on my system is set to 8192 KB by default, or 0x800000 bytes. The CST puts an array that is at least the size of the entire image on the stack, which when combined with all of the other items on the stack exceeds the max stack size and causes a segfault. To fix this issue, either increase the max stack size or modify ssl_wrapper.c as described below.
Detailed analysis:
On a whim, I decided to run Valgrind on the program to see if I could get any further insight into what was going on. I recompiled the CST to include debugging symbols and reran the test using Valgrind. Here is the output of this test: https://gist.github.com/rjfendricks-indesign/2ba68e9e39416d536ef92b4d2025cdc2 . According to this log, SIGSEGV is being thrown from line 72 of ssl_wrapper.c. This is one of the back_end source files available to the developer to modify. This specific line looks like it's allocating some space for a struct, but it's not immediately apparent why a segfault would be thrown.
if (!(ctx = EVP_CIPHER_CTX_new())) {
However, taking another look at the Valgrind output, the following lines are printed out immediately after the segfault is thrown:
==12501== If you believe this happened as a result of a stack
==12501== overflow in your program's main thread (unlikely but
==12501== possible), you can try to increase the size of the
==12501== main thread stack using the --main-stacksize= flag.
==12501== The main thread stack size used in this run was 8388608.
This is very interesting, because a stack size of 8388608 bytes is the same size as the image I passed in. I reran Valgrind passing in --main-stacksize=$((0x900000)), and the program succeeded (There were still a bunch of Valgrind warnings, but it didn't segfault)! I did a little researching and found the `ulimit` command, which allows the developer to change default stack size. Running "ulimit -S -a" revealed to me that my stack size was 8192 KB, or 8388608 bytes. Given this information, the following command allowed the CST to run without issue:
ulimit -S -s 9216 && ./bin/cst --o --test_image.csf --i test_image.csf.ini
I set the stack size to 9126 KB, 1024KB bytes larger than my image size, to give the program more than enough space to hold the image.
My best guess for why the segfault happened at line 72 of ssl_wrapper.c is that a few lines earlier, on line 66, an array is created that is the size of the plaintext file + EVP_MAX_BLOCK_LENGTH.
unsigned char ciphertext[plaintext_len + EVP_MAX_BLOCK_LENGTH] ;
Then on line 72 a function is called to allocate memory for a new cipher constructor. So the array, which is at least 0x800000 bytes long, is put onto the stack and overruns the max stacksize, causing a segfault and crashing the program. To fix this, I allocated a buffer that is plaintext_len + EVP_MAX_BLOCK_LENGTH long in place of creating an array:
unsigned char *ciphertext = NULL;
ciphertext = (unsigned char *) malloc(
sizeof(unsigned char) * plaintext_len + EVP_MAX_BLOCK_LENGTH);
Not shown above is error checking and freeing the memory. After recompiling, I can confirm that this fixed the segfault issue. Going forward, I will be using this modified version of the CST to encrypt my images.