Commit graph

8 commits

Author SHA1 Message Date
Kevin Israel
709f828c99 MWCryptHash: Clean up and add types of static fields
* Made $hashLength an int instead of an associative array of ints. All
  acceptable hash functions have a digest size that is a multiple of
  8 bits, so the hex length is always twice the binary (byte) length.
* Added types of both $algo and $hashLength using PHP 7.4 syntax.

Change-Id: Idc4592aa69a546b27bb0e77a3689f5d14d9ba7b8
2023-01-14 01:30:29 -05:00
Kevin Israel
21d9c94f7b MWCryptHash: Clean up check for acceptable hashing algorithms
* Replaced use of hash_algos() with hash_hmac_algos(), which was added
  in PHP 7.2 and omits non-cryptographic hashing algorithms that are not
  supported by hash_hmac().
* Removed MD5 and SHA-1 from the list of acceptable hash functions.
  These functions are cryptographically broken and are not being used
  anyway; all supported PHP versions support Whirlpool and SHA-256.
* Made the in_array() comparison strict as per coding conventions.

Change-Id: I3a3d43a790f71a4875a39c8788bef67ecf0181f0
2022-07-10 05:15:56 -04:00
Kevin Israel
5ad4da0f19 MWCryptHash: Remove "acceptably unstable" from doc comments
These words referred to uses in MWCryptRand that were removed in
9bab7de5f8 and do not make much sense outside that context.

Change-Id: I0e05b357741a166a3fc5225fc4391764ba6e99a4
2022-07-10 05:15:56 -04:00
Umherirrender
1f71eccf63 phan: Disable null_casts_as_any_type setting
Make phan stricter about null types by setting null_casts_as_any_type to
false (the default in mediawiki-phan-config)
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T242536
Bug: T301991
Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
2022-03-21 18:25:07 +00:00
Umherirrender
0855bbe8ad MWCryptHash: Avoid bool as array key
php allows only int|string. Use strings instead to avoid implicit casts

Change-Id: Ibc9bfa6199d3794095f1619d92cc406ccf1b1e6b
2021-08-26 21:43:12 +00:00
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
Max Semenik
06a275f48e Remove more HHVM hacks
Change-Id: I6bd298ef3b887173b87004ee055be2a4f6ea5f11
2019-10-06 10:16:09 +00:00
Kunal Mehta
9300bc2933 Move MWCryptHash into libs/
Remove the single wfDebug() call that was making this class MW specific,
someone can log the return value of MWCryptHash::hashAlgo() if they'd
like to know the specific implementation being used.

Change-Id: Ibb7ead7594edab7861631046dd8316daab613401
2016-10-01 23:19:28 -07:00
Renamed from includes/utils/MWCryptHash.php (Browse further)