diff --git a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp index 6cce56120b6..578f7b60439 100644 --- a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp +++ b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp @@ -4507,10 +4507,14 @@ WebIDL::ExceptionOr> ED25519::export_key(Bindings::KeyFormat // * Set the version field to 0. // * Set the privateKeyAlgorithm field to a PrivateKeyAlgorithmIdentifier ASN.1 type with the following properties: // * Set the algorithm object identifier to the id-Ed25519 OID defined in [RFC8410]. - // * 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 Ed25519 private key represented by the [[handle]] internal slot of key + // * 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 Ed25519 private key + // represented by the [[handle]] internal slot of key + ::Crypto::ASN1::Encoder encoder; + TRY_OR_THROW_OOM(vm, encoder.write(key_data.bytes())); auto ed25519_oid = ::Crypto::ASN1::ed25519_oid; - auto data = TRY_OR_THROW_OOM(vm, ::Crypto::PK::wrap_in_private_key_info(key_data, ed25519_oid, nullptr)); + auto data = TRY_OR_THROW_OOM(vm, ::Crypto::PK::wrap_in_private_key_info(encoder.finish(), ed25519_oid, nullptr)); // 3. Let result be a new ArrayBuffer associated with the relevant global object of this [HTML], and containing data. return JS::ArrayBuffer::create(m_realm, move(data));