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

azjezz / psl / 9286105259

29 May 2024 12:29PM UTC coverage: 87.311% (-10.0%) from 97.267%
9286105259

Pull #451

github

azjezz
feat(tcp): support TLS/SSL

Signed-off-by: azjezz <azjezz@protonmail.com>
Pull Request #451: feat(tcp): add support for TLS/SSL in TCP

37 of 627 new or added lines in 16 files covered. (5.9%)

2 existing lines in 1 file now uncovered.

5030 of 5761 relevant lines covered (87.31%)

46.26 hits per line

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

0.0
/src/Psl/TCP/TLS/HashingAlgorithm.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\TCP\TLS;
6

7
use Psl\Default\DefaultInterface;
8

9
/**
10
 * Defines the hashing algorithms supported for generating and verifying TLS certificate fingerprints.
11
 *
12
 * This enum facilitates the use of strictly typed hashing algorithms throughout the TLS configuration,
13
 * ensuring that only supported and correctly implemented algorithms are utilized.
14
 */
15
enum HashingAlgorithm: string implements DefaultInterface
16
{
17
    /**
18
     * Represents the SHA-1 hashing algorithm.
19
     *
20
     * SHA-1 produces a 40-character hexadecimal fingerprint. It's less secure than SHA-256 due to vulnerabilities
21
     * that allow for collision attacks, and its use is generally discouraged in favor of stronger algorithms.
22
     */
23
    case Sha1 = 'sha1';
24

25
    /**
26
     * Represents the SHA-256 hashing algorithm.
27
     *
28
     * SHA-256 is a member of the SHA-2 cryptographic hash functions designed by the NSA, producing a 64-character
29
     * hexadecimal fingerprint. It's more secure than SHA-1 and recommended for modern security requirements.
30
     */
31
    case Sha256 = 'sha256';
32

33
    /**
34
     * Provides the default hashing algorithm used for TLS certificate fingerprints.
35
     *
36
     * The default is set to SHA-256 due to its enhanced security over SHA-1, making it the
37
     * recommended choice for modern security requirements. This method offers a straightforward
38
     * way to access the preferred default hashing algorithm when configuring TLS options.
39
     *
40
     * @pure
41
     */
42
    public static function default(): static
43
    {
NEW
44
        return static::Sha256;
×
45
    }
46

47
    /**
48
     * Retrieves the expected length of the fingerprint generated by the hashing algorithm.
49
     *
50
     * @mutation-free
51
     */
52
    public function getExpectedLength(): int
53
    {
NEW
54
        return match ($this) {
×
NEW
55
            self::Sha1 => 40,
×
NEW
56
            self::Sha256 => 64,
×
NEW
57
        };
×
58
    }
59
}
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

© 2025 Coveralls, Inc