Temporary sp_int needs to be allocated to be 1 digit larger than a or b for the div operation. Change sp_div to check sizes of r and rem when passed in. Fix sp_invmod, sp_gcm, sp_submod to use temporary sp_int sizes that work with calls to sp_div().
Temporary sp_int needs to be allocated to be 1 digit larger than a or b for the div operation. Change sp_div to check sizes of r and rem when passed in. Fix sp_invmod, sp_gcm, sp_submod to use temporary sp_int sizes that work with calls to sp_div().