mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-20 18:12:53 +00:00
LibWeb: Fix X448
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
89f1f3f31c
commit
06733bea48
Notes:
github-actions[bot]
2024-12-16 10:36:08 +00:00
Author: https://github.com/devgianlu
Commit: 06733bea48
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2915
2 changed files with 13 additions and 11 deletions
|
@ -5447,8 +5447,11 @@ WebIDL::ExceptionOr<GC::Ref<JS::Object>> X448::export_key(Bindings::KeyFormat fo
|
|||
// * Set the privateKeyAlgorithm field to a PrivateKeyAlgorithmIdentifier ASN.1 type with the following properties:
|
||||
// * Set the algorithm object identifier to the id-X448 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 X448 private key represented by the [[handle]] internal slot of key
|
||||
::Crypto::ASN1::Encoder encoder;
|
||||
TRY_OR_THROW_OOM(m_realm->vm(), encoder.write(key_data.bytes()));
|
||||
|
||||
auto x448_oid = ::Crypto::ASN1::x448_oid;
|
||||
auto data = TRY_OR_THROW_OOM(m_realm->vm(), ::Crypto::PK::wrap_in_private_key_info(key_data, x448_oid));
|
||||
auto data = TRY_OR_THROW_OOM(m_realm->vm(), ::Crypto::PK::wrap_in_private_key_info(encoder.finish(), x448_oid));
|
||||
|
||||
// 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, data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue