public interface IPad
The basic visible methods of any padding algorithm.
Padding algorithms serve to pad and unpad byte arrays usually
as the last step in an encryption or respectively a decryption
operation. Their input buffers are usually those processed by instances of
IMode
and/or IBlockCipher
.
Modifier and Type | Method and Description |
---|---|
void |
init(int bs)
Initialises the padding scheme with a designated block size.
|
java.lang.String |
name() |
byte[] |
pad(byte[] in,
int offset,
int length)
Returns the byte sequence that should be appended to the designated input.
|
void |
reset()
Resets the scheme instance for re-initialisation and use with other
characteristics.
|
boolean |
selfTest()
A basic symmetric pad/unpad test.
|
int |
unpad(byte[] in,
int offset,
int length)
Returns the number of bytes to discard from a designated input buffer.
|
java.lang.String name()
void init(int bs) throws java.lang.IllegalStateException
bs
- the designated block size.java.lang.IllegalStateException
- if the instance is already initialised.java.lang.IllegalArgumentException
- if the block size value is invalid.byte[] pad(byte[] in, int offset, int length)
in
- the input buffer containing the bytes to pad.offset
- the starting index of meaningful data in in.length
- the number of meaningful bytes in in.int unpad(byte[] in, int offset, int length) throws WrongPaddingException
in
- the input buffer containing the bytes to unpad.offset
- the starting index of meaningful data in in.length
- the number of meaningful bytes in in.WrongPaddingException
- if the data is not terminated with the
expected padding bytes.void reset()
boolean selfTest()
Copyright © 2025. All rights reserved.