Fix memleaks in KDF implementations