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

Class KeyWrapper

tests/encryption_test_helper.py:19–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19class KeyWrapper:
20 def __init__(self, kid='local:key1'):
21 # Must have constant key value for recorded tests, otherwise we could use a random generator.
22 self.kek = b'\xbe\xa4\x11K\x9eJ\x07\xdafF\x83\xad+\xadvA C\xe8\xbc\x90\xa4\x11}G\xc3\x0f\xd4\xb4\x19m\x11'
23 self.backend = default_backend()
24 self.kid = kid
25
26 def wrap_key(self, key, algorithm='A256KW'):
27 if algorithm == 'A256KW':
28 return aes_key_wrap(self.kek, key, self.backend)
29 else:
30 raise ValueError(_ERROR_UNKNOWN_KEY_WRAP_ALGORITHM)
31
32 def unwrap_key(self, key, algorithm):
33 if algorithm == 'A256KW':
34 return aes_key_unwrap(self.kek, key, self.backend)
35 else:
36 raise ValueError(_ERROR_UNKNOWN_KEY_WRAP_ALGORITHM)
37
38 def get_key_wrap_algorithm(self):
39 return 'A256KW'
40
41 def get_kid(self):
42 return self.kid
43
44
45class KeyResolver:

Calls

no outgoing calls