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 classCipherCore.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)intdoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)intgetBlockSize()com.fortanix.sdkms.v1.model.CryptModegetCryptMode()byte[]getIv()SdkmsCipherKeygetKey()StringgetOperation()intgetOutputSize(int inputLen)The actual encrypted/decrypted data size can be smaller then the length return by this methodStringgetPadding()voidinit(int opmode, Key key)voidinit(int opmode, Key key, AlgorithmParameters params)voidinit(int opmode, Key key, AlgorithmParameterSpec params)voidinitMultiCore()protected booleanisPaddingRequired()protected voidprepareDoFinal()protected voidresetFields()voidsetBlockSize(int blockSize)voidsetCryptMode(com.fortanix.sdkms.v1.model.CryptMode cryptMode)voidsetPadding(String padding)voidsetState(byte[] state)protected voidswitchCryptMode()Keyunwrap(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 modeintupdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)This method doesn't perform any encryption.voidupdateAAD(byte[] src, int offset, int len)protected voidvalidateParameters()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:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
init
public void init(int opmode, Key key) throws InvalidKeyException- Parameters:
opmode- operation mode of this cipher. Possible values areENCRYPT_MODE,DECRYPT_MODE,WRAP_MODEorUNWRAP_MODEkey- the secret key- Throws:
InvalidAlgorithmParameterExceptionInvalidKeyException
-
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 ShortBufferExceptionThis 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()
-
-