for dh key exchanges, use p as the parameter for weak key exchanges.
Y can be a few bytes smaller due to the modulo operation - this is ok.