mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Fix ED25519
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:
parent
6e33dbb533
commit
9613b87b12
Notes:
github-actions[bot]
2024-12-16 10:36:49 +00:00
Author: https://github.com/devgianlu Commit: https://github.com/LadybirdBrowser/ladybird/commit/9613b87b129 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2915
1 changed files with 6 additions and 2 deletions
|
@ -4507,10 +4507,14 @@ WebIDL::ExceptionOr<GC::Ref<JS::Object>> 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));
|
||||
|
|
Loading…
Add table
Reference in a new issue