From fafa79cc3198e980e60de0b23af7e7ad03e37aad Mon Sep 17 00:00:00 2001 From: siddharth Date: Sat, 9 Oct 2021 11:46:08 -0400 Subject: lib: refactor sha1 implementation Add ability to set initial hash values for Sha1 --- challenge/c28.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'challenge') diff --git a/challenge/c28.go b/challenge/c28.go index 7a763d5..a54be26 100644 --- a/challenge/c28.go +++ b/challenge/c28.go @@ -35,11 +35,14 @@ I'm pushin' away, I'm pushin' away Yeah I'm pushin' away, pushin' away`) sec := lib.StrToBytes("Milk Records") + // Init SHA1 + sha1 := lib.Sha1{} + // Generate SHA1 MAC. - mac := lib.Sha1Mac(sec, msg) + mac := sha1.Mac(sec, msg) // Verify. - if lib.Sha1MacVerify(sec, msg, mac) != true { + if sha1.MacVerify(sec, msg, mac) != true { fmt.Printf("Error: Sha1Mac verification failed!\n") return } @@ -48,7 +51,7 @@ Yeah I'm pushin' away, pushin' away`) msg[42] = byte(42) // Verify that SHA1 MAC fails - if lib.Sha1MacVerify(sec, msg, mac) != false { + if sha1.MacVerify(sec, msg, mac) != false { fmt.Printf("Error: Sha1Mac verification success!\n") return } -- cgit v1.2.3