def test_verify_signed_data(self):
     signed = memcache_crypt.sign_data('mykey', 'Testz')
     self.assertEqual(memcache_crypt.verify_signed_data('mykey', signed),
                      'Testz')
     self.assertEqual(
         memcache_crypt.verify_signed_data('aasSFWE13WER', 'not MACed'),
         'not MACed')
 def test_verify_signed_data(self):
     signed = memcache_crypt.sign_data('mykey', 'Testz')
     self.assertEqual(
         memcache_crypt.verify_signed_data('mykey', signed),
         'Testz')
     self.assertEqual(
         memcache_crypt.verify_signed_data('aasSFWE13WER', 'not MACed'),
         'not MACed')
예제 #3
0
    def _unprotect_cache_value(self, token, data):
        """ Decrypt or verify signed data if necessary. """
        if data is None:
            return data

        try:
            if self._memcache_security_strategy == "ENCRYPT":
                return memcache_crypt.decrypt_data(token, self._memcache_secret_key, data)
            elif self._memcache_security_strategy == "MAC":
                return memcache_crypt.verify_signed_data(token, data)
            else:
                return data
        except:
            msg = "Failed to decrypt/verify cache data."
            self.LOG.exception(msg)
            # this should have the same effect as data not found in cache
            return None
예제 #4
0
    def _unprotect_cache_value(self, token, data):
        """ Decrypt or verify signed data if necessary. """
        if data is None:
            return data

        try:
            if self._memcache_security_strategy == 'ENCRYPT':
                return memcache_crypt.decrypt_data(token,
                                                   self._memcache_secret_key,
                                                   data)
            elif self._memcache_security_strategy == 'MAC':
                return memcache_crypt.verify_signed_data(token, data)
            else:
                return data
        except:
            msg = 'Failed to decrypt/verify cache data.'
            self.LOG.exception(msg)
            # this should have the same effect as data not found in cache
            return None