wolfSSL / wolfEngine

wolfCrypt and wolfCrypt FIPS engine for OpenSSL
https://www.wolfssl.com
GNU General Public License v3.0
23 stars 26 forks source link

Fix deallocation strategy in various we_ec_p*_init functions. #183

Closed haydenroche5 closed 2 years ago

haydenroche5 commented 2 years ago

These functions were taking it upon themselves to free the we_Ecc object and the data it holds. With this commit, that's left to we_ec_cleanup. A user discovered this problem, and I reproduced it by changing this line

ecc->group = EC_GROUP_new_by_curve_name(ecc->curveName);

to

ecc->group = EC_GROUP_new_by_curve_name(0);

to trigger a deliberate failure in we_ec_p192_init. If you do that and run the unit tests, you'll get a double free fault. This commit fixes this problem across the we_ec_p*_init functions.

See ZD #14091.