Overview | Package | Class | Tree | Deprecated | Index | Help
| For the latest news and information visit The GNU Crypto project
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## gnu.crypto.pad
Class BasePad

    java.lang.Object
      |
      +--gnu.crypto.pad.BasePad

All Implemented Interfaces:
  IPad

Direct Known Subclasses:
  PKCS7, TBC

public abstract class BasePad
extends java.lang.Object
implements IPad

An abstract class to facilitate implementing padding algorithms.

Version:
  $Revision: 1.2 $

Field Summary
`protected int` | `blockSize` The block size, in bytes, for this instance.
`protected java.lang.String` | `name` The canonical name prefix of the padding algorithm.

Constructor Summary
`protected` | `BasePad(java.lang.String name)` Trivial constructor for use by concrete subclasses.

Method Summary
`void` | `init(int bs)` Initialises the padding scheme with a designated block size.
`java.lang.String` | `name()`
`abstract 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.
`abstract void` | `setup()`
`abstract int` | `unpad(byte[] in, int offset, int length)` Returns the number of bytes to discard from a designated input buffer.

Methods inherited from class java.lang.Object
`, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### name

    protected java.lang.String name

  The canonical name prefix of the padding algorithm.

### blockSize

    protected int blockSize

  The block size, in bytes, for this instance.

Constructor Detail

### BasePad

    protected BasePad(java.lang.String name)

  Trivial constructor for use by concrete subclasses.

Method Detail

### name

    public java.lang.String name()

  Specified by:
    `name` in interface `IPad`
  Following copied from interface: `gnu.crypto.pad.IPad`
  Returns:
    the canonical name of this instance.

### init

    public void init(int bs)
              throws java.lang.IllegalStateException

  Description copied from interface: `IPad`
  Initialises the padding scheme with a designated block size.
  Specified by:
    `init` in interface `IPad`
  Following copied from interface: `gnu.crypto.pad.IPad`
  Parameters:
    `bs` - the designated block size.
  Throws:
    `java.lang.IllegalStateException` - if the instance is already initialised.
    `java.lang.IllegalArgumentException` - if the block size value is invalid.

### reset

    public void reset()

  Description copied from interface: `IPad`
  Resets the scheme instance for re-initialisation and use with other characteristics. This method always succeeds.
  Specified by:
    `reset` in interface `IPad`

### selfTest

    public boolean selfTest()

  Description copied from interface: `IPad`
  A basic symmetric pad/unpad test.
  Specified by:
    `selfTest` in interface `IPad`
  Following copied from interface: `gnu.crypto.pad.IPad`
  Returns:
    `true` if the implementation passes a basic symmetric self-test. Returns `false` otherwise.

### setup

    public abstract void setup()

### pad

    public abstract byte[] pad(byte[] in,
                               int offset,
                               int length)

  Description copied from interface: `IPad`
  Returns the byte sequence that should be appended to the designated input.
  Specified by:
    `pad` in interface `IPad`
  Following copied from interface: `gnu.crypto.pad.IPad`
  Parameters:
    `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.
  Returns:
    the possibly 0-byte long sequence to be appended to the designated input.

### unpad

    public abstract int unpad(byte[] in,
                              int offset,
                              int length)
                       throws WrongPaddingException

  Description copied from interface: `IPad`
  Returns the number of bytes to discard from a designated input buffer.
  Specified by:
    `unpad` in interface `IPad`
  Following copied from interface: `gnu.crypto.pad.IPad`
  Parameters:
    `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.
  Returns:
    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`.
  Throws:
    `WrongPaddingException` - if the data is not terminated with the expected padding bytes.

Overview | Package | Class | Tree | Deprecated | Index | Help
| For the latest news and information visit The GNU Crypto project
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright ©2001-2002 Free Software Foundation, Inc.. All Rights Reserved.