示例#1
0
文件: signing.py 项目: GaretJax/txs3
 def _signingPayload(self, canonical):
     return '\n'.join([
         'AWS4-HMAC-SHA256',
         timestampToHttpString(self._timestamp),
         self._scope(),
         hashlib.sha256(canonical).hexdigest()
     ])
示例#2
0
文件: signing.py 项目: GaretJax/txs3
 def _signingChunkPayload(self, previousSignature, chunkData):
     return '\n'.join([
         'AWS4-HMAC-SHA256-PAYLOAD',
         timestampToHttpString(self._timestamp),
         self._scope(),
         previousSignature,
         hashlib.sha256('').hexdigest(),
         hashlib.sha256(chunkData).hexdigest()
     ])
示例#3
0
文件: signing.py 项目: GaretJax/txs3
    def signRequest(self, request):
        request.headers.addRawHeader(
            'Date', timestampToHttpString(self._timestamp)
        )
        request.headers.addRawHeader(
            'x-amz-content-sha256', request.bodyHash()
        )
        headers, canonical = request.canonicalized()
        signingKey = self._signingKey()
        signingPayload = self._signingPayload(canonical)
        signature = sign(signingKey, signingPayload, True)
        authorization = (
            'AWS4-HMAC-SHA256 Credential={},SignedHeaders={},Signature={}'
            .format(self._credentials(), headers, signature)
        )
        request.headers.addRawHeader('Authorization', authorization)

        self._previousSignature = signature