WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit e1d4aca

Browse files
committed
Updated dependencies
1 parent ed94a9b commit e1d4aca

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

Cargo.lock

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/signer.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,14 @@ fn p1363_to_der(data: &[u8]) -> Vec<u8> {
2929
s = &s[1..];
3030
}
3131

32-
// Do we need to pad the r and s parts?
3332
let r_sign: &[u8] = if r[0] >= 0x80 { &[0] } else { &[] };
3433
let s_sign: &[u8] = if s[0] >= 0x80 { &[0] } else { &[] };
3534

36-
// Length of the value, i.e excluding the tag and length bytes
37-
// For longer signatures the 4 Tag-LENGTH bytes are not enough, but we assume that the signature is less than 252 bytes.
3835
let v_length = 4 + r_sign.len() + s_sign.len() + r.len() + s.len();
3936

40-
// Do we use short or long form for the length?
4137
let (short_form, length_len) = if v_length <= 0x80 {
42-
// Short form, one octet
4338
(true, 1)
4439
} else {
45-
// Long form, first octet is the number of length octets
4640
let mut v_length = v_length;
4741
let mut length_len = 0;
4842
while v_length > 0 {
@@ -59,9 +53,9 @@ fn p1363_to_der(data: &[u8]) -> Vec<u8> {
5953
if short_form {
6054
der.push(v_length as u8); // LENGTH - short form
6155
} else {
62-
der.push(0x80 | length_len as u8); // LENGTH - initial octet of long form
56+
der.push(0x80 | length_len as u8);
6357
for i in (0..length_len).rev() {
64-
der.push((v_length >> (i * 8)) as u8); // LENGTH - long form octets
58+
der.push((v_length >> (i * 8)) as u8);
6559
}
6660
}
6761

0 commit comments

Comments
 (0)