def test_from_metadata_missing_matdesc(self):
     meta = {
         'x-amz-iv': self.iv_64,
         'x-amz-key': self.key_64
     }
     envelope = EncryptionEnvelope()
     envelope.from_metadata(meta)
 def test_from_metadata_missing_iv(self):
     meta = {
         'x-amz-matdesc': '{}',
         'x-amz-key': self.key_64
     }
     envelope = EncryptionEnvelope()
     envelope.from_metadata(meta)
 def test_from_metadata_missing_key(self):
     meta = {
         'x-amz-matdesc': '{}',
         'x-amz-iv': self.iv_64,
     }
     envelope = EncryptionEnvelope()
     envelope.from_metadata(meta)
 def test_from_metadata_missing_key(self):
     meta = {
         'x-amz-matdesc': '{}',
         'x-amz-iv': self.iv_64,
     }
     envelope = EncryptionEnvelope()
     envelope.from_metadata(meta)
    def test_from_metadata(self):
        meta = {
            'x-amz-matdesc': '{}',
            'x-amz-iv': self.iv_64,
            'x-amz-key': self.key_64
        }
        envelope = EncryptionEnvelope()
        envelope.from_metadata(meta)

        assert_equal(envelope['x-amz-matdesc'], '{}')
        assert_equal(envelope.iv, self.iv)
        assert_equal(envelope['x-amz-iv'], self.iv_64)
        assert_equal(envelope.key, self.key)
        assert_equal(envelope['x-amz-key'], self.key_64)
    def test_from_metadata(self):
        meta = {
            'x-amz-matdesc': '{}',
            'x-amz-iv': self.iv_64,
            'x-amz-key': self.key_64
        }
        envelope = EncryptionEnvelope()
        envelope.from_metadata(meta)

        assert_equal(envelope['x-amz-matdesc'], '{}')
        assert_equal(envelope.iv, self.iv)
        assert_equal(envelope['x-amz-iv'], self.iv_64)
        assert_equal(envelope.key, self.key)
        assert_equal(envelope['x-amz-key'], self.key_64)
Beispiel #7
0
class DecryptionHandler(object):
    def __init__(self, provider):
        self.provider = provider

    def build_response_context(self, obj_metadata, context):
        self.envelope = EncryptionEnvelope()
        self.envelope.from_metadata(obj_metadata)
        self.deconstruct_envelope()
        cipher = crypto.aes_cipher(mode="CBC")
        cipher.iv = self.envelope.iv
        cipher.key = self.envelope.key
        context["cipher"] = cipher
        context["raw_body"] = cipher.decrypt(context["body"])
        return context

    def deconstruct_envelope(self):
        key = self.provider.key_for(self.provider.encryption_materials)
        self.envelope.key = crypto.aes_decrypt(key, self.envelope.key)
Beispiel #8
0
class DecryptionHandler(object):

    def __init__(self, provider):
        self.provider = provider

    def build_response_context(self, obj_metadata, context):
        self.envelope = EncryptionEnvelope()
        self.envelope.from_metadata(obj_metadata)
        self.deconstruct_envelope()
        cipher = crypto.aes_cipher(mode='CBC')
        cipher.iv = self.envelope.iv
        cipher.key = self.envelope.key
        context['cipher'] = cipher
        context['raw_body'] = cipher.decrypt(context['body'])
        return context

    def deconstruct_envelope(self):
        key = self.provider.key_for(self.provider.encryption_materials)
        self.envelope.key = crypto.aes_decrypt(key, self.envelope.key)
 def test_from_metadata_empty(self):
     meta = {}
     envelope = EncryptionEnvelope()
     envelope.from_metadata(meta)
Beispiel #10
0
 def test_from_metadata_empty(self):
     meta = {}
     envelope = EncryptionEnvelope()
     envelope.from_metadata(meta)
Beispiel #11
0
 def test_from_metadata_missing_iv(self):
     meta = {'x-amz-matdesc': '{}', 'x-amz-key': self.key_64}
     envelope = EncryptionEnvelope()
     envelope.from_metadata(meta)
Beispiel #12
0
 def test_from_metadata_missing_matdesc(self):
     meta = {'x-amz-iv': self.iv_64, 'x-amz-key': self.key_64}
     envelope = EncryptionEnvelope()
     envelope.from_metadata(meta)