RC5ParameterSpecpublic class RC5ParameterSpec extends Object implements AlgorithmParameterSpecThe algorithm parameter specification for the RC5 algorithm. |
Fields Summary |
---|
private final int | version | private final int | rounds | private final int | wordSize | private final byte[] | iv |
Constructors Summary |
---|
public RC5ParameterSpec(int version, int rounds, int wordSize)Creates a new RC5ParameterSpec instance with the specified
version, round count an word size (in bits).
this.version = version;
this.rounds = rounds;
this.wordSize = wordSize;
this.iv = null;
| public RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv)Creates a new RC5ParameterSpec instance with the specified
version, round count, word size (in bits) and an initialization
vector.
The size of the initialization vector must be at least
2 * (wordSize / 8) bytes which are copied to protect them
against modification.
if (iv == null) {
throw new IllegalArgumentException(Messages.getString("crypto.31")); //$NON-NLS-1$
}
if (iv.length < 2 * (wordSize / 8)) {
throw new IllegalArgumentException(
Messages.getString("crypto.32")); //$NON-NLS-1$
}
this.version = version;
this.rounds = rounds;
this.wordSize = wordSize;
this.iv = new byte[2*(wordSize/8)];
System.arraycopy(iv, 0, this.iv, 0, 2*(wordSize/8));
| public RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv, int offset)Creates a new RC5ParameterSpec instance with the specified
version, round count, wordSize (in bits), an initialization vector
and an offset.
The size of the initialization vector must be at least
offset + (2 * (wordSize / 8)) bytes. The bytes starting at
offset are copied to protect them against modification.
if (iv == null) {
throw new IllegalArgumentException(Messages.getString("crypto.31")); //$NON-NLS-1$
}
if (offset < 0) {
throw new ArrayIndexOutOfBoundsException(Messages.getString("crypto.33")); //$NON-NLS-1$
}
if (iv.length - offset < 2 * (wordSize / 8)) {
throw new IllegalArgumentException(
Messages.getString("crypto.34")); //$NON-NLS-1$
}
this.version = version;
this.rounds = rounds;
this.wordSize = wordSize;
this.iv = new byte[offset+2*(wordSize/8)];
System.arraycopy(iv, offset, this.iv, 0, 2*(wordSize/8));
|
Methods Summary |
---|
public boolean | equals(java.lang.Object obj)Compares the specified object with this RC5ParameterSpec
instance.
if (obj == this) {
return true;
}
if (!(obj instanceof RC5ParameterSpec)) {
return false;
}
RC5ParameterSpec ps = (RC5ParameterSpec) obj;
return (version == ps.version)
&& (rounds == ps.rounds)
&& (wordSize == ps.wordSize)
&& (Arrays.equals(iv, ps.iv));
| public byte[] | getIV()Returns a copy of the initialization vector.
if (iv == null) {
return null;
}
byte[] result = new byte[iv.length];
System.arraycopy(iv, 0, result, 0, iv.length);
return result;
| public int | getRounds()Returns the round count.
return rounds;
| public int | getVersion()Returns the version.
return version;
| public int | getWordSize()Returns the word size (in bits).
return wordSize;
| public int | hashCode()Returns the hash code of this RC5ParameterSpec instance.
int result = version + rounds + wordSize;
if (iv == null) {
return result;
}
for (byte element : iv) {
result += element & 0xFF;
}
return result;
|
|