LibWeb: Support the exporting of ml-kem keys in raw-seed format

This commit is contained in:
Tete17
2026-01-04 17:45:39 +01:00
committed by Shannon Booth
parent ed025f5fcd
commit df0796bdf2
Notes: github-actions[bot] 2026-01-06 00:07:44 +00:00
3 changed files with 42 additions and 27 deletions

View File

@@ -9286,7 +9286,20 @@ WebIDL::ExceptionOr<GC::Ref<JS::Object>> MLKEM::export_key(Bindings::KeyFormat f
// 3. Let result be data.
result = JS::ArrayBuffer::create(m_realm, data);
}
// FIXME: -> If format is "raw-seed":
// -> If format is "raw-seed":
else if (format == Bindings::KeyFormat::RawSeed) {
// 1. If the [[type]] internal slot of key is not "private", then throw an InvalidAccessError.
if (key->type() != Bindings::KeyType::Private)
return WebIDL::InvalidAccessError::create(m_realm, "Key is not a private key"_utf16);
// 2. Let data be a byte sequence containing the concatenation of the d and z seed variables of the
// key represented by the [[handle]] internal slot of key.
VERIFY(key->handle().has<::Crypto::PK::MLKEMPrivateKey>());
auto const data = key->handle().get<::Crypto::PK::MLKEMPrivateKey>().seed();
// 3. Let result be data.
result = JS::ArrayBuffer::create(m_realm, data);
}
// FIXME: -> If format is "jwk":
// -> Otherwise:
else {