Skip to content

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
@sjiekak sjiekak force-pushed the aws-sdk-reuse-signer branch from f9dfa34 to 6417369 Compare April 23, 2024 11:44
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.

1 participant