All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.gatling.recorder.internal.bouncycastle.crypto.params.KeyParameter Maven / Gradle / Ivy

package io.gatling.recorder.internal.bouncycastle.crypto.params;

import io.gatling.recorder.internal.bouncycastle.crypto.CipherParameters;
import io.gatling.recorder.internal.bouncycastle.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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy