1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.crypto

File Digest.java

 

Code metrics

0
0
0
1
131
20
0
-
-
0
-

Classes

Class Line # Actions
Digest 35 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.crypto;
21   
22    import java.io.FilterInputStream;
23    import java.io.IOException;
24    import java.io.InputStream;
25    import java.io.OutputStream;
26   
27    import org.xwiki.crypto.params.DigestParameters;
28   
29    /**
30    * Interface on a message Digest.
31    *
32    * @version $Id: 81ec566c1191437cb24b17ed9b49562f483acc6e $
33    * @since 5.4M1
34    */
 
35    public interface Digest
36    {
37    /**
38    * @return the algorithm name of the underlying digest.
39    */
40    String getAlgorithmName();
41   
42    /**
43    * @return the size of the digest produced by this message digest (in bytes).
44    */
45    int getDigestSize();
46   
47    /**
48    * @return if any, return the parameters of this digest.
49    */
50    DigestParameters getParameters();
51   
52    /**
53    * Return a filtered input stream computing byte read into a digest.
54    *
55    * The digest is reset each time this function is called.
56    * Any previously retrieved input stream or in progress operation should therefore be discarded.
57    *
58    * @param is an input stream to read and calculate digest from. Call {@link #digest()} to get the digest.
59    * @return a filtered input stream based calculating digest of bytes read.
60    */
61    FilterInputStream getInputStream(InputStream is);
62   
63    /**
64    * Return an output stream to this digest.
65    *
66    * The digest is reset each time this function is called.
67    * Any previously retrieved input stream or in progress operation should therefore be discarded.
68    *
69    * @return avn output stream writing to this digest.
70    */
71    OutputStream getOutputStream();
72   
73    /**
74    * Continues a multiple-part digest operation, processing another data part.
75    *
76    * @param input the input buffer.
77    */
78    void update(byte[] input);
79   
80    /**
81    * Continues a multiple-part digest operation, processing another data part.
82    *
83    * @param input the input buffer.
84    * @param inputOffset the offset in input where the input starts.
85    * @param inputLen the input length.
86    */
87    void update(byte[] input, int inputOffset, int inputLen);
88   
89    /**
90    * Finishes a multiple-part digest operation, and produce the resulting digest.
91    *
92    * Upon finishing, this method resets this digest.
93    *
94    * @return a new buffer with the resulting digest.
95    */
96    byte[] digest();
97   
98    /**
99    * Finishes a multiple-part digest operation, and produce the resulting digest.
100    *
101    * Upon finishing, this method resets this digest.
102    *
103    * @param input the input buffer.
104    * @return a new buffer with the resulting digest.
105    */
106    byte[] digest(byte[] input);
107   
108    /**
109    * Finishes a multiple-part digest operation, and produce the resulting digest.
110    *
111    * Upon finishing, this method resets this digest.
112    *
113    * @param input the input buffer.
114    * @param inputOffset the offset in input where the input starts.
115    * @param inputLen the input length.
116    * @return a new buffer with the resulting digest.
117    */
118    byte[] digest(byte[] input, int inputOffset, int inputLen);
119   
120    /**
121    * Serialize the definition of this digest.
122    *
123    * This serialization could be provided to an appropriate factory (like the one that have been used to create this
124    * digest) to produce an equivalent digest. The serialization contains the digest algorithm.
125    * For best interoperability, the recommended encoding is ASN.1 in DER format.
126    *
127    * @return an encoded definition of this digest.
128    * @throws IOException on error
129    */
130    byte[] getEncoded() throws IOException;
131    }