Package org.opends.server.crypto
Class CryptoSuite
- java.lang.Object
-
- org.opends.server.crypto.CryptoSuite
-
public class CryptoSuite extends Object
Defines cipher transformation and hash algorithm for cryptographic related operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCryptoSuite.CipherInfoCipher specific settings that can change at runtime.
-
Constructor Summary
Constructors Constructor Description CryptoSuite(CryptoManager cryptoManager, String cipherTransformation, int cipherKeyLength, boolean encrypt)Declares a new CryptoSuite with provided parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]decrypt(byte[] data)Decrypts data using the key specified in the prologue.byte[]encrypt(byte[] data)Encrypts data with the configured cipher transformation and key length.CipherInputStreamgetCipherInputStream(InputStream is)Returns aCipherInputStreamfor decrypting through a sequence of InputStreams.CipherOutputStreamgetCipherOutputStream(OutputStream os)Returns aCipherOutputStreamfor encrypting through a sequence of OutputStreams.ByteStringhash48(ByteSequence data)Returns a ByteString of 6 bytes hash of the data.booleanisEncrypted()Returns whether the user of the crypto suite needs encryption.voidnewParameters(String cipherTransformation, int cipherKeyLength, boolean enabled)Set new cipher and enable parameters for the crypto suite.StringtoString()
-
-
-
Constructor Detail
-
CryptoSuite
public CryptoSuite(CryptoManager cryptoManager, String cipherTransformation, int cipherKeyLength, boolean encrypt)
Declares a new CryptoSuite with provided parameters.- Parameters:
cryptoManager- the CryptoManager to use for cryptographic operationscipherTransformation- the initial cipher transformationcipherKeyLength- the initial key length for the cipherencrypt- if the user of the crypto suite needs encryption
-
-
Method Detail
-
newParameters
public void newParameters(String cipherTransformation, int cipherKeyLength, boolean enabled)
Set new cipher and enable parameters for the crypto suite.- Parameters:
cipherTransformation- the new cipher transformationcipherKeyLength- the new key lengthenabled- true if the user of the crypto suite needs encryption
-
decrypt
public byte[] decrypt(byte[] data) throws GeneralSecurityException, CryptoManagerExceptionDecrypts data using the key specified in the prologue.- Parameters:
data- the cipher-text to be decrypted (contains prologue)- Returns:
- a byte array with the clear-text
- Throws:
GeneralSecurityException- if a problem occurs while decrypting the dataCryptoManagerException- if a problem occurs during cipher initialization
-
encrypt
public byte[] encrypt(byte[] data) throws GeneralSecurityException, CryptoManagerExceptionEncrypts data with the configured cipher transformation and key length.- Parameters:
data- the clear-text data to encrypt- Returns:
- a byte array with a prologue containing the key identifier followed by cipher-text
- Throws:
GeneralSecurityException- if a problem occurs while encrypting the dataCryptoManagerException- if a problem occurs during cipher initialization
-
getCipherOutputStream
public CipherOutputStream getCipherOutputStream(OutputStream os) throws CryptoManagerException
Returns aCipherOutputStreamfor encrypting through a sequence of OutputStreams.- Parameters:
os- the up-link OutputStream- Returns:
- a
CipherOutputStreamfor encrypting through a sequence of OutputStreams - Throws:
CryptoManagerException- if a problem occurs during cipher initialization
-
getCipherInputStream
public CipherInputStream getCipherInputStream(InputStream is) throws CryptoManagerException
Returns aCipherInputStreamfor decrypting through a sequence of InputStreams.- Parameters:
is- the up-link InputStream- Returns:
- a
CipherInputStreamfor decrypting through a sequence of InputStreams. - Throws:
CryptoManagerException- if a problem occurs during cipher initialization
-
hash48
public ByteString hash48(ByteSequence data) throws DecodeException
Returns a ByteString of 6 bytes hash of the data.- Parameters:
data- a ByteSequence containing the input data to be hashed- Returns:
- a ByteString of 6 bytes hash of the data.
- Throws:
DecodeException- if digest of the data cannot be computed
-
isEncrypted
public boolean isEncrypted()
Returns whether the user of the crypto suite needs encryption.- Returns:
- true if the user of the crypto suite needs encryption
-
-