ECDH_DATA *ecdh_check(EC_KEY *key) { ECDH_DATA *ecdh_data; void *data = EC_KEY_get_key_method_data(key, ecdh_data_dup, ecdh_data_free, ecdh_data_free); if (data == NULL) { ecdh_data = (ECDH_DATA *)ecdh_data_new(); if (ecdh_data == NULL) return NULL; data = EC_KEY_insert_key_method_data(key, (void *)ecdh_data, ecdh_data_dup, ecdh_data_free, ecdh_data_free); if (data != NULL) { /* * Another thread raced us to install the key_method data and * won. */ ecdh_data_free(ecdh_data); ecdh_data = (ECDH_DATA *)data; } } else ecdh_data = (ECDH_DATA *)data; return ecdh_data; }
ECDH_DATA *ecdh_check(EC_KEY *key) { ECDH_DATA *ecdh_data; void *data = EC_KEY_get_key_method_data(key, ecdh_data_dup, ecdh_data_free, ecdh_data_free); if (data == NULL) { ecdh_data = (ECDH_DATA *)ecdh_data_new(); if (ecdh_data == NULL) return NULL; data = EC_KEY_insert_key_method_data(key, (void *)ecdh_data, ecdh_data_dup, ecdh_data_free, ecdh_data_free); if (data != NULL) { /* * Another thread raced us to install the key_method data and * won. */ ecdh_data_free(ecdh_data); ecdh_data = (ECDH_DATA *)data; } } else ecdh_data = (ECDH_DATA *)data; #ifdef OPENSSL_FIPS if (FIPS_mode() && !(ecdh_data->flags & ECDH_FLAG_FIPS_METHOD) && !(EC_KEY_get_flags(key) & EC_FLAG_NON_FIPS_ALLOW)) { ECDHerr(ECDH_F_ECDH_CHECK, ECDH_R_NON_FIPS_METHOD); return NULL; } #endif return ecdh_data; }