Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hamsi and Fugue HMAC failling #1

Closed
pedroalbanese opened this issue May 17, 2024 · 1 comment
Closed

Hamsi and Fugue HMAC failling #1

pedroalbanese opened this issue May 17, 2024 · 1 comment

Comments

@pedroalbanese
Copy link

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.

@deatil deatil closed this as completed May 18, 2024
@pedroalbanese
Copy link
Author

Thank You!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants