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

ZeroBytePadding

public class ZeroBytePadding extends Object implements BlockCipherPadding
A padder that adds NULL byte padding to a block.

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);

        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 "ZeroByte";
    
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;

        while (count > 0)
        {
            if (in[count - 1] != 0)
            {
                break;
            }

            count--;
        }

        return in.length - count;