In the testing of my application I have received a bad memory access crash
that was triggered by the EC_POINT_point2oct function inside
i2o_ECPublicKey.

I have been testing this application for some time now and this is the
first time it has crashed. What I did notice in particular is that it seems
that the crash occurred while two threads were inside my EC Key generation
function at the same time.

I realized that my error checking isn't up to par and that I should have
been able to prevent the crash by checking for error conditions in
functions like EC_KEY_set_group, EC_KEY_Generate_key, etc. What i'm more
interested in more is what conditions cause these functions to throw an
error. I'm running on a PC with tons of free ram so i'm sure its not low
memory that is the issue. Is generating new EC keys not thread-safe?

My functions looks something like this

EC_KEY *newKey = EC_KEY_new();

if (newKey)
{
    EC_GROUP *group = EC_GROUP_new_by_curve_name(curve);
    EC_KEY_set_group(newKey, group);
    EC_KEY_generate_key(newKey);

    unsigned char *converted = convertKeyToOctPub(newKey);
    return converted;
}

Its very possible that i'm completely wrong and its some other problem in
my application but I just wanted to double check as it seemed odd that the
one time this happened multiple threads were accessing these functions.

Reply via email to