public final class CipherSpec extends Object implements Serializable
Cipher
except for the encryption key.
The "setters" all return a reference to this
so that they can be
strung together.
Note: While this is a useful class in it's own right, it should primarily be regarded as an implementation class to use with ESAPI encryption, especially the reference implementation. It is not intended to be used directly by application developers, but rather only by those either extending ESAPI or in the ESAPI reference implementation. Use directly by application code is not recommended or supported.
Constructor and Description |
---|
CipherSpec()
Default CTOR.
|
CipherSpec(byte[] iv) |
CipherSpec(Cipher cipher)
CTOR that sets everything except for the cipher key size and possibly
the IV.
|
CipherSpec(Cipher cipher,
int keySize)
CTOR that sets everything.
|
CipherSpec(String cipherXform,
int keySize)
CTOR that sets everything but block size and IV.
|
CipherSpec(String cipherXform,
int keySize,
byte[] iv)
CTOR that sets everything except block size.
|
CipherSpec(String cipherXform,
int keySize,
int blockSize)
CTOR that sets everything but IV.
|
CipherSpec(String cipherXform,
int keySize,
int blockSize,
byte[] iv)
CTOR that explicitly sets everything.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
canEqual(Object other)
Needed for correct definition of equals for general classes.
|
boolean |
equals(Object other) |
int |
getBlockSize()
Retrieve the block size, in bytes.
|
String |
getCipherAlgorithm()
Retrieve the cipher algorithm.
|
String |
getCipherMode()
Retrieve the cipher mode.
|
String |
getCipherTransformation()
Get the cipher transformation.
|
byte[] |
getIV()
Retrieve the initialization vector (IV).
|
int |
getKeySize()
Retrieve the key size, in bits.
|
String |
getPaddingScheme()
Retrieve the cipher padding scheme.
|
int |
hashCode() |
boolean |
requiresIV()
Return true if the cipher mode requires an IV.
|
CipherSpec |
setBlockSize(int blockSize)
Set the block size for this
CipherSpec . |
CipherSpec |
setCipherTransformation(String cipherXform)
Set the cipher transformation for this
CipherSpec . |
CipherSpec |
setIV(byte[] iv)
Set the initialization vector (IV).
|
CipherSpec |
setKeySize(int keySize)
Set the key size for this
CipherSpec . |
String |
toString()
Override
Object.toString() to provide something more useful. |
public CipherSpec(String cipherXform, int keySize, int blockSize, byte[] iv)
cipherXform
- The cipher transformationkeySize
- The key size (in bits).blockSize
- The block size (in bytes).iv
- The initialization vector. Null if not applicable.public CipherSpec(String cipherXform, int keySize, int blockSize)
cipherXform
- The cipher transformationkeySize
- The key size (in bits).blockSize
- The block size (in bytes).public CipherSpec(String cipherXform, int keySize)
public CipherSpec(String cipherXform, int keySize, byte[] iv)
public CipherSpec(Cipher cipher)
public CipherSpec(Cipher cipher, int keySize)
public CipherSpec(byte[] iv)
public CipherSpec()
null
IV.public CipherSpec setCipherTransformation(String cipherXform)
CipherSpec
.cipherXform
- The cipher transformation string; e.g., "DESede/CBC/PKCS5Padding".CipherSpec
object.public String getCipherTransformation()
String
.public CipherSpec setKeySize(int keySize)
CipherSpec
.keySize
- The key size, in bits. Must be positive integer.CipherSpec
object.public int getKeySize()
public CipherSpec setBlockSize(int blockSize)
CipherSpec
.blockSize
- The block size, in bytes. Must be positive integer appropriate
for the specified cipher algorithm.CipherSpec
object.public int getBlockSize()
public String getCipherAlgorithm()
public String getCipherMode()
public String getPaddingScheme()
public byte[] getIV()
public CipherSpec setIV(byte[] iv)
iv
- The byte array to set as the IV. A copy of the IV is saved.
This parameter is ignored if the cipher mode does not
require an IV.CipherSpec
object.public boolean requiresIV()
public String toString()
Object.toString()
to provide something more useful.protected boolean canEqual(Object other)
See How to write an Equality Method in Java for full explanation.
Copyright © 2020 The Open Web Application Security Project (OWASP). All rights reserved.