MCPcopy
hub / github.com/authlib/authlib / wrap

Method wrap

authlib/jose/rfc7518/jwe_algs.py:66–76  ·  view source on GitHub ↗
(self, enc_alg, headers, key, preset=None)

Source from the content-addressed store, hash-verified

64 return {"cek": cek}
65
66 def wrap(self, enc_alg, headers, key, preset=None):
67 if preset and "cek" in preset:
68 cek = preset["cek"]
69 else:
70 cek = enc_alg.generate_cek()
71
72 op_key = key.get_op_key("wrapKey")
73 if op_key.key_size < self.key_size:
74 raise ValueError("A key of size 2048 bits or larger MUST be used")
75 ek = op_key.encrypt(cek, self.padding)
76 return {"ek": ek, "cek": cek}
77
78 def unwrap(self, enc_alg, ek, headers, key):
79 op_key = key.get_op_key("unwrapKey")

Callers 1

wrapMethod · 0.45

Calls 3

generate_cekMethod · 0.80
get_op_keyMethod · 0.45
encryptMethod · 0.45

Tested by

no test coverage detected