Welcome to mirror list, hosted at ThFree Co, Russian Federation.

UseSRTPData.java « tls « crypto « bouncycastle « org « java « main « src « core - gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bc2cf10c148cfa610974de1718ad9237a545add7 (plain)
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
50
51
52
package org.bouncycastle.crypto.tls;

/**
 * RFC 5764 4.1.1
 */
public class UseSRTPData
{
    private int[] protectionProfiles;
    private byte[] mki;

    /**
     * @param protectionProfiles see {@link SRTPProtectionProfile} for valid constants.
     * @param mki                valid lengths from 0 to 255.
     */
    public UseSRTPData(int[] protectionProfiles, byte[] mki)
    {
        if (protectionProfiles == null || protectionProfiles.length < 1
            || protectionProfiles.length >= (1 << 15))
        {
            throw new IllegalArgumentException(
                "'protectionProfiles' must have length from 1 to (2^15 - 1)");
        }

        if (mki == null)
        {
            mki = TlsUtils.EMPTY_BYTES;
        }
        else if (mki.length > 255)
        {
            throw new IllegalArgumentException("'mki' cannot be longer than 255 bytes");
        }

        this.protectionProfiles = protectionProfiles;
        this.mki = mki;
    }

    /**
     * @return see {@link SRTPProtectionProfile} for valid constants.
     */
    public int[] getProtectionProfiles()
    {
        return protectionProfiles;
    }

    /**
     * @return valid lengths from 0 to 255.
     */
    public byte[] getMki()
    {
        return mki;
    }
}