APIdia Launch Partner
Top Description Methods
com.sun.crypto.provider

pack-priv Interface Padding

Known Direct Implementers
com.sun.crypto.provider.PKCS5Padding, com.sun.crypto.provider.ISO10126Padding
Imports
javax.crypto.ShortBufferException

Padding interface. This interface is implemented by general-purpose padding schemes, such as the one described in PKCS#5.
Authors
Jan Luehe, Gigi Ankeny
See Also
PKCS5Padding

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the length of the padding
padLength
(int
the length of the data to pad
len
)

Determines how long the padding will be for a given input length.

public void
padWithLen(byte[]
the input buffer with the data to pad
in
,
int
the offset in in where the padding bytes are appended
off
,
int
the number of padding bytes to add
len
)

Adds the given number of padding bytes to the data input.

public int

Returns:

the index where the padding starts, or -1 if the input is not properly padded
unpad
(byte[]
the buffer with the data and their padding
in
,
int
the offset in in where the data starts
off
,
int
the length of the data and their padding
len
)

Returns the index where padding starts.

Method Detail

padLengthback to summary
public int padLength(int len)

Determines how long the padding will be for a given input length.

Parameters
len:int

the length of the data to pad

Returns:int

the length of the padding

padWithLenback to summary
public void padWithLen(byte[] in, int off, int len) throws ShortBufferException

Adds the given number of padding bytes to the data input. The value of the padding bytes is determined by the specific padding mechanism that implements this interface.

Parameters
in:byte[]

the input buffer with the data to pad

off:int

the offset in in where the padding bytes are appended

len:int

the number of padding bytes to add

Exceptions
ShortBufferException:
if in is too small to hold the padding bytes
unpadback to summary
public int unpad(byte[] in, int off, int len)

Returns the index where padding starts.

Given a buffer with data and their padding, this method returns the index where the padding starts.

Parameters
in:byte[]

the buffer with the data and their padding

off:int

the offset in in where the data starts

len:int

the length of the data and their padding

Returns:int

the index where the padding starts, or -1 if the input is not properly padded