1 |
769 |
jeremybenn |
/* IMessageDigest.java --
|
2 |
|
|
Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This file is a part of GNU Classpath.
|
5 |
|
|
|
6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
7 |
|
|
it under the terms of the GNU General Public License as published by
|
8 |
|
|
the Free Software Foundation; either version 2 of the License, or (at
|
9 |
|
|
your option) any later version.
|
10 |
|
|
|
11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
General Public License for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License
|
17 |
|
|
along with GNU Classpath; if not, write to the Free Software
|
18 |
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
|
19 |
|
|
USA
|
20 |
|
|
|
21 |
|
|
Linking this library statically or dynamically with other modules is
|
22 |
|
|
making a combined work based on this library. Thus, the terms and
|
23 |
|
|
conditions of the GNU General Public License cover the whole
|
24 |
|
|
combination.
|
25 |
|
|
|
26 |
|
|
As a special exception, the copyright holders of this library give you
|
27 |
|
|
permission to link this library with independent modules to produce an
|
28 |
|
|
executable, regardless of the license terms of these independent
|
29 |
|
|
modules, and to copy and distribute the resulting executable under
|
30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
31 |
|
|
independent module, the terms and conditions of the license of that
|
32 |
|
|
module. An independent module is a module which is not derived from
|
33 |
|
|
or based on this library. If you modify this library, you may extend
|
34 |
|
|
this exception to your version of the library, but you are not
|
35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
36 |
|
|
exception statement from your version. */
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
package gnu.java.security.hash;
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* The basic visible methods of any hash algorithm.
|
43 |
|
|
* <p>
|
44 |
|
|
* A hash (or message digest) algorithm produces its output by iterating a basic
|
45 |
|
|
* compression function on blocks of data.
|
46 |
|
|
*/
|
47 |
|
|
public interface IMessageDigest
|
48 |
|
|
extends Cloneable
|
49 |
|
|
{
|
50 |
|
|
/**
|
51 |
|
|
* Returns the canonical name of this algorithm.
|
52 |
|
|
*
|
53 |
|
|
* @return the canonical name of this instance.
|
54 |
|
|
*/
|
55 |
|
|
String name();
|
56 |
|
|
|
57 |
|
|
/**
|
58 |
|
|
* Returns the output length in bytes of this message digest algorithm.
|
59 |
|
|
*
|
60 |
|
|
* @return the output length in bytes of this message digest algorithm.
|
61 |
|
|
*/
|
62 |
|
|
int hashSize();
|
63 |
|
|
|
64 |
|
|
/**
|
65 |
|
|
* Returns the algorithm's (inner) block size in bytes.
|
66 |
|
|
*
|
67 |
|
|
* @return the algorithm's inner block size in bytes.
|
68 |
|
|
*/
|
69 |
|
|
int blockSize();
|
70 |
|
|
|
71 |
|
|
/**
|
72 |
|
|
* Continues a message digest operation using the input byte.
|
73 |
|
|
*
|
74 |
|
|
* @param b the input byte to digest.
|
75 |
|
|
*/
|
76 |
|
|
void update(byte b);
|
77 |
|
|
|
78 |
|
|
/**
|
79 |
|
|
* Continues a message digest operation, by filling the buffer, processing
|
80 |
|
|
* data in the algorithm's HASH_SIZE-bit block(s), updating the context and
|
81 |
|
|
* count, and buffering the remaining bytes in buffer for the next operation.
|
82 |
|
|
*
|
83 |
|
|
* @param in the input block.
|
84 |
|
|
*/
|
85 |
|
|
void update(byte[] in);
|
86 |
|
|
|
87 |
|
|
/**
|
88 |
|
|
* Continues a message digest operation, by filling the buffer, processing
|
89 |
|
|
* data in the algorithm's HASH_SIZE-bit block(s), updating the context and
|
90 |
|
|
* count, and buffering the remaining bytes in buffer for the next operation.
|
91 |
|
|
*
|
92 |
|
|
* @param in the input block.
|
93 |
|
|
* @param offset start of meaningful bytes in input block.
|
94 |
|
|
* @param length number of bytes, in input block, to consider.
|
95 |
|
|
*/
|
96 |
|
|
void update(byte[] in, int offset, int length);
|
97 |
|
|
|
98 |
|
|
/**
|
99 |
|
|
* Completes the message digest by performing final operations such as padding
|
100 |
|
|
* and resetting the instance.
|
101 |
|
|
*
|
102 |
|
|
* @return the array of bytes representing the hash value.
|
103 |
|
|
*/
|
104 |
|
|
byte[] digest();
|
105 |
|
|
|
106 |
|
|
/**
|
107 |
|
|
* Resets the current context of this instance clearing any eventually cached
|
108 |
|
|
* intermediary values.
|
109 |
|
|
*/
|
110 |
|
|
void reset();
|
111 |
|
|
|
112 |
|
|
/**
|
113 |
|
|
* A basic test. Ensures that the digest of a pre-determined message is equal
|
114 |
|
|
* to a known pre-computed value.
|
115 |
|
|
*
|
116 |
|
|
* @return <code>true</code> if the implementation passes a basic self-test.
|
117 |
|
|
* Returns <code>false</code> otherwise.
|
118 |
|
|
*/
|
119 |
|
|
boolean selfTest();
|
120 |
|
|
|
121 |
|
|
/**
|
122 |
|
|
* Returns a clone copy of this instance.
|
123 |
|
|
*
|
124 |
|
|
* @return a clone copy of this instance.
|
125 |
|
|
*/
|
126 |
|
|
Object clone();
|
127 |
|
|
}
|