(self, enc_alg, ek, headers, key, sender_key, tag=None)
| 181 | return {"ek": b"", "cek": dk, "header": h} |
| 182 | |
| 183 | def unwrap(self, enc_alg, ek, headers, key, sender_key, tag=None): |
| 184 | if "epk" not in headers: |
| 185 | raise ValueError('Missing "epk" in headers') |
| 186 | |
| 187 | if self.key_size is None: |
| 188 | bit_size = enc_alg.CEK_SIZE |
| 189 | else: |
| 190 | # Per draft-madden-jose-ecdh-1pu-04 §2.1, the key wrapping mode |
| 191 | # rejects content encryption algorithms other than |
| 192 | # AES_CBC_HMAC_SHA2. |
| 193 | if not isinstance(enc_alg, CBCHS2EncAlgorithm): |
| 194 | raise InvalidEncryptionAlgorithmForECDH1PUWithKeyWrappingError() |
| 195 | |
| 196 | bit_size = self.key_size |
| 197 | |
| 198 | sender_pubkey = sender_key.get_op_key("wrapKey") |
| 199 | epk = key.import_key(headers["epk"]) |
| 200 | epk_pubkey = epk.get_op_key("wrapKey") |
| 201 | dk = self.deliver_at_recipient( |
| 202 | key, sender_pubkey, epk_pubkey, headers, bit_size, tag |
| 203 | ) |
| 204 | |
| 205 | if self.key_size is None: |
| 206 | return dk |
| 207 | |
| 208 | kek = self.aeskw.prepare_key(dk) |
| 209 | return self.aeskw.unwrap(enc_alg, ek, headers, kek) |
| 210 | |
| 211 | |
| 212 | JWE_DRAFT_ALG_ALGORITHMS = [ |
nothing calls this directly
no test coverage detected