gnu.crypto.pad
Class BasePad
- IPad
public abstract class BasePad
An abstract class to facilitate implementing padding algorithms.
protected int | blockSize - The block size, in bytes, for this instance.
|
protected String | name - The canonical name prefix of the padding algorithm.
|
BasePad(String name) - Trivial constructor for use by concrete subclasses.
|
void | init(int bs) - Initialises the padding scheme with a designated block size.
|
String | name()
|
abstract byte[] | pad(byte[] in, int off, int len) - 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.
|
abstract void | setup() - If any additional checks or resource setup must be done by the
subclass, then this is the hook for it.
|
abstract int | unpad(byte[] in, int off, int len) - Returns the number of bytes to discard from a designated input buffer.
|
blockSize
protected int blockSize
The block size, in bytes, for this instance.
name
protected String name
The canonical name prefix of the padding algorithm.
BasePad
protected BasePad(String name)
Trivial constructor for use by concrete subclasses.
init
public void init(int bs)
throws IllegalStateException
Initialises the padding scheme with a designated block size.
- init in interface IPad
bs
- the designated block size.
name
public String name()
- name in interface IPad
- the canonical name of this instance.
pad
public abstract byte[] pad(byte[] in,
int off,
int len)
Returns the byte sequence that should be appended to the designated input.
- pad in interface IPad
in
- the input buffer containing the bytes to pad.
- the possibly 0-byte long sequence to be appended to the designated
input.
reset
public void reset()
Resets the scheme instance for re-initialisation and use with other
characteristics. This method always succeeds.
- reset in interface IPad
selfTest
public boolean selfTest()
A basic symmetric pad/unpad test.
- selfTest in interface IPad
- true if the implementation passes a basic symmetric
self-test. Returns false otherwise.
setup
public abstract void setup()
If any additional checks or resource setup must be done by the
subclass, then this is the hook for it. This method will be called before
the
init(int)
method returns.
unpad
public abstract int unpad(byte[] in,
int off,
int len)
throws WrongPaddingException
Returns the number of bytes to discard from a designated input buffer.
- unpad in interface IPad
in
- the input buffer containing the bytes to unpad.
- the number of bytes to discard, to the left of index position
offset + length in in. In other words, if the return
value of a successful invocation of this method is result, then
the unpadded byte sequence will be offset + length - result bytes
in in, starting from index position offset.
Copyright © 2001, 2002, 2003
Free Software Foundation,
Inc. All Rights Reserved.