1 // SimpleSHSStream.java
3 /* Copyright (C) 2000 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 import java
.io
.Serializable
;
14 import java
.lang
.reflect
.*;
16 public class SimpleSHSStream
extends java
.io
.DataOutputStream
20 final int SHS_BLOCKSIZE
= 64;
21 final int SHS_DIGESTSIZE
= 20;
26 native static byte [] shsFinal (byte info
[]);
27 native static void shsUpdate (byte info
[], byte buf
[], int count
);
28 native static byte [] shsInit ();
30 private void update (byte b
)
33 if (counter
% SHS_BLOCKSIZE
== 0)
36 shsUpdate (shs_info
, buf
, SHS_BLOCKSIZE
);
40 public void write (int b
) throws IOException
46 public void write (byte[] b
, int off
, int len
) throws IOException
48 for (int i
= 0; i
< len
; i
++)
52 public byte[] digest()
54 shsUpdate (shs_info
, buf
, counter
);
55 return shsFinal (shs_info
);
58 public SimpleSHSStream (OutputStream out
)
61 buf
= new byte[SHS_BLOCKSIZE
];
62 shs_info
= shsInit ();