From 5001a38cc1a25850314a77bcde5df32371493236 Mon Sep 17 00:00:00 2001 From: sevki Date: Sat, 17 Nov 2018 21:28:08 +0000 Subject: [PATCH] crypto/hmac: rename CheckHMAC to ValidHMAC in package docs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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: 32199a418b5e5507259fa4b6715da8a9c185f90a GitHub-Pull-Request: golang/go#28823 Reviewed-on: https://go-review.googlesource.com/c/149857 Reviewed-by: Filippo Valsorda --- src/crypto/hmac/hmac.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crypto/hmac/hmac.go b/src/crypto/hmac/hmac.go index c8c0617c47..801ece67ae 100644 --- a/src/crypto/hmac/hmac.go +++ b/src/crypto/hmac/hmac.go @@ -11,8 +11,8 @@ 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: - // CheckMAC reports whether messageMAC is a valid HMAC tag for message. - func CheckMAC(message, messageMAC, key []byte) bool { + // 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) -- 2.48.1