01: package org.bouncycastle.crypto.paddings;
02:
03: import java.security.SecureRandom;
04:
05: import org.bouncycastle.crypto.InvalidCipherTextException;
06:
07: /**
08: * Block cipher padders are expected to conform to this interface
09: */
10: public interface BlockCipherPadding {
11: /**
12: * Initialise the padder.
13: *
14: * @param random the source of randomness for the padding, if required.
15: */
16: public void init(SecureRandom random)
17: throws IllegalArgumentException;
18:
19: /**
20: * Return the name of the algorithm the cipher implements.
21: *
22: * @return the name of the algorithm the cipher implements.
23: */
24: public String getPaddingName();
25:
26: /**
27: * add the pad bytes to the passed in block, returning the
28: * number of bytes added.
29: * <p>
30: * Note: this assumes that the last block of plain text is always
31: * passed to it inside in. i.e. if inOff is zero, indicating the
32: * entire block is to be overwritten with padding the value of in
33: * should be the same as the last block of plain text. The reason
34: * for this is that some modes such as "trailing bit compliment"
35: * base the padding on the last byte of plain text.
36: * </p>
37: */
38: public int addPadding(byte[] in, int inOff);
39:
40: /**
41: * return the number of pad bytes present in the block.
42: * @exception InvalidCipherTextException if the padding is badly formed
43: * or invalid.
44: */
45: public int padCount(byte[] in) throws InvalidCipherTextException;
46: }
|