Commit 5001a38c authored by sevki's avatar sevki Committed by Filippo Valsorda

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: 32199a418b5e5507259fa4b6715da8a9c185f90a
GitHub-Pull-Request: golang/go#28823
Reviewed-on: https://go-review.googlesource.com/c/149857Reviewed-by: default avatarFilippo Valsorda <filippo@golang.org>
parent a889aaf8
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment