mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb: Fix X25519 PCKS#8 key export format
The ASN1 structure for PCKS#8 was wrong and missing one wrapping of the key in a OctetString. The issue was discovered while implementing `wrapKey` and `unwrapKey` in the next commits.
This commit is contained in:
@@ -5202,7 +5202,10 @@ WebIDL::ExceptionOr<GC::Ref<JS::Object>> X25519::export_key(Bindings::KeyFormat
|
||||
// Set the privateKey field to the result of DER-encoding a CurvePrivateKey ASN.1 type, as defined in Section 7 of [RFC8410],
|
||||
// that represents the X25519 private key represented by the [[handle]] internal slot of key
|
||||
auto private_key = handle.get<ByteBuffer>();
|
||||
auto data = TRY_OR_THROW_OOM(vm, ::Crypto::PK::wrap_in_private_key_info(private_key, ::Crypto::ASN1::x25519_oid));
|
||||
|
||||
::Crypto::ASN1::Encoder encoder;
|
||||
TRY_OR_THROW_OOM(vm, encoder.write(private_key));
|
||||
auto data = TRY_OR_THROW_OOM(vm, ::Crypto::PK::wrap_in_private_key_info(encoder.finish(), ::Crypto::ASN1::x25519_oid));
|
||||
|
||||
// 3. Let result be a new ArrayBuffer associated with the relevant global object of this [HTML], and containing data.
|
||||
result = JS::ArrayBuffer::create(m_realm, data);
|
||||
|
||||
Reference in New Issue
Block a user