Using global defines for parameters (as seems to be typical in academic crypto code) does not play nice with multithreading at all.