| 326 | } |
| 327 | |
| 328 | bytes |
| 329 | HPKEPrivateKey::decrypt(CipherSuite suite, |
| 330 | const std::string& label, |
| 331 | const bytes& context, |
| 332 | const HPKECiphertext& ct) const |
| 333 | { |
| 334 | auto label_plus = mls_1_0_plus(label); |
| 335 | auto encrypt_context = tls::marshal(EncryptContext{ label_plus, context }); |
| 336 | auto skR = suite.hpke().kem.deserialize_private(data); |
| 337 | auto ctx = suite.hpke().setup_base_r(ct.kem_output, *skR, encrypt_context); |
| 338 | auto pt = ctx.open({}, ct.ciphertext); |
| 339 | if (!pt) { |
| 340 | throw InvalidParameterError("HPKE decryption failure"); |
| 341 | } |
| 342 | |
| 343 | return opt::get(pt); |
| 344 | } |
| 345 | |
| 346 | bytes |
| 347 | HPKEPrivateKey::do_export(CipherSuite suite, |
no test coverage detected