From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/go/crypto%2Fhmac%2Findex.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 devdocs/go/crypto%2Fhmac%2Findex.html (limited to 'devdocs/go/crypto%2Fhmac%2Findex.html') diff --git a/devdocs/go/crypto%2Fhmac%2Findex.html b/devdocs/go/crypto%2Fhmac%2Findex.html new file mode 100644 index 00000000..e08e7719 --- /dev/null +++ b/devdocs/go/crypto%2Fhmac%2Findex.html @@ -0,0 +1,23 @@ +

Package hmac

Overview

Package hmac implements the Keyed-Hash Message Authentication Code (HMAC) as defined in U.S. Federal Information Processing Standards Publication 198. An HMAC is a cryptographic hash that uses a key to sign a message. The receiver verifies the hash by recomputing it using the same key.

+

Receivers should be careful to use Equal to compare MACs in order to avoid timing side-channels:

+
// ValidMAC reports whether messageMAC is a valid HMAC tag for message.
+func ValidMAC(message, messageMAC, key []byte) bool {
+	mac := hmac.New(sha256.New, key)
+	mac.Write(message)
+	expectedMAC := mac.Sum(nil)
+	return hmac.Equal(messageMAC, expectedMAC)
+}
+

Index

Package files

hmac.go

func Equal 1.1

func Equal(mac1, mac2 []byte) bool

Equal compares two MACs for equality without leaking timing information.

+

func New

func New(h func() hash.Hash, key []byte) hash.Hash

New returns a new HMAC hash using the given hash.Hash type and key. New functions like sha256.New from crypto/sha256 can be used as h. h must return a new Hash every time it is called. Note that unlike other hash implementations in the standard library, the returned Hash does not implement encoding.BinaryMarshaler or encoding.BinaryUnmarshaler.

+

+ © Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.
+ http://golang.org/pkg/crypto/hmac/ +

+
-- cgit v1.2.3