Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(aws): aws signer has cache and can be reused #886

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sjiekak
Copy link

@sjiekak sjiekak commented Apr 23, 2024

aws v4.Signer is implemented for reuse

What is meant to be saved is recomputing the key (which require 4 HMACSHA256) calls.

// DeriveKey returns a derived signing key from the given credentials to be used with SigV4 signing.
func (k *SigningKeyDeriver) DeriveKey(credential aws.Credentials, service, region string, signingTime SigningTime) []byte {
	return k.cache.Get(credential, service, region, signingTime)
}

func deriveKey(secret, service, region string, t SigningTime) []byte {
	hmacDate := HMACSHA256([]byte("AWS4"+secret), []byte(t.ShortTimeFormat()))
	hmacRegion := HMACSHA256(hmacDate, []byte(region))
	hmacService := HMACSHA256(hmacRegion, []byte(service))
	return HMACSHA256(hmacService, []byte("aws4_request"))
}

@sjiekak sjiekak force-pushed the aws-sdk-reuse-signer branch 3 times, most recently from dd31650 to f9dfa34 Compare April 23, 2024 11:43
Signed-off-by: Steve Jiekak <devaureshy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant