dissertation-2-code/mocks/mac.go
Jake Hillion ff4ce07b05
All checks were successful
continuous-integration/drone/push Build is passing
functional udp
2020-11-27 20:17:59 +00:00

23 lines
398 B
Go

package mocks
import (
"mpbl3p/shared"
)
type AlmostUselessMac struct{}
func (AlmostUselessMac) CodeLength() int {
return 4
}
func (AlmostUselessMac) Generate([]byte) []byte {
return []byte{'a', 'b', 'c', 'd'}
}
func (u AlmostUselessMac) Verify(_, sum []byte) error {
if !(sum[0] == 'a' && sum[1] == 'b' && sum[2] == 'c' && sum[3] == 'd') {
return shared.ErrBadChecksum
}
return nil
}