diff options
Diffstat (limited to 'roseh.moe.go')
| -rw-r--r-- | roseh.moe.go | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/roseh.moe.go b/roseh.moe.go index a2e7ed2..687fe4c 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -338,14 +338,9 @@ func verify(msg, messageMAC []byte, purpose string) bool { } func marshalInt(x int64) []byte { - ux := uint64(x) << 1 - if x < 0 { - ux = ^ux - } buf := make([]byte, 8) - binary.BigEndian.PutUint64(buf, ux) - for len(buf) > 0 && buf[0] == 0 { - buf = buf[1:] + binary.BigEndian.PutUint64(buf, uint64(x)) + for ; len(buf) > 0 && buf[0] == 0; buf = buf[1:] { } return buf } @@ -356,15 +351,10 @@ func unmarshalInt(b []byte) (int64, bool) { } buf := make([]byte, 8) copy(buf[8-len(b):], b) - ux := binary.BigEndian.Uint64(buf) - x := int64(ux >> 1) - if ux&1 != 0 { - x = ^x - } - return x, true + return int64(binary.BigEndian.Uint64(buf)), true } -const yearOffset = 2089 +const yearOffset = 2025 func marshalTime(t time.Time) []byte { year, month, day := t.UTC().Date() |
