summary refs log tree commit diff
path: root/crypto/src/tls/PrfAlgorithm.cs
blob: ec9c2f249af96b1964ce23f807c9e16670893b54 (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
48
49
using System;

namespace Org.BouncyCastle.Tls
{
    /// <summary>RFC 5246</summary>
    /// <remarks>
    /// Note that the values here are implementation-specific and arbitrary. It is recommended not to depend on the
    /// particular values (e.g. serialization).
    /// </remarks>
    public abstract class PrfAlgorithm
    {
        public const int ssl_prf_legacy = 0;
        public const int tls_prf_legacy = 1;
        public const int tls_prf_sha256 = 2;
        public const int tls_prf_sha384 = 3;
        public const int tls13_hkdf_sha256 = 4;
        public const int tls13_hkdf_sha384 = 5;
        //public const int tls13_hkdf_sha512 = 6;
        public const int tls13_hkdf_sm3 = 7;

        public static string GetName(int prfAlgorithm)
        {
            switch (prfAlgorithm)
            {
            case ssl_prf_legacy:
                return "ssl_prf_legacy";
            case tls_prf_legacy:
                return "tls_prf_legacy";
            case tls_prf_sha256:
                return "tls_prf_sha256";
            case tls_prf_sha384:
                return "tls_prf_sha384";
            case tls13_hkdf_sha256:
                return "tls13_hkdf_sha256";
            case tls13_hkdf_sha384:
                return "tls13_hkdf_sha384";
            case tls13_hkdf_sm3:
                return "tls13_hkdf_sm3";
            default:
                return "UNKNOWN";
            }
        }

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