diff --git a/Libraries/LibCrypto/PK/RSA.cpp b/Libraries/LibCrypto/PK/RSA.cpp index 120f87c26e2..301ae19e5c1 100644 --- a/Libraries/LibCrypto/PK/RSA.cpp +++ b/Libraries/LibCrypto/PK/RSA.cpp @@ -10,12 +10,11 @@ #include #include #include +#include #include namespace Crypto::PK { -static constexpr Array pkcs8_rsa_key_oid { 1, 2, 840, 113549, 1, 1, 1 }; - RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes der) { // we are going to assign to at least one of these @@ -96,7 +95,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes der) auto oid = oid_result.release_value(); // Now let's check that the OID matches "RSA key" - if (oid != pkcs8_rsa_key_oid) { + if (oid != Crypto::Certificate::rsa_encryption_oid) { // Oh well. not an RSA key at all. dbgln_if(RSA_PARSE_DEBUG, "RSA PKCS#8 public key parse failed: Not an RSA key"); return false; diff --git a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp index b0f392d4d03..3ab0a37f0ad 100644 --- a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp +++ b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp @@ -1110,8 +1110,7 @@ WebIDL::ExceptionOr> RSAOAEP::export_key(Bindings::KeyFormat // 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 { - auto rsa_encryption_oid = Array { 1, 2, 840, 113549, 1, 1, 1 }; - return TRY(::Crypto::PK::wrap_in_subject_public_key_info(public_key, rsa_encryption_oid)); + return TRY(::Crypto::PK::wrap_in_subject_public_key_info(public_key, Array { ::Crypto::Certificate::rsa_encryption_oid })); }, [](auto) -> ErrorOr { VERIFY_NOT_REACHED(); @@ -1138,8 +1137,7 @@ WebIDL::ExceptionOr> RSAOAEP::export_key(Bindings::KeyFormat // that represents the RSA private key represented by the [[handle]] internal slot of key auto maybe_data = handle.visit( [&](::Crypto::PK::RSAPrivateKey<> const& private_key) -> ErrorOr { - auto rsa_encryption_oid = Array { 1, 2, 840, 113549, 1, 1, 1 }; - return TRY(::Crypto::PK::wrap_in_private_key_info(private_key, rsa_encryption_oid)); + return TRY(::Crypto::PK::wrap_in_private_key_info(private_key, Array { ::Crypto::Certificate::rsa_encryption_oid })); }, [](auto) -> ErrorOr { VERIFY_NOT_REACHED(); @@ -3659,8 +3657,7 @@ WebIDL::ExceptionOr> X25519::export_key(Bindings::KeyFormat // Set the algorithm object identifier to the id-X25519 OID defined in [RFC8410]. // Set the subjectPublicKey field to keyData. auto public_key = handle.get(); - auto x25519_oid = Array { 1, 3, 101, 110 }; - auto data = TRY_OR_THROW_OOM(vm, ::Crypto::PK::wrap_in_subject_public_key_info(public_key, x25519_oid)); + auto data = TRY_OR_THROW_OOM(vm, ::Crypto::PK::wrap_in_subject_public_key_info(public_key, Array { ::Crypto::Certificate::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); @@ -3679,8 +3676,7 @@ WebIDL::ExceptionOr> 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(); - auto x25519_oid = Array { 1, 3, 101, 110 }; - auto data = TRY_OR_THROW_OOM(vm, ::Crypto::PK::wrap_in_private_key_info(private_key, x25519_oid)); + auto data = TRY_OR_THROW_OOM(vm, ::Crypto::PK::wrap_in_private_key_info(private_key, Array { ::Crypto::Certificate::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);