mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 05:52:53 +00:00
LibWeb: Add RSAOAEP.exportKey for the spki format
This commit is contained in:
parent
1fd6673f87
commit
f9dd028119
Notes:
sideshowbarker
2024-07-17 07:11:12 +09:00
Author: https://github.com/stelar7
Commit: f9dd028119
Pull-request: https://github.com/SerenityOS/serenity/pull/23851
2 changed files with 43 additions and 5 deletions
|
@ -788,19 +788,27 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Object>> RSAOAEP::export_key(Bindings::
|
|||
if (key->type() != Bindings::KeyType::Public)
|
||||
return WebIDL::InvalidAccessError::create(realm, "Key is not public"_fly_string);
|
||||
|
||||
// FIXME: 2. Let data be an instance of the subjectPublicKeyInfo ASN.1 structure defined in [RFC5280] with the following properties:
|
||||
// 2. Let data be an instance of the subjectPublicKeyInfo ASN.1 structure defined in [RFC5280] with the following properties:
|
||||
// - Set the algorithm field to an AlgorithmIdentifier ASN.1 type with the following properties:
|
||||
// - Set the algorithm field to the OID rsaEncryption defined in [RFC3447].
|
||||
// - Set the params field to the ASN.1 type NULL.
|
||||
// - Set the subjectPublicKey field to the result of DER-encoding an RSAPublicKey ASN.1 type, as defined in [RFC3447], Appendix A.1.1,
|
||||
// that represents the RSA public key represented by the [[handle]] internal slot of key
|
||||
auto maybe_data = handle.visit(
|
||||
[&](::Crypto::PK::RSAPublicKey<> const& public_key) -> ErrorOr<ByteBuffer> {
|
||||
auto rsa_encryption_oid = Array<int, 7> { 1, 2, 840, 113549, 1, 1, 1 };
|
||||
return TRY(::Crypto::PK::wrap_in_subject_public_key_info(public_key, rsa_encryption_oid));
|
||||
},
|
||||
[](auto) -> ErrorOr<ByteBuffer> {
|
||||
VERIFY_NOT_REACHED();
|
||||
});
|
||||
// FIXME: clang-format butchers the visit if we do the TRY inline
|
||||
auto data = TRY_OR_THROW_OOM(vm, maybe_data);
|
||||
|
||||
// FIXME: 3. Let result be the result of creating an ArrayBuffer containing data.
|
||||
result = JS::ArrayBuffer::create(realm, TRY_OR_THROW_OOM(vm, ByteBuffer::copy(("FIXME"sv).bytes())));
|
||||
// 3. Let result be the result of creating an ArrayBuffer containing data.
|
||||
result = JS::ArrayBuffer::create(realm, data);
|
||||
}
|
||||
|
||||
// FIXME: If format is "pkcs8"
|
||||
|
||||
// If format is "jwk"
|
||||
else if (format == Bindings::KeyFormat::Jwk) {
|
||||
// 1. Let jwk be a new JsonWebKey dictionary.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue