Question about using BN_rand()
I couldn't reproduce the issue since you used some custom functions, but this works for me:

#include &lt;openssl/bn.h&gt;
#include &lt;openssl/rand.h&gt;
#include &lt;stdio.h&gt;

int main(void) {
    BIGNUM *test = NULL;
    unsigned char buffer[2048];
    FILE* fd = fopen("/dev/urandom", "r");
    fread(buffer, 1, 2048, fd);
    fclose(fd);

    test = BN_new();
    if (RAND_status() != 1)
        printf("Not enough entropy\n");

    RAND_seed(buffer, 2048);

    if (!BN_rand(test,2048,0,1))
        printf("Not enough entropy\n");

    printf("%s", BN_bn2dec(test));
    return 0;
}