Commit Graph

97 Commits

Author SHA1 Message Date
Shannon Booth
bad44f8fc9 LibWeb: Remove Bindings/Forward.h from LibWeb/Forward.h
This was resulting in a whole lot of rebuilding whenever a new IDL
interface was added.

Instead, just directly include the prototype in every C++ file which
needs it. While we only really need a forward declaration in each cpp
file; including the full prototype header (which itself only includes
LibJS/Object.h, which is already transitively brought in by
PlatformObject) - it seems like a small price to pay compared to what
feels like a full rebuild of LibWeb whenever a new IDL file is added.

Given all of these includes are only needed for the ::initialize
method, there is probably a smart way of avoiding this problem
altogether. I've considered both using some macro trickery or generating
these functions somehow instead.
2024-04-27 18:29:35 -04:00
Matthew Olsson
aac873fcec LibWeb: Fix a few "missing visit_edges" warnings from the GC verifier 2024-04-07 07:03:13 +02:00
Matthew Olsson
8450041b52 LibWeb: Fix some GCVerifier warnings 2024-04-07 07:03:13 +02:00
stelar7
7c7f01b82f LibWeb: Add RSAOAEP.exportKey for the pkcs8 format 2024-04-05 21:53:12 +02:00
stelar7
f9dd028119 LibWeb: Add RSAOAEP.exportKey for the spki format 2024-04-05 21:53:12 +02:00
stelar7
9f3c3925e0 LibWeb: Implement skeleton of SubtleCrypto.deriveKey 2024-04-04 21:00:40 +02:00
stelar7
abf55fe33d LibWeb: Implement PBKDF2 getKeyLength for SubtleCrypto 2024-04-04 21:00:40 +02:00
stelar7
19bb62d60e LibWeb: Implement PBKDF2 deriveBits for SubtleCrypto 2024-04-04 21:00:40 +02:00
stelar7
daf2c4ce46 LibWeb: Implement skeleton of SubtleCrypto.deriveBits 2024-04-04 21:00:40 +02:00
stelar7
35676491ec LibWeb: Implement ED25519 verify for SubtleCrypto 2024-04-03 13:10:01 -06:00
stelar7
9ad10566b2 LibWeb: Implement ED25519 sign for SubtleCrypto 2024-04-03 13:10:01 -06:00
stelar7
ec015034bd LibWeb: Implement ED25519 generateKey for SubtleCrypto 2024-04-03 13:10:01 -06:00
stelar7
069295d132 LibWeb: Improve NotSupported error message for normalize_an_algorithm 2024-04-03 13:10:01 -06:00
stelar7
ae230c9150 LibWeb: Implement most of ECDSA verify for SubtleCrypto 2024-04-03 13:10:01 -06:00
stelar7
6906b7c1e6 LibWeb: Implement skeleton of SubtleCrypto.verify 2024-04-03 13:10:01 -06:00
stelar7
bc2a5e24bc LibWeb: Implement skeleton of ECDSA sign for SubtleCrypto 2024-04-03 13:10:01 -06:00
stelar7
41449814db LibWeb: Implement generateKey for ECDSA 2024-04-03 13:10:01 -06:00
stelar7
cfae6523be LibWeb: Implement skeleton of SubtleCrypto.sign 2024-04-03 13:10:01 -06:00
Andrew Kaster
cddbdf5ae9 LibWeb: Implement skeleton of RSA-OAEP decrypt for SubtleCrypto
The actual Crypto algorithm part isn't implemented yet, so we just copy
the ciphertext and claim that's the plaintext :^)
2024-03-25 17:01:23 -06:00
Andrew Kaster
29b68a1b10 LibWeb: Implement skeleton of RSA-OAEP encrypt for SubtleCrypto
The actual Crypto algorithm part isn't implemented yet, so we just copy
the plaintext and claim that's the ciphertext :^)
2024-03-25 17:01:23 -06:00
Andrew Kaster
d71bd185c6 LibWeb: Implement skeleton of SubtleCrypto.decrypt 2024-03-25 17:01:23 -06:00
Andrew Kaster
df3d0538a9 LibWeb: Implement skeleton of SubtleCrypto.encrypt
No algorithms implement this yet, but this is the high level entry
point.
2024-03-25 17:01:23 -06:00
Andrew Kaster
ae4d90c88a LibWeb: Error out SubtleCrypto.digest with a OOM on Buffer copy error
Instead of returning a custom OperationError, let's just return a LibJS
defined OOM error instead.
2024-03-25 17:01:23 -06:00
Andrew Kaster
497f3ca0fd LibWeb: Store PBKDF2Params' salt field as a ByteBuffer directly
Rather than trying to store a Handle to a WebIDL::BufferSource, let's
look ahead to what the spec wants us to do with this field and get a
copy of the bytes held by the buffer source right away.
2024-03-25 17:01:23 -06:00
Andrew Kaster
a0623a47de LibWeb: Implement importKey for RSA-OAEP 2024-03-25 17:01:23 -06:00
Andrew Kaster
28dc076764 LibWeb: Use a forgiving base64url encoding for JWK export 2024-03-25 17:01:23 -06:00
Andrew Kaster
e422c93537 LibWeb: Make normalize_an_algorithm from SubtleCrypto public
We'll need to call this from other source files when implementing
specific algorithms.
2024-03-25 17:01:23 -06:00
Kenneth Myhra
52f056503d LibWeb: Add {,de}serialization steps for CryptoKey 2024-03-20 09:16:01 +01:00
Andreas Kling
c0d7f748ed LibWeb: Avoid FlyString lookups when setting IDL interface prototypes
This commit introduces a WEB_SET_PROTOTYPE_FOR_INTERFACE macro that
caches the interface name in a local static FlyString. This means that
we only pay for FlyString-from-literal lookup once per browser lifetime
instead of every time the interface is instantiated.
2024-03-16 16:35:54 +01:00
Andrew Kaster
1521a60a67 LibWeb: Support SubtleCrypto.exportKey for RSA-OAEP in JsonWebKey format 2024-03-14 17:57:37 -06:00
Andrew Kaster
2599142214 LibWeb: Export UnsignedBigInts into Uint8Arrays without losing bytes
The behavior of Crypto::UnsignedBigInt::export_data unexpectedly
does not actually remove leading zero bytes when the corresponding
parameter is passed. The caller must manually adjust for the location
of the zero bytes.
2024-03-14 17:57:37 -06:00
Andrew Kaster
0a3d27c41d LibWeb: Make SubtleCrypto AlgorithmParams classes virtual
This allows us to properly destroy the child classes through a pointer
to the base class, avoiding ASAN/UBSAN errors.
2024-03-14 17:57:37 -06:00
Andrew Kaster
a9d240c647 LibWeb: Implement SubtleCrypto.generateKey for RSA-OAEP
This patch implements and tests window.crypto.sublte.generateKey with
an RSA-OAEP algorithm. In order for the types to be happy, the
KeyAlgorithms objects are moved to their own .h/.cpp pair, and the new
KeyAlgorithms for RSA are added there.
2024-03-13 15:31:00 -06:00
Andrew Kaster
0b4858e589 LibWeb: Implement SubtleCrypto.generateKey skeleton
We don't have any algorithms defined that actually support generateKey,
but now all the scaffolding is there.
2024-03-13 15:31:00 -06:00
Andrew Kaster
810be6af07 LibWeb: Add CryptoKeyPair object for use in upcoming SubtleCrypto APIs 2024-03-13 15:31:00 -06:00
Andrew Kaster
0a6f195a71 LibWeb: Implement usages property for CryptoKey
And set it from the only place we currently create a CryptoKey, in
importKey.
2024-03-13 15:31:00 -06:00
Andrew Kaster
2d59d6c98c LibWeb: Refactor SubtleCrypto to allow adding more algorithms easier
This patch throws away some of the spec suggestions for how to implement
the normalize_algorithm AO and uses a new pattern that we can actually
extend in our C++.

Also update CryptoKey to store the key data.
2024-03-13 15:31:00 -06:00
Sam Atkins
4bdb7dba8c LibWeb: Add and use a helper to reject a promise with an exception 2024-03-08 14:14:57 -05:00
Johannes Røsvik
d89e617a42 LibWeb: Make SubtleCrypto use the correct algorithm name for SHA-1
The spec defines "SHA-1" as a recognized algorithm name, not "SHA1".

This makes SHA-1 hash values show up on string.248.no.
2024-03-03 08:41:32 +01:00
stelar7
423e77d5c3 LibWeb: Implement import_key for PBKDF2
Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2024-01-23 14:07:06 -07:00
Andrew Kaster
7bc7e2a48f LibWeb: Convert SubtleCrypto::digest to use WebIDL Promises
We should be using WebIDL Promise in these methods, per the spec
references in other specifications. That is, the HTML spec always links
to WebIDL when it talks about `Promise<T>`. The Crypto seems to be
missing those cross-references.

While we're here, actually resolve the digest promise in parallel.
2024-01-23 14:07:06 -07:00
stelar7
3e0c0ce7ae LibWeb: Move dictionaries to separate file
Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2024-01-23 14:07:06 -07:00
stelar7
1bf73482f5 LibWeb: Add using statement for simpler type names 2024-01-23 14:07:06 -07:00
stelar7
0afea792e2 LibWeb: Move dictionaries to the Bindings namespace 2024-01-23 14:07:06 -07:00
stelar7
a8ddf6c2a4 LibWeb: Add the CryptoKey interface 2024-01-23 14:07:06 -07:00
Bastiaan van der Plaat
5f5ac48908 LibWeb: Format all .idl files to use four space indentation 2024-01-18 14:00:06 +01:00
Timothy Flynn
9258d7b98a LibJS+LibWeb: Implement resizable ArrayBuffer support for TypedArray
This is (part of) a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/a9ae96e
2023-12-26 11:16:10 +01:00
stelar7
b2b5297997 LibWeb: Implement normalize_an_algorithm 2023-12-15 21:37:51 +01:00
stelar7
635ad9e9b8 LibWeb: Use AlgorithmIdentifier in SubtleCrypto IDL 2023-12-15 21:37:51 +01:00
Shannon Booth
96af80acd1 LibWeb: Port Intrinsics from DeprecatedString 2023-11-28 17:15:27 -05:00