Class CipherCore
- java.lang.Object
-
- com.fortanix.sdkms.jce.provider.ciphers.CipherCore
-
public class CipherCore extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CipherCore.CipherType
-
Constructor Summary
Constructors Constructor Description CipherCore(com.fortanix.sdkms.v1.model.ObjectType alg, int blkSize, CipherCore.CipherType cipherType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
doFinal(byte[] input, int inputOffset, int inputLen)
int
doFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
int
getBlockSize()
com.fortanix.sdkms.v1.model.CryptMode
getCryptMode()
byte[]
getIv()
SdkmsCipherKey
getKey()
String
getOperation()
int
getOutputSize(int inputLen)
The actual encrypted/decrypted data size can be smaller then the length return by this methodString
getPadding()
void
init(int opmode, Key key)
void
init(int opmode, Key key, AlgorithmParameters params)
void
init(int opmode, Key key, AlgorithmParameterSpec params)
void
initMultiCore()
protected boolean
isPaddingRequired()
protected void
prepareDoFinal()
protected void
resetFields()
void
setBlockSize(int blockSize)
void
setCryptMode(com.fortanix.sdkms.v1.model.CryptMode cryptMode)
void
setPadding(String padding)
void
setState(byte[] state)
protected void
switchCryptMode()
Key
unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType)
Decrypt the wrapped key and return JCE key objectbyte[]
update(byte[] input, int inputOffset, int inputLen)
return encrypted / plain bytes depend upon cipher modeint
update(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
This method doesn't perform any encryption.void
updateAAD(byte[] src, int offset, int len)
protected void
validateParameters()
byte[]
wrap(Key key)
Encrypt input key
-
-
-
Constructor Detail
-
CipherCore
public CipherCore(com.fortanix.sdkms.v1.model.ObjectType alg, int blkSize, CipherCore.CipherType cipherType)
-
-
Method Detail
-
init
public void init(int opmode, Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException
- Parameters:
opmode
-key
-params
-- Throws:
InvalidKeyException
InvalidAlgorithmParameterException
-
init
public void init(int opmode, Key key) throws InvalidKeyException
- Parameters:
opmode
- operation mode of this cipher. Possible values areENCRYPT_MODE
,DECRYPT_MODE
,WRAP_MODE
orUNWRAP_MODE
key
- the secret key- Throws:
InvalidAlgorithmParameterException
InvalidKeyException
-
init
public void init(int opmode, Key key, AlgorithmParameters params) throws InvalidKeyException, InvalidAlgorithmParameterException
-
initMultiCore
public void initMultiCore()
-
update
public byte[] update(byte[] input, int inputOffset, int inputLen)
return encrypted / plain bytes depend upon cipher mode
-
update
public int update(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException
This method doesn't perform any encryption. Call doFinal for encryption/decryption operation- Parameters:
input
-inputOffset
-inputLen
-output
-outputOffset
-- Returns:
- zero. As nothing is copied into output
- Throws:
ShortBufferException
-
doFinal
public byte[] doFinal(byte[] input, int inputOffset, int inputLen)
- Parameters:
input
-inputOffset
-inputLen
-- Returns:
- encrypted/decrypted content
-
doFinal
public int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException
- Parameters:
input
-inputOffset
-inputLen
-output
- , cipher/plain text as per operation modeoutputOffset
-- Returns:
- Throws:
ShortBufferException
-
prepareDoFinal
protected void prepareDoFinal()
-
setCryptMode
public void setCryptMode(com.fortanix.sdkms.v1.model.CryptMode cryptMode)
-
setPadding
public void setPadding(String padding)
-
getOutputSize
public int getOutputSize(int inputLen)
The actual encrypted/decrypted data size can be smaller then the length return by this method- Parameters:
inputLen
-- Returns:
- required output buffer size in bytes
-
updateAAD
public void updateAAD(byte[] src, int offset, int len)
-
wrap
public byte[] wrap(Key key) throws InvalidKeyException
Encrypt input key- Parameters:
key
- to be wrapped- Returns:
- wrapped key
- Throws:
InvalidKeyException
-
unwrap
public Key unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException
Decrypt the wrapped key and return JCE key object- Parameters:
wrappedKey
-wrappedKeyAlgorithm
-wrappedKeyType
-- Returns:
- Key object
- Throws:
InvalidKeyException
-
getIv
public byte[] getIv()
-
getPadding
public String getPadding()
-
getOperation
public String getOperation()
-
getCryptMode
public com.fortanix.sdkms.v1.model.CryptMode getCryptMode()
-
getBlockSize
public int getBlockSize()
-
setBlockSize
public void setBlockSize(int blockSize)
-
getKey
public SdkmsCipherKey getKey()
-
validateParameters
protected void validateParameters()
-
switchCryptMode
protected void switchCryptMode()
-
isPaddingRequired
protected boolean isPaddingRequired()
-
setState
public void setState(byte[] state)
-
resetFields
protected void resetFields()
-
-