FileDocCategorySizeDatePackage
ISO10126d2Padding.javaAPI DocAndroid 1.5 API1661Wed May 06 22:41:06 BST 2009org.bouncycastle.crypto.paddings

ISO10126d2Padding

public class ISO10126d2Padding extends Object implements BlockCipherPadding
A padder that adds ISO10126-2 padding to a block.

Fields Summary
SecureRandom
random
Constructors Summary
Methods Summary
public intaddPadding(byte[] in, int inOff)
add the pad bytes to the passed in block, returning the number of bytes added.

        byte code = (byte)(in.length - inOff);

        while (inOff < (in.length - 1))
        {
            in[inOff] = (byte)random.nextInt();
            inOff++;
        }

        in[inOff] = code;

        return code;
    
public java.lang.StringgetPaddingName()
Return the name of the algorithm the padder implements.

return
the name of the algorithm the padder implements.

        return "ISO10126-2";
    
public voidinit(java.security.SecureRandom random)
Initialise the padder.

param
random a SecureRandom if available.

        if (random != null)
        {
            this.random = random;
        }
        else
        {
            this.random = new SecureRandom();
        }
    
public intpadCount(byte[] in)
return the number of pad bytes present in the block.

        int count = in[in.length - 1] & 0xff;

        if (count > in.length)
        {
            throw new InvalidCipherTextException("pad block corrupted");
        }

        return count;