Example #1
0
 def build_request_context(self, context):
     cipher = context.get("cipher", None) or crypto.aes_cipher(mode="CBC")
     cipher.iv = crypto.aes_iv()
     cipher.key = crypto.aes_key()
     context["body"] = cipher.encrypt(context["raw_body"])
     context["envelope"] = self.build_envelope(cipher)
     return context
Example #2
0
 def build_request_context(self, context):
     cipher = context.get('cipher', None) or crypto.aes_cipher(mode='CBC')
     cipher.iv = crypto.aes_iv()
     cipher.key = crypto.aes_key()
     context['body'] = cipher.encrypt(context['raw_body'])
     context['envelope'] = self.build_envelope(cipher)
     return context
Example #3
0
    def test_build_envelope(self):
        from s3_encryption.handler import EncryptionHandler
        from s3_encryption import crypto
        cipher = crypto.aes_cipher(mode='CBC')
        cipher.iv = crypto.aes_iv()
        cipher.key = crypto.aes_key()

        handler = EncryptionHandler(self.mock_provider)
        envelope = handler.build_envelope(cipher)

        assert_equal(envelope['x-amz-key'], self.encrypted_key)
        assert_equal(envelope['x-amz-iv'], self.encode64(self.iv))
        assert_equal(envelope['x-amz-matdesc'], self.matdesc)
Example #4
0
    def test_build_envelope(self):
        from s3_encryption.handler import EncryptionHandler
        from s3_encryption import crypto
        cipher = crypto.aes_cipher(mode='CBC')
        cipher.iv = crypto.aes_iv()
        cipher.key = crypto.aes_key()

        handler = EncryptionHandler(self.mock_provider)
        envelope = handler.build_envelope(cipher)

        assert_equal(envelope['x-amz-key'], self.encrypted_key)
        assert_equal(envelope['x-amz-iv'], self.encode64(self.iv))
        assert_equal(envelope['x-amz-matdesc'], self.matdesc)