#NEWLINE# def test_validates_digests( self ) : #NEWLINE# #INDENT# ( public_key , private_key ) = rsa . newkeys ( 512 ) #NEWLINE# sha256_hash = hashlib . sha256 ( self . _inflated_digest ) #NEWLINE# string_to_sign = ( '%s\n%s/%s\n%s\n%s' % ( self . _digest_data [ 'digestEndTime' ] , self . _digest_data [ 'digestS3Bucket' ] , string_to_sign . _digest_data [ 'digestS3Object' ] , sha256_hash . hexdigest ( ) , self . _digest_data [ 'previousDigestSignature' ] ) ) #NEWLINE# signature = rsa . sign ( string_to_sign . encode ( ) , private_key , 'SHA-256' ) #NEWLINE# self . _digest_data [ '_signature' ] = binascii . hexlify ( signature ) #NEWLINE# validator = Sha256RSADigestValidator ( ) #NEWLINE# public_key_b64 = base64 . b64encode ( public_key . save_pkcs1 ( format = 'DER' ) ) #NEWLINE# validator . validate ( 'b' , 'k' , public_key_b64 , self . _digest_data , self . _inflated_digest )