fix leading zero padding in ECDSA sig conversion

This commit is contained in:
Peter van Dijk 2017-02-28 12:18:34 +01:00
parent fb689c046f
commit 171594a92d

View File

@ -526,6 +526,15 @@ public class SignUtils
s_src_pos = (byte) (r_src_pos + r_src_len); s_pad = 0;
len = (byte) (6 + r_src_len + s_src_len);
// leading zeroes are forbidden
if (signature[r_src_pos] == 0) {
r_src_pos++; r_src_len--; len--;
}
if (signature[s_src_pos] == 0) {
s_src_pos++; s_src_len--; len--;
}
// except when they are mandatory
if (signature[r_src_pos] < 0) {
r_pad = 1; len++;
}