Either R or S could end up being shorter than the expected length, so adjust for that.

This commit is contained in:
David Blacka 2017-01-05 13:50:48 -05:00
parent c13d9379b3
commit c5896495c7

View File

@ -485,13 +485,15 @@ public class SignUtils
// Adjust for leading zeros on both R and S // Adjust for leading zeros on both R and S
if (signature[r_pos] == 0) { if (signature[r_pos] == 0) {
r_pos++; r_pos++;
r_len--;
} }
if (signature[s_pos] == 0) { if (signature[s_pos] == 0) {
s_pos++; s_pos++;
s_len--;
} }
System.arraycopy(signature, r_pos, sig, 0, exp_length); System.arraycopy(signature, r_pos, sig, 0 + (exp_length - r_len), r_len);
System.arraycopy(signature, s_pos, sig, exp_length, exp_length); System.arraycopy(signature, s_pos, sig, exp_length + (exp_length - s_len), s_len);
return sig; return sig;
} }