Hi, I'm trying to write an app to generate public/private/shared key for ECDH. Here is what I was able to build based on examples:
#include <openssl/ssl.h> #define ECDH_SIZE 67 int main() { EC_KEY *ecdh = EC_KEY_new(); const EC_POINT *point = NULL; EC_POINT *point2; const EC_GROUP *group; // const void *pubkey = NULL; unsigned char *pubkey = NULL; void *shared = NULL; //Generate Public ecdh = EC_KEY_new_by_curve_name(NID_secp521r1); EC_KEY_generate_key(ecdh); point = EC_KEY_get0_public_key(ecdh); EC_POINT_point2oct(EC_KEY_get0_group(ecdh), point, POINT_CONVERSION_COMPRESSED, pubkey, ECDH_SIZE, NULL); //ComputeKey group = EC_KEY_get0_group((ecdh)); point2 = EC_POINT_new(group); EC_POINT_oct2point(group, point2, pubkey, ECDH_SIZE, NULL); ECDH_compute_key(shared, ECDH_SIZE, point2, ecdh, NULL); EC_POINT_free(point2); EC_KEY_free(ecdh); ecdh = NULL; printf("To the end"); return 0; } But it just broke on EC_POINT_oct2point(group, point2, pubkey, ECDH_SIZE, NULL); And pubkey is exiting EC_POINT_point2oct(EC_KEY_get0_group(ecdh), point, POINT_CONVERSION_COMPRESSED, pubkey, ECDH_SIZE, NULL); with a NULL value. The program exists and gives no segFAULT or any erros messages. Any suggestions? Thanks, -- Fabio Resner.