equal
deleted
inserted
replaced
80 0x431D67C49C100D4CL, 0x4CC5D4BECB3E42B6L, 0x597F299CFC657E2AL, |
80 0x431D67C49C100D4CL, 0x4CC5D4BECB3E42B6L, 0x597F299CFC657E2AL, |
81 0x5FCB6FAB3AD6FAECL, 0x6C44198C4A475817L |
81 0x5FCB6FAB3AD6FAECL, 0x6C44198C4A475817L |
82 }; |
82 }; |
83 |
83 |
84 // buffer used by implCompress() |
84 // buffer used by implCompress() |
85 private final long[] W; |
85 private long[] W; |
86 |
86 |
87 // state of this object |
87 // state of this object |
88 private final long[] state; |
88 private long[] state; |
89 |
89 |
90 // initial state value. different between SHA-384 and SHA-512 |
90 // initial state value. different between SHA-384 and SHA-512 |
91 private final long[] initialHashes; |
91 private final long[] initialHashes; |
92 |
92 |
93 /** |
93 /** |
97 super(name, digestLength, 128); |
97 super(name, digestLength, 128); |
98 this.initialHashes = initialHashes; |
98 this.initialHashes = initialHashes; |
99 state = new long[8]; |
99 state = new long[8]; |
100 W = new long[80]; |
100 W = new long[80]; |
101 implReset(); |
101 implReset(); |
102 } |
|
103 |
|
104 /** |
|
105 * Creates a SHA object with state (for cloning) |
|
106 */ |
|
107 SHA5(SHA5 base) { |
|
108 super(base); |
|
109 this.initialHashes = base.initialHashes; |
|
110 this.state = base.state.clone(); |
|
111 this.W = new long[80]; |
|
112 } |
102 } |
113 |
103 |
114 final void implReset() { |
104 final void implReset() { |
115 System.arraycopy(initialHashes, 0, state, 0, state.length); |
105 System.arraycopy(initialHashes, 0, state, 0, state.length); |
116 } |
106 } |
253 state[5] += f; |
243 state[5] += f; |
254 state[6] += g; |
244 state[6] += g; |
255 state[7] += h; |
245 state[7] += h; |
256 } |
246 } |
257 |
247 |
|
248 public Object clone() throws CloneNotSupportedException { |
|
249 SHA5 copy = (SHA5) super.clone(); |
|
250 copy.state = copy.state.clone(); |
|
251 copy.W = new long[80]; |
|
252 return copy; |
|
253 } |
|
254 |
258 /** |
255 /** |
259 * SHA-512 implementation class. |
256 * SHA-512 implementation class. |
260 */ |
257 */ |
261 public static final class SHA512 extends SHA5 { |
258 public static final class SHA512 extends SHA5 { |
262 |
259 |
268 }; |
265 }; |
269 |
266 |
270 public SHA512() { |
267 public SHA512() { |
271 super("SHA-512", 64, INITIAL_HASHES); |
268 super("SHA-512", 64, INITIAL_HASHES); |
272 } |
269 } |
273 |
|
274 private SHA512(SHA512 base) { |
|
275 super(base); |
|
276 } |
|
277 |
|
278 public Object clone() { |
|
279 return new SHA512(this); |
|
280 } |
|
281 } |
270 } |
282 |
271 |
283 /** |
272 /** |
284 * SHA-384 implementation class. |
273 * SHA-384 implementation class. |
285 */ |
274 */ |
293 }; |
282 }; |
294 |
283 |
295 public SHA384() { |
284 public SHA384() { |
296 super("SHA-384", 48, INITIAL_HASHES); |
285 super("SHA-384", 48, INITIAL_HASHES); |
297 } |
286 } |
298 |
287 } |
299 private SHA384(SHA384 base) { |
|
300 super(base); |
|
301 } |
|
302 |
|
303 public Object clone() { |
|
304 return new SHA384(this); |
|
305 } |
|
306 } |
|
307 |
|
308 } |
288 } |