• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

azjezz / psl / 22639242943

03 Mar 2026 07:30PM UTC coverage: 97.792% (-0.4%) from 98.201%
22639242943

Pull #607

github

azjezz
feat: introduce `Crypto` component

Signed-off-by: azjezz <azjezz@protonmail.com>
Pull Request #607: feat: introduce `Crypto` component

348 of 394 new or added lines in 49 files covered. (88.32%)

2 existing lines in 1 file now uncovered.

9302 of 9512 relevant lines covered (97.79%)

39.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/src/Psl/Crypto/Hkdf/extract.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\Crypto\Hkdf;
6

7
use Psl\Encoding\Hex;
8
use Psl\Hash\Hmac;
9
use SensitiveParameter;
10

11
use function str_repeat;
12

13
/**
14
 * HKDF-Extract: Extract a pseudorandom key from input keying material.
15
 *
16
 * @see https://tools.ietf.org/html/rfc5869#section-2.2
17
 */
18
function extract(
19
    #[SensitiveParameter] string $input_keying_material,
20
    string $salt = '',
21
    Hmac\Algorithm $algorithm = Hmac\Algorithm::Sha256,
22
): string {
23
    if ($salt === '') {
11✔
24
        /** @var non-negative-int $hashLength */
25
        $hashLength = match ($algorithm) {
2✔
26
            Hmac\Algorithm::Sha256 => 32,
2✔
NEW
27
            Hmac\Algorithm::Sha384 => 48,
×
NEW
28
            Hmac\Algorithm::Sha512 => 64,
×
NEW
29
            default => 32,
×
30
        };
2✔
31

32
        /** @var non-empty-string $salt */
33
        $salt = str_repeat("\x00", $hashLength);
2✔
34
    }
35

36
    return Hex\decode(Hmac\hash($input_keying_material, $algorithm, $salt));
11✔
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc