Package com.basis.filesystem
Class Crypt
java.lang.Object
com.basis.filesystem.Crypt
Base class and entry point for BBj encryption services. Subclasses must
implement a constructor taking three arguments: (Boolean p_constant, String
p_password, Map p_modes) for use as the default Crypt subclass.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
decrypt
(byte[] p_buffer, int p_offset, int p_length) Decrypt an arbitrary buffer.abstract void
decryptBlocks
(byte[] p_buffer, int p_offset, int p_length) Decrypt a buffer in place that is a multiple of the block size for this Crypt object is applicable.byte[]
encrypt
(byte[] p_buffer, int p_offset, int p_length) Encrypt an arbitrary buffer.abstract void
encryptBlocks
(byte[] p_buffer, int p_offset, int p_length) Encrypt a buffer in place that is a multiple of the block size for this Crypt object is applicable.abstract int
Get the preferred block size for this encryption method.static Crypt
Get the appropriate Crypt object given an initialization buffer.protected abstract Crypt
getCryptInstance
(byte[] p_init, String p_password) Method to see if a registered Crypt subclass can handle a given initialization.static Crypt
getDefaultCrypt
(boolean p_constant, String p_password, Map p_modes) Get the default Crypt object with either constant or randomized initialization.abstract byte[]
Get the initialization buffer suitable for reconstructing the Crypt object.protected static void
Register a subclass of Crypt as available.
-
Constructor Details
-
Crypt
public Crypt()
-
-
Method Details
-
getCrypt
Get the appropriate Crypt object given an initialization buffer.- Parameters:
p_init
- Intialization buffer.p_password
- Crypt password.- Returns:
- Initialized Crypt object.
- Throws:
FilesystemException
- if unable to instantiate appropriate Crypt object.
-
getDefaultCrypt
public static Crypt getDefaultCrypt(boolean p_constant, String p_password, Map p_modes) throws FilesystemException Get the default Crypt object with either constant or randomized initialization.- Parameters:
p_modes
- Modes for the initialization.- Returns:
- Crypt with randomized initialization.
- Throws:
FilesystemException
-
encrypt
Encrypt an arbitrary buffer. The encrypted buffer is returned and can be a different size from the buffer being encrypted.- Parameters:
p_buffer
- Buffer to encrypt.p_offset
- Offset into buffer.p_length
- Length of buffer.- Returns:
- Encrypted buffer.
- Throws:
FilesystemException
- on error.
-
decrypt
Decrypt an arbitrary buffer. The decrypted buffer is returned and can be a different size from the buffer being decrypted.- Parameters:
p_buffer
- Buffer to decrypt.p_offset
- Offset into buffer.p_length
- Length of buffer.- Returns:
- Encrypted buffer.
- Throws:
FilesystemException
- on error.
-
getInitialization
public abstract byte[] getInitialization()Get the initialization buffer suitable for reconstructing the Crypt object.- Returns:
- Initization buffer.
-
getBlockSize
public abstract int getBlockSize()Get the preferred block size for this encryption method. If there is no preferred block size, return a number less than or equal to zero.- Returns:
- Preferred block size.
-
encryptBlocks
public abstract void encryptBlocks(byte[] p_buffer, int p_offset, int p_length) throws FilesystemException Encrypt a buffer in place that is a multiple of the block size for this Crypt object is applicable.- Parameters:
p_buffer
- Buffer to encrypt in place.p_offset
- Offset into buffer.p_length
- Length of buffer.- Throws:
FilesystemException
- on error.
-
decryptBlocks
public abstract void decryptBlocks(byte[] p_buffer, int p_offset, int p_length) throws FilesystemException Decrypt a buffer in place that is a multiple of the block size for this Crypt object is applicable.- Parameters:
p_buffer
- Buffer to decrypt in place.p_offset
- Offset into buffer.p_length
- Length of buffer.- Throws:
FilesystemException
- on error.
-
register
Register a subclass of Crypt as available.- Parameters:
p_crypt
- Instance of a Crypt subclass.
-
getCryptInstance
protected abstract Crypt getCryptInstance(byte[] p_init, String p_password) throws FilesystemException Method to see if a registered Crypt subclass can handle a given initialization. This method should return null if the given init is not appropriate for this Crypt subclass.- Parameters:
p_init
- Initialization buffer.p_password
- Password.- Returns:
- Instance of Crypt subclass if appropriate.
- Throws:
FilesystemException
- if this is the appropriate handler for the given initialzation but another problem occurs.
-