BN_mod_exp(r,a,p,m,ctx) should not be called with r == p.