llgo support crypto hmac (#663)

* llgo support crypto/hmac
This commit is contained in:
tsingbx
2024-08-06 16:47:51 +08:00
committed by GitHub
parent 43fd5d233a
commit 6a05aa4e53
5 changed files with 270 additions and 10 deletions

View File

@@ -21,7 +21,6 @@ func main() {
return
}
defer ctx.Free()
var ret c.Int = ctx.InitEx(unsafe.Pointer(unsafe.StringData(key)), c.Int(lenKey), openssl.EVP_sha256(), nil)
if ret == 0 {
c.Fprintf(c.Stderr, c.Str("%s\n"), c.Str("Error initializing HMAC_CTX"))
@@ -37,9 +36,5 @@ func main() {
c.Fprintf(c.Stderr, c.Str("%s\n"), c.Str("Error finalizing HMAC_CTX"))
return
}
fmt.Print("HMAC: ")
for i := 0; i < int(digestLen); i++ {
fmt.Printf("%02x", digest[i])
}
fmt.Print("\n")
fmt.Printf("HMAC:%x\n", digest[:digestLen])
}

View File

@@ -47,10 +47,6 @@ type EVP_MD struct {
Unused [0]byte
}
type EVP_MD_CTX struct {
Unused [0]byte
}
type HMAC_CTX struct {
Unused [0]byte
}