Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/cryptography/hazmat/primitives/kdf/__init__.py: 91%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

11 statements  

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 annotations 

6 

7import abc 

8 

9from cryptography.utils import Buffer 

10 

11 

12class KeyDerivationFunction(metaclass=abc.ABCMeta): 

13 @abc.abstractmethod 

14 def derive(self, key_material: bytes) -> bytes: 

15 """ 

16 Deterministically generates and returns a new key based on the existing 

17 key material. 

18 """ 

19 

20 @abc.abstractmethod 

21 def derive_into(self, key_material: bytes, buffer: Buffer) -> None: 

22 """ 

23 Deterministically generates a new key based on the existing key 

24 material and stores it in the provided buffer. 

25 """ 

26 

27 @abc.abstractmethod 

28 def verify(self, key_material: bytes, expected_key: bytes) -> None: 

29 """ 

30 Checks whether the key generated by the key material matches the 

31 expected derived key. Raises an exception if they do not match. 

32 """