Skip to content

Commit 054640b

Browse files
sevkiFiloSottile
authored andcommitted
crypto/hmac: rename CheckHMAC to ValidHMAC in package docs
Procedure names should reflect what they do; function names should reflect what they return. Functions are used in expressions, often in things like if's, so they need to read appropriately. if CheckHMAC(a, b, key) is unhelpful because we can't deduce whether CheckHMAC returns true on error or non­-error; instead if ValidHMAC(a, b, key) makes the point clear and makes a future mistake in using the routine less likely. https://www.lysator.liu.se/c/pikestyle.html Change-Id: I7c4b1981c90c8d7475ddd8ec18dee3db2e0f42df GitHub-Last-Rev: 32199a4 GitHub-Pull-Request: #28823 Reviewed-on: https://go-review.googlesource.com/c/149857 Reviewed-by: Filippo Valsorda <[email protected]>
1 parent 96eeaa1 commit 054640b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/crypto/hmac/hmac.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The receiver verifies the hash by recomputing it using the same key.
1111
Receivers should be careful to use Equal to compare MACs in order to avoid
1212
timing side-channels:
1313
14-
// CheckMAC reports whether messageMAC is a valid HMAC tag for message.
15-
func CheckMAC(message, messageMAC, key []byte) bool {
14+
// ValidMAC reports whether messageMAC is a valid HMAC tag for message.
15+
func ValidMAC(message, messageMAC, key []byte) bool {
1616
mac := hmac.New(sha256.New, key)
1717
mac.Write(message)
1818
expectedMAC := mac.Sum(nil)

0 commit comments

Comments
 (0)