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
1 changed files with 4 additions and 2 deletions

View File

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