Skip to content

Commit

Permalink
公开HMAC V1 Scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
gotoxu committed Nov 20, 2017
1 parent 31e8596 commit fc0a804
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions hmac_v1_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

const (
authHeaderPrefix = "FNBUS1-HMAC-SHA256"
HMACV1Scheme = "FNBUS1-HMAC-SHA256"
timeFormat = "20060102T150405Z"
shortTimeFormat = "20060102"
emptyStringSHA256 = `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`
Expand Down Expand Up @@ -160,7 +160,7 @@ func (ctx *signingCtx) build(disableHeaderHoisting bool) *HMACSigningResult {
ctx.buildSignature()

parts := []string{
authHeaderPrefix + " Credential=" + ctx.identifier + "/" + ctx.credentialString,
HMACV1Scheme + " Credential=" + ctx.identifier + "/" + ctx.credentialString,
"SignedHeaders=" + ctx.signedHeaders,
"Signature=" + ctx.signature,
}
Expand Down Expand Up @@ -256,7 +256,7 @@ func (ctx *signingCtx) buildCanonicalString() {

func (ctx *signingCtx) buildStringToSign() {
ctx.stringToSign = strings.Join([]string{
authHeaderPrefix,
HMACV1Scheme,
ctx.formattedTime,
ctx.credentialString,
hex.EncodeToString(makeSha256([]byte(ctx.canonicalString))),
Expand Down
4 changes: 2 additions & 2 deletions hmac_v1_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (v1 *HMACValidatorV1) Verify(r *Request) bool {
if len(parts) != 2 {
return false
}
if parts[0] != authHeaderPrefix {
if parts[0] != HMACV1Scheme {
return false
}

Expand Down Expand Up @@ -148,7 +148,7 @@ func (ctx *verifyCtx) buildSignature() {

func (ctx *verifyCtx) buildStringToSign() {
ctx.stringToSign = strings.Join([]string{
authHeaderPrefix,
HMACV1Scheme,
ctx.formattedTime,
ctx.credentialString,
hex.EncodeToString(makeSha256([]byte(ctx.canonicalString))),
Expand Down

0 comments on commit fc0a804

Please sign in to comment.