# Path: simplekv/decorator.py
# class StoreDecorator(object):
#     """Base class for store decorators.
# 
#     The default implementation will use :func:`getattr` to pass through all
#     attribute/method requests to an underlying object stored as
#     :attr:`_dstore`. It will also pass through the :attr:`__getattr__` and
#     :attr:`__contains__` python special methods.
#     """
# 
#     def __init__(self, store):
#         self._dstore = store
# 
#     def __getattr__(self, attr):
#         store = object.__getattribute__(self, "_dstore")
#         return getattr(store, attr)
# 
#     def __contains__(self, *args, **kwargs):
#         return self._dstore.__contains__(*args, **kwargs)
# 
#     def __iter__(self, *args, **kwargs):
#         return self._dstore.__iter__(*args, **kwargs)


import hashlib
import hmac
import os
import tempfile
from .decorator import StoreDecorator
            offset = len(self.buffer) - self.hm.digest_size

        rv, self.buffer = self.buffer[:offset], self.buffer[offset:]

        # update hmac
        self.hm.update(rv)

        if finished:
            # check hash
            if not self.buffer == self.hm.digest():
                raise VerificationException('HMAC verification failed.')

        return rv

    def close(self):
        self.source.close()

    def __enter__(self):
        return self

    def __exit__(self, *args):
        self.close()


class VerificationException(Exception):
    """This exception is thrown whenever there was an error with an
    authenticity check performed by any of the decorators in this module."""
    pass



# Path: simplekv/decorator.py
# class StoreDecorator(object):
#     """Base class for store decorators.
# 
#     The default implementation will use :func:`getattr` to pass through all
#     attribute/method requests to an underlying object stored as
#     :attr:`_dstore`. It will also pass through the :attr:`__getattr__` and
#     :attr:`__contains__` python special methods.
#     """
# 
#     def __init__(self, store):
#         self._dstore = store
# 
#     def __getattr__(self, attr):
#         store = object.__getattribute__(self, "_dstore")
#         return getattr(store, attr)
# 
#     def __contains__(self, *args, **kwargs):
#         return self._dstore.__contains__(*args, **kwargs)
# 
#     def __iter__(self, *args, **kwargs):
#         return self._dstore.__iter__(*args, **kwargs)


# Path: simplekv/crypt.py
import hashlib
import hmac
import os
import tempfile
from .decorator import StoreDecorator

            offset = len(self.buffer) - self.hm.digest_size

        rv, self.buffer = self.buffer[:offset], self.buffer[offset:]

        # update hmac
        self.hm.update(rv)

        if finished:
            # check hash
            if not self.buffer == self.hm.digest():
                raise VerificationException('HMAC verification failed.')

        return rv

    def close(self):
        self.source.close()

    def __enter__(self):
        return self

    def __exit__(self, *args):
        self.close()


class VerificationException(Exception):
    """This exception is thrown whenever there was an error with an
    authenticity check performed by any of the decorators in this module."""
    pass



class HMACDecorator(StoreDecorator):