MCPcopy Create free account
hub / github.com/Azure/azure-storage-python / KeyWrapper

Class KeyWrapper

samples/blob/encryption_usage.py:24–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23# Sample implementations of the encryption-related interfaces.
24class KeyWrapper:
25 def __init__(self, kid):
26 self.kek = urandom(32)
27 self.backend = default_backend()
28 self.kid = 'local:' + kid
29
30 def wrap_key(self, key, algorithm='A256KW'):
31 if algorithm == 'A256KW':
32 return aes_key_wrap(self.kek, key, self.backend)
33 else:
34 raise ValueError(_ERROR_UNKNOWN_KEY_WRAP_ALGORITHM)
35
36 def unwrap_key(self, key, algorithm):
37 if algorithm == 'A256KW':
38 return aes_key_unwrap(self.kek, key, self.backend)
39 else:
40 raise ValueError(_ERROR_UNKNOWN_KEY_WRAP_ALGORITHM)
41
42 def get_key_wrap_algorithm(self):
43 return 'A256KW'
44
45 def get_kid(self):
46 return self.kid
47
48
49class KeyResolver:

Callers 4

put_encrypted_blobMethod · 0.70
get_encrypted_blobMethod · 0.70
require_encryptionMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected