
org.testifyproject.bouncycastle.jce.spec.IESParameterSpec Maven / Gradle / Ivy
package org.testifyproject.bouncycastle.jce.spec;
import java.security.spec.AlgorithmParameterSpec;
import org.testifyproject.bouncycastle.util.Arrays;
/**
* Parameter spec for an integrated encryptor, as in IEEE P1363a
*/
public class IESParameterSpec
implements AlgorithmParameterSpec
{
private byte[] org.testifyproject.testifyprojectrivation;
private byte[] encoding;
private int macKeySize;
private int cipherKeySize;
private byte[] nonce;
/**
* Set the IES engine parameters.
*
* @param org.testifyproject.testifyprojectrivation the optional org.testifyproject.testifyprojectrivation vector for the KDF.
* @param encoding the optional encoding vector for the KDF.
* @param macKeySize the key size (in bits) for the MAC.
*/
public IESParameterSpec(
byte[] org.testifyproject.testifyprojectrivation,
byte[] encoding,
int macKeySize)
{
this(org.testifyproject.testifyprojectrivation, encoding, macKeySize, -1);
}
/**
* Set the IES engine parameters.
*
* @param org.testifyproject.testifyprojectrivation the optional org.testifyproject.testifyprojectrivation vector for the KDF.
* @param encoding the optional encoding vector for the KDF.
* @param macKeySize the key size (in bits) for the MAC.
* @param cipherKeySize the key size (in bits) for the block cipher.
*/
public IESParameterSpec(
byte[] org.testifyproject.testifyprojectrivation,
byte[] encoding,
int macKeySize,
int cipherKeySize)
{
this(org.testifyproject.testifyprojectrivation, encoding, macKeySize, cipherKeySize, null);
}
/**
* Set the IES engine parameters.
*
* @param org.testifyproject.testifyprojectrivation the optional org.testifyproject.testifyprojectrivation vector for the KDF.
* @param encoding the optional encoding vector for the KDF.
* @param macKeySize the key size (in bits) for the MAC.
* @param cipherKeySize the key size (in bits) for the block cipher.
* @param nonce an IV to use initialising the block cipher.
*/
public IESParameterSpec(
byte[] org.testifyproject.testifyprojectrivation,
byte[] encoding,
int macKeySize,
int cipherKeySize,
byte[] nonce)
{
if (org.testifyproject.testifyprojectrivation != null)
{
this.org.testifyproject.testifyprojectrivation = new byte[org.testifyproject.testifyprojectrivation.length];
System.arraycopy(org.testifyproject.testifyprojectrivation, 0, this.org.testifyproject.testifyprojectrivation, 0, org.testifyproject.testifyprojectrivation.length);
}
else
{
this.org.testifyproject.testifyprojectrivation = null;
}
if (encoding != null)
{
this.encoding = new byte[encoding.length];
System.arraycopy(encoding, 0, this.encoding, 0, encoding.length);
}
else
{
this.encoding = null;
}
this.macKeySize = macKeySize;
this.cipherKeySize = cipherKeySize;
this.nonce = Arrays.clone(nonce);
}
/**
* return the org.testifyproject.testifyprojectrivation vector.
*/
public byte[] getDerivationV()
{
return Arrays.clone(org.testifyproject.testifyprojectrivation);
}
/**
* return the encoding vector.
*/
public byte[] getEncodingV()
{
return Arrays.clone(encoding);
}
/**
* return the key size in bits for the MAC used with the message
*/
public int getMacKeySize()
{
return macKeySize;
}
/**
* return the key size in bits for the block cipher used with the message
*/
public int getCipherKeySize()
{
return cipherKeySize;
}
/**
* Return the nonce (IV) value to be associated with message.
*
* @return block cipher IV for message.
*/
public byte[] getNonce()
{
return Arrays.clone(nonce);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy