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