Commit Graph

52693 Commits

Author SHA1 Message Date
Nico Weber
12e77cba0a LibPDF: Move "7.6.2 General Encryption Algorithm" comment down a bit
The algorithm really only starts a bit later in the function,
so move the comment to there.
2023-07-21 11:55:20 +02:00
Nico Weber
6d0dbaf9d7 LibPDF: Extract aes helper in StandardSecurityHandler::crypt()
No behavior change, pure code move.

We'll use this for AESV3.
2023-07-21 11:55:20 +02:00
Nico Weber
9cbdb334ab LibPDF: Make try_provide_user_password() work for R6+ files
try_provide_user_password() calls compute_encryption_key_r6_and_later()
now. This checks both owner and user passwords. (For pre-R6 files,
owner password checking isn't yet implemented, as far as I can tell.)

With this, CIPA_DC-007-2021_E.pdf (or other AESV3-encrypted files)
successfully compute a file encryption key (...and then hit the
TODO() in StandardSecurityHandler::crypt() for AESV3, but it's
still good progress.)
2023-07-21 11:55:20 +02:00
Nico Weber
0428308420 LibPDF: Implement 7.6.4.3.3 Algorithm 2.A: Retrieve file encryption key
...for handlers of revision 6.

The spec for this algorithm has several quirks:

1. It describes how to authenticate a password as an owner password,
   but it redundantly inlines the description of algorithm 12 instead
   of referring to it. We just call that algorithm here.

2. It does _not_ describe how to authenticate a password as a user
   password before using the password to compute the file encryption
   key using an intermediate user key, despite the latter step that
   computes the file encryption key refers to the password as
   "user password". I added a call to algorithm 11 to check if the
   password is the user password that isn't in the spec. Maybe I'm
   misunderstanding the spec, but this looks like a spec bug to me.

3. It says "using AES-256 in ECB mode with an initialization vector
   of zero". ECB mode has no initialization vector. CBC mode with
   initialization vector of zero for message length 16 is the same
   as ECB mode though, so maybe that's meant? (In addition to the
   spec being a bit wobbly, using EBC in new software isn't
   recommended, but too late for that.)

SASLprep / stringprep still aren't implemented. For ASCII passwords
(including the important empty password), this is good enough.
2023-07-21 11:55:20 +02:00
Nico Weber
f8a3022ca2 LibPDF: Plumb OE, UE, Perms values to StandardSecurityHandler 2023-07-21 11:55:20 +02:00
Nico Weber
57768325cc LibPDF: Implement 7.6.4.4.11 Algorithm 12: Authenticating owner password
...for handlers of revision 6.

Since this adds U to the hash input, also trim the size of U and O to
48 bytes. The spec requires them to be 48 bytes, but all the newer PDFs
on https://cipa.jp/e/std/std-sec.html have 127 bytes -- 48 real bytes
and 79 nul padding bytes. These files were created by:

    Creator: Word 用 Acrobat PDFMaker 17
    Producer: Adobe PDF Library 15.0

and

    Creator: Word 用 Acrobat PDFMaker 17
    Producer: Adobe PDF Library 17.11.238
2023-07-21 11:55:20 +02:00
Nico Weber
8f6c67a71c LibPDF: Implement 7.6.4.4.10 Algorithm 11: Authenticating user password
...for handlers of revision 6.
2023-07-21 11:55:20 +02:00
Nico Weber
f23a394aac LibPDF: Stop using MUST in Encryption.cpp
...and use `release_value_but_fixme_should_propagate_errors()` instead,
as requested by mattco98.
2023-07-21 11:55:20 +02:00
MacDue
30277f385c LibWeb: Add an initial implementation of SVG text-anchor
This only handles very simple <text> elements, but this is enough (with
the font-size changes) to improve the badges on the GitHub README a fair
bit.
2023-07-21 11:42:30 +02:00
MacDue
4cdb4de049 LibWeb: Enable quirks when parsing SVGGraphicsElement CSS attributes
This allows valid SVG attributes such as `font-size` with a unitless
value to be parsed successfully (in an admittedly hacky way).
2023-07-21 11:42:30 +02:00
MacDue
48d03a68e9 LibWeb: Allow font-size as an SVG attribute and handle font scaling 2023-07-21 11:42:30 +02:00
MacDue
21ace4f90b LibWeb: Add Node::scaled_font(float scale_factor)
This will allow fetching fonts scaled by a transform.
2023-07-21 11:42:30 +02:00
MacDue
f84abbe1f9 LibWeb: Add FIXME for viewBox scaling to SVGTextBox 2023-07-21 11:42:30 +02:00
Nico Weber
6caaffa134 LibPDF: Add a few FIXMEs to set_graphics_state_from_dict 2023-07-21 08:17:12 +02:00
Nico Weber
9283c939bb LibPDF: Include width in Type1Font glyph cache key
LibGfx's ScaledFont doesn't do this, but in ScaledFont m_x_scale and
m_y_scale are immutable once the class is created, so it can get away
with not doing it.

In Type1Font, `width` changes in different calls to
Type1Font::draw_glyph(), so we need to make it part of the cache key.

Fixes rendering of the word "Version" on the first page of
pdf_reference_1-7.pdf.
2023-07-21 07:01:09 +02:00
MacDue
17a5af04e3 LibJS: Actually generate the bytecode CFG
This is just something I spotted looking around the code, previously
the PassPipelineExecutable was passed by value to
generate_cfg_for_block, which generated the CFG then just dropped it on
the floor. Making this a reference results in the CFG actually getting
generated.
2023-07-21 06:59:51 +02:00
Aliaksandr Kalenik
fb94415f03 LibJS: Delete Declaration::for_each_var_declared_name
1. Replaces for_each_var_declared_name usage with more generic
for_each_var_declared_identifier.
2. Deletes for_each_var_declared_name.
2023-07-20 20:19:15 +02:00
Aliaksandr Kalenik
0fa47405df LibJS: Delete Declaration::for_each_lexically_declared_name
1. Replaces for_each_lexically_declared_name usage with more generic
for_each_lexically_declared_identifier.
2. Deletes for_each_lexically_declared_name.
2023-07-20 20:19:15 +02:00
Aliaksandr Kalenik
231d58dd62 LibJS: Delete Declaration::for_each_bound_name
We can delete for_each_bound_name() because there is more generic
version of this function called for_each_bound_identifier() that gives
you identifier using which you can get both name and check if it is
local/global.
2023-07-20 20:19:15 +02:00
Aliaksandr Kalenik
348e43b36d LibJS: Replace for_each_bound_name with for_each_bound_identifier
Preparation before deleting for_each_bound_name.
2023-07-20 20:19:15 +02:00
Aliaksandr Kalenik
608a730bd6 LibWeb: Use Core::Timer for style and layout update timers in Document
Fixes leaking of DOM::Document by capturing it into JS::SafeFunction
callback when using Platform::Timer for style and layout update timers.
2023-07-20 15:01:52 +02:00
Sam Atkins
8ec691057f FileManager: Add "Font" tab to File Properties window
We now keep the MappedFile around when inspecting a font, so that we can
use that font to display a preview.
2023-07-20 08:02:12 +01:00
Sam Atkins
98eaa4b044 LibGfx: Add functions to convert font widths to/from strings
This isn't a "width" in the sense of a fixed-width font, but of the OS/2
width class defined in some font formats.
2023-07-20 08:02:12 +01:00
Sam Atkins
9f5e105958 LibCore: Add mime types for font files 2023-07-20 08:02:12 +01:00
Sam Atkins
50b6ed2aa3 FileManager: Add "Image" tab to File Properties window
We don't yet expose most image metadata yet, so most of this is ICC
profile data since we do have a way to access that.
2023-07-20 08:02:12 +01:00
Sam Atkins
835dada3d3 LibGfx: Add method to get String data from an ICC Profile tag 2023-07-20 08:02:12 +01:00
Sam Atkins
1066831b39 LibGfx: Add a method to get a specific tag from an ICC Profile 2023-07-20 08:02:12 +01:00
Sam Atkins
91b677c81e FileManager: Add "Audio" tab to File Properties window 2023-07-20 08:02:12 +01:00
Sam Atkins
0a9fa85e86 LibAudio: Use ReadonlyBytes instead of Bytes for buffer parameters
Bytes will implicitly cast to StringView, but not to ReadonlyBytes. That
means that if you call
`Audio::Loader::create_plugin(mapped_file->bytes())`
it will silently use the `create_plugin(StringView path)` overload.

Reading audio data does not require that data to be writable, so let's
use ReadonlyBytes for it and avoid the footgun.
2023-07-20 08:02:12 +01:00
Sam Atkins
8e0fa57e5b FileManager: Extract creation of PropertiesWindow General tab 2023-07-20 08:02:12 +01:00
Sam Atkins
a847bd463a FileManager: Remove unused PropertyValuePair struct 2023-07-20 08:02:12 +01:00
Sam Atkins
9cd6b97dd9 FileManager: Don't wrap long paths on Properties window
These have a fixed height, so any wrapping made them entirely illegible.
2023-07-20 08:02:12 +01:00
Kenneth Myhra
c0d0391d08 Toolchain+Ports: Update QEMU to 8.0.3 2023-07-20 07:24:40 +01:00
Kenneth Myhra
0263052284 Ports/glib: Reformat package.sh according to our current style 2023-07-20 07:24:40 +01:00
Kenneth Myhra
0bf8735aba Ports/glib: Update to 2.77.0 2023-07-20 07:24:40 +01:00
Kenneth Myhra
53db5d8b6c Ports/curl: Update to 8.2.0 2023-07-20 07:24:40 +01:00
Kenneth Myhra
1166f5a758 Ports/openssl: Reformat package.sh according to our current style 2023-07-20 07:24:40 +01:00
Kenneth Myhra
b38edc9d43 Ports/openssl: Update to 3.0.9
The 3.0 series is the new LTS version and is supported until 7th
September 2026. The 1.1.1 series which is the previous LTS version has
an end of support on 11th September 2023.
2023-07-20 07:24:40 +01:00
Matthew Olsson
25b89aa962 LibGfx: Replace a magic number in ScaledFont with the calculation
This makes the reason for the multiplication much clearer.
2023-07-20 06:56:41 +01:00
Matthew Olsson
5f8fd47214 LibPDF: Resize fonts when the text and line matrices change 2023-07-20 06:56:41 +01:00
Matthew Olsson
9a0e1dde42 LibPDF: Propogate errors from ColorSpace::color() 2023-07-20 06:56:41 +01:00
Matthew Olsson
e989008471 LibPDF: Use proper ICC profiles for ICCBasedColorSpace 2023-07-20 06:56:41 +01:00
Matthew Olsson
fa1b1f8244 LibGfx: Forward-declare TagData in WellKnownProfiles 2023-07-20 06:56:41 +01:00
Sebastian Zaha
7696738140 Meta: Port recent LibWeb and LibJS changes to gn build
This ports the following commits:
a8587fe54e
9d7215c636
2023-07-20 06:48:13 +01:00
Shannon Booth
a0d1ef34e2 LibJS: Deduplicate labelled continue & break bytecode generation
Similar to the scoped continue and break, the only two differences
between these functions is the scope that is scanned for a matching
label, and the specific handling of a continue/break boundary.
2023-07-20 07:24:31 +02:00
Shannon Booth
663e4507ea LibJS: Deduplicate scoped continue & break bytecode generation
The only two differences between these two functions are the name of the
block that is created and the specific jump/break handling per boundary.
2023-07-20 07:24:31 +02:00
Nico Weber
c4bad2186f LibPDF: Implement 7.6.4.3.4 Algorithm 2.B: Computing a hash
This is a step towards AESV3 support for PDF files.

The straight-forward way of writing this with our APIs is pretty
allocation-heavy, but this code won't run all that often for the
regular "open PDF, check password" flow.
2023-07-19 21:26:55 +01:00
Nico Weber
492962502f LibCrypto: Make create_aligned_buffer() static
I ended up not needing this, but there's no reason for this function
to not be static.
2023-07-19 21:26:55 +01:00
Sebastian Zaha
919033fffd Ladybird: Prevent QAction leaking
In some places in the code QAction instances are added to a parent
directly on instantiation. In the case they are not, Valgrind
reports them as leaking.
2023-07-19 21:26:43 +01:00
Sebastian Zaha
d974142c7e Ladybird: Allow copying text in the js console 2023-07-19 21:26:43 +01:00