From 3e2a965ae1f92e429c22d2f069c4070bd335dc9d Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 22 Nov 2020 11:45:12 -0500 Subject: lib: gf: fix GFMultiply The logXPlusOneOf[a] + logXPlusOneOf[b] addition can go over 255, so make it a uint16 addition. --- lib/gf.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/gf.go') diff --git a/lib/gf.go b/lib/gf.go index 52715ce..9de143b 100644 --- a/lib/gf.go +++ b/lib/gf.go @@ -11,11 +11,11 @@ func GFMultiply(a, b byte) byte { return 0x00 } - ans := logXPlusOneOf[a] + logXPlusOneOf[b] + ans := uint16(logXPlusOneOf[a]) + uint16(logXPlusOneOf[b]) if ans >= 255 { ans -= 255 } - return xPlusOneToThe[ans] + return xPlusOneToThe[byte(ans)] } var xPlusOneToThe map[byte]byte = map[byte]byte{ -- cgit v1.2.3