Skip to content

Backport #198 to v1.x - #199

Merged
paragonie-security merged 1 commit into
v1.xfrom
v1.x-pr198-backport
Oct 4, 2025
Merged

paragonie-security merged 1 commit into
v1.xfrom
v1.x-pr198-backport

Conversation

@paragonie-security

@paragonie-security paragonie-security commented Oct 4, 2025 •

Copy link
Copy Markdown
Contributor

This is a backport of #198 to the v1.x branch. It's not a 1:1 copy, as some code style changes occur in PHP 8.1+.

PHP Version This Pull Request v1.22.0 v1.21.1
5.3 1.92 minutes 2.11 minutes 2.12 minutes
5.4 1.54 minutes 1.8 minutes 1.71 minutes
5.5 1.33 minutes 1.64 minutes 1.64 minutes
5.6 1.24 minutes 1.54 minutes 1.53 minutes
7.0 38.43 seconds 46.38 seconds 44.93 seconds
7.1 31.86 seconds 36.24 seconds 35.78 seconds
7.2 41.27 seconds 45.9 seconds 45.77 seconds
7.3 00:41.152 00:45.740 00:46.385
7.4 00:39.549 00:43.711 00:45.834
8.0 00:34.710 00:41.857 00:39.286
8.1 00:31.464 00:38.130 00:38.373
8.2 00:31.056 00:34.393 00:33.866
8.3 00:33.630 00:37.106 00:36.239
8.4 00:32.698 00:34.855 00:35.049
8.5 00:32.682 00:34.838 00:37.018

In every version of PHP, this change results in a noticeable performance improvement.

By leveraging PHP's optimized object key access for what is effectively always a fixed-length array, we can remove some computational overhead and memory usage in by the PHP interpreter.

Since these memory access patterns are not secret (they were array indices from 0 to 9), the risk of side-channel leakage by this change is at least as low as what was previously implemented.

This is a backport of #198 to the v1.x branch. It's not a 1:1 copy, as some code style changes occur in PHP 8.1+.
@paragonie-security
paragonie-security merged commit a4d611b into v1.x Oct 4, 2025
18 checks passed
@paragonie-security
paragonie-security deleted the v1.x-pr198-backport branch October 4, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant