All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cryptix.provider.padding.PKCS5

java.lang.Object
   |
   +----java.security.IJCE_Traceable
           |
           +----java.security.PaddingScheme
                   |
                   +----cryptix.provider.padding.PKCS5

public class PKCS5
extends PaddingScheme
A class for padding cipher data according to the following scheme, described in section 6.2 of RSA Data Security, Inc.'s PKCS #5 standard:

    ...
 

An IllegalBlockSizeException is thrown (by the Cipher class) if the block size is not 8 bytes.

References:

  1. PKCS#5: ... An RSA Laboratories Technical Note; Version 1.5; Revised November 1, 1993.

Copyright © 1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.6 $

Author:
Raif S. Naffah, David Hopwood

Constructor Index

 o PKCS5()
Creates a PKCS5 object.

Method Index

 o engineIsValidBlockSize(int)
SPI: Returns true if size is a valid block size (in bytes) for this algorithm.
 o enginePad(byte[], int, int)
Pads a given array of bytes.
 o engineUnpad(byte[], int, int)
Given the specified subarray of bytes that includes padding bytes, returns the index indicating where padding starts.

Constructors

 o PKCS5
 public PKCS5()
Creates a PKCS5 object.

Methods

 o enginePad
 protected int enginePad(byte in[],
                         int offset,
                         int length)
Pads a given array of bytes. The padding is written to the same buffer that is used for input (in). When this method returns, the padded block will be stored at in[offset+length..offset+7].

Parameters:
in - the buffer containing the incomplete block.
offset - the offset into the in buffer of the first byte in the group of bytes to be padded.
length - the number of bytes from the in buffer, starting at offset, that need to be padded.
Overrides:
enginePad in class PaddingScheme
 o engineUnpad
 protected int engineUnpad(byte in[],
                           int offset,
                           int length)
Given the specified subarray of bytes that includes padding bytes, returns the index indicating where padding starts.

For PKCS#5, the padding bytes all have value 8 - (length % 8). Hence to find the number of added bytes, it's enough to consider the last byte value of the padded message.

Parameters:
in - the buffer containing the bytes.
offset - the offset into the in buffer of the first byte in the block.
length - the length of the block in bytes.
Returns:
the index into the in buffer indicating where the padding starts.
Throws: CryptixException
if the number of padding bytes is invalid.
Overrides:
engineUnpad in class PaddingScheme
 o engineIsValidBlockSize
 protected boolean engineIsValidBlockSize(int size)
SPI: Returns true if size is a valid block size (in bytes) for this algorithm.

For PKCS#5 padding, the only valid size is 8 bytes.

Overrides:
engineIsValidBlockSize in class PaddingScheme

All Packages  Class Hierarchy  This Package  Previous  Next  Index