deatil/go-hash

Hamsi and Fugue HMAC failling

pedroalbanese opened this issue · 1 comments

Greetings!

There is a problem with the implementations of the Hamsi and Fugue algorithms. They don't support hmac. That is, any key generates the same output:

package main

import (
	"crypto/hmac"
	"fmt"
	"io"
	"log"
	"os"

	"github.com/deatil/go-hash/hamsi"
)

func main() {
	if len(os.Args) < 3 {
		fmt.Println("Usage: ./hamsi_hmac_tool <path_to_file> <key>")
		os.Exit(1)
	}

	filePath := os.Args[1]
	key := []byte(os.Args[2])

	file, err := os.Open(filePath)
	if err != nil {
		log.Fatal("Error opening file:", err)
	}
	defer file.Close()

	h := hmac.New(hamsi.New256, key)

	if _, err := io.Copy(h, file); err != nil {
		log.Fatal("Error reading file:", err)
	}

	hashValue := h.Sum(nil)

	// Convert hash value to hex string
	hashHex := fmt.Sprintf("%x", hashValue)

	fmt.Printf("HMAC-Hamsi-256 of file %s: %s\n", filePath, hashHex)
}

Thanks in advance.

Thank You!