2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
package com.sun.crypto.provider;
|
|
27 |
|
|
28 |
import javax.crypto.ShortBufferException;
|
|
29 |
|
|
30 |
/**
|
|
31 |
* Padding interface.
|
|
32 |
*
|
|
33 |
* This interface is implemented by general-purpose padding schemes, such as
|
|
34 |
* the one described in PKCS#5.
|
|
35 |
*
|
|
36 |
* @author Jan Luehe
|
|
37 |
* @author Gigi Ankeny
|
|
38 |
*
|
|
39 |
*
|
|
40 |
* @see PKCS5Padding
|
|
41 |
*/
|
|
42 |
|
|
43 |
interface Padding {
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Adds the given number of padding bytes to the data input.
|
|
47 |
* The value of the padding bytes is determined
|
|
48 |
* by the specific padding mechanism that implements this
|
|
49 |
* interface.
|
|
50 |
*
|
|
51 |
* @param in the input buffer with the data to pad
|
|
52 |
* @param the offset in <code>in</code> where the padding bytes
|
|
53 |
* are appended
|
|
54 |
* @param len the number of padding bytes to add
|
|
55 |
*
|
|
56 |
* @exception ShortBufferException if <code>in</code> is too small to hold
|
|
57 |
* the padding bytes
|
|
58 |
*/
|
|
59 |
void padWithLen(byte[] in, int off, int len) throws ShortBufferException;
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Returns the index where padding starts.
|
|
63 |
*
|
|
64 |
* <p>Given a buffer with data and their padding, this method returns the
|
|
65 |
* index where the padding starts.
|
|
66 |
*
|
|
67 |
* @param in the buffer with the data and their padding
|
|
68 |
* @param off the offset in <code>in</code> where the data starts
|
|
69 |
* @param len the length of the data and their padding
|
|
70 |
*
|
|
71 |
* @return the index where the padding starts, or -1 if the input is
|
|
72 |
* not properly padded
|
|
73 |
*/
|
|
74 |
int unpad(byte[] in, int off, int len);
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Determines how long the padding will be for a given input length.
|
|
78 |
*
|
|
79 |
* @param len the length of the data to pad
|
|
80 |
*
|
|
81 |
* @return the length of the padding
|
|
82 |
*/
|
|
83 |
int padLength(int len);
|
|
84 |
}
|