__init__.py 771 B

1234567891011121314151617181920212223242526
  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. from __future__ import absolute_import, division, print_function
  5. import abc
  6. import six
  7. @six.add_metaclass(abc.ABCMeta)
  8. class KeyDerivationFunction(object):
  9. @abc.abstractmethod
  10. def derive(self, key_material):
  11. """
  12. Deterministically generates and returns a new key based on the existing
  13. key material.
  14. """
  15. @abc.abstractmethod
  16. def verify(self, key_material, expected_key):
  17. """
  18. Checks whether the key generated by the key material matches the
  19. expected derived key. Raises an exception if they do not match.
  20. """