1# This file is dual licensed under the terms of the Apache License, Version 2# 2.0, and the BSD License. See the LICENSE file in the root of this repository 3# for complete details. 4 5from __future__ import absolute_import, division, print_function 6 7import abc 8 9import six 10 11 12@six.add_metaclass(abc.ABCMeta) 13class MACContext(object): 14 @abc.abstractmethod 15 def update(self, data): 16 """ 17 Processes the provided bytes. 18 """ 19 20 @abc.abstractmethod 21 def finalize(self): 22 """ 23 Returns the message authentication code as bytes. 24 """ 25 26 @abc.abstractmethod 27 def copy(self): 28 """ 29 Return a MACContext that is a copy of the current context. 30 """ 31 32 @abc.abstractmethod 33 def verify(self, signature): 34 """ 35 Checks if the generated message authentication code matches the 36 signature. 37 """ 38