The first one is the order of the checks, as it was being checked differently from the ROM. First, we check that the size of the parameters is within our limits.
The second fix is which size of the parameters was used for the comparison: we have the size passed as a parameter (for example: baseLen), and the size of the number in bits (for example: baseBitLen). In the ROM, it was decided to do the comparison based on the size passed as parameter (One reason for making that decision is that the return data will be of the size of the module modLen). In this case, the comparison was being made using the number of bits of the number.
Fix for this issue. I have added two fixes:
baseLen
), and the size of the number in bits (for example:baseBitLen
). In the ROM, it was decided to do the comparison based on the size passed as parameter (One reason for making that decision is that the return data will be of the size of the modulemodLen
). In this case, the comparison was being made using the number of bits of the number.