summary refs log tree commit diff
path: root/crypto/src/tls/CertificateCompressionAlgorithm.cs
blob: 4b6ebdadcbeed0e0ed0e93094b912b862891491b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;

namespace Org.BouncyCastle.Tls
{
    /**
     * RFC 8879
     */
    public abstract class CertificateCompressionAlgorithm
    {
        public const int zlib = 1;
        public const int brotli = 2;
        public const int zstd = 3;

        public static string GetName(int certificateCompressionAlgorithm)
        {
            switch (certificateCompressionAlgorithm)
            {
            case zlib:
                return "zlib";
            case brotli:
                return "brotli";
            case zstd:
                return "zstd";
            default:
                return "UNKNOWN";
            }
        }

        public static string GetText(int certificateCompressionAlgorithm)
        {
            return GetName(certificateCompressionAlgorithm) + "(" + certificateCompressionAlgorithm + ")";
        }

        public static bool IsRecognized(int certificateCompressionAlgorithm)
        {
            switch (certificateCompressionAlgorithm)
            {
            case zlib:
            case brotli:
            case zstd:
                return true;
            default:
                return false;
            }
        }
    }
}