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

Class KeyWrapper

samples/queue/encryption_usage.py:23–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 4

put_encrypted_messageMethod · 0.70
require_encryptionMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected