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

ISO7816d4Padding

public class ISO7816d4Padding extends Object implements BlockCipherPadding
A padder that adds the padding according to the scheme referenced in ISO 7814-4 - scheme 2 from ISO 9797-1. The first byte is 0x80, rest is 0x00

Fields Summary
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.

        int added = (in.length - inOff);

        in [inOff]= (byte) 0x80;
        inOff ++;
        
        while (inOff < in.length)
        {
            in[inOff] = (byte) 0;
            inOff++;
        }

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

return
the name of the algorithm the padder implements.

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

param
random - a SecureRandom if available.

        // nothing to do.
    
public intpadCount(byte[] in)
return the number of pad bytes present in the block.

        int count = in.length - 1;

        while (count > 0 && in[count] == 0)
        {
            count--;
        }

        if (in[count] != (byte)0x80)
        {
            throw new InvalidCipherTextException("pad block corrupted");
        }
        
        return in.length - count;