wangzhibo
4 天以前 ae6f40460dcd56af6c5f60ba52c883854c3bac55
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
53
54
55
56
package org.bouncycastle.shaded.crypto.params;
 
import org.bouncycastle.shaded.crypto.CipherParameters;
import org.bouncycastle.shaded.util.Arrays;
 
public class KeyParameter
    implements CipherParameters
{
    private byte[]  key;
 
    public KeyParameter(
        byte[]  key)
    {
        this(key, 0, key.length);
    }
 
    public KeyParameter(
        byte[]  key,
        int     keyOff,
        int     keyLen)
    {
        this(keyLen);
 
        System.arraycopy(key, keyOff, this.key, 0, keyLen);
    }
 
    private KeyParameter(int length)
    {
        this.key = new byte[length];
    }
 
    public void copyTo(byte[] buf, int off, int len)
    {
        if (key.length != len)
            throw new IllegalArgumentException("len");
 
        System.arraycopy(key, 0, buf, off, len);
    }
 
    public byte[] getKey()
    {
        return key;
    }
 
    public int getKeyLength()
    {
        return key.length;
    }
 
    public KeyParameter reverse()
    {
        KeyParameter reversed = new KeyParameter(key.length);
        Arrays.reverse(this.key, reversed.key);
        return reversed;
    }
}