diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 2000-05-19 17:55:34 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2000-05-19 17:55:34 +0000 |
commit | 6c80c45e3010bfe992b41dd8800d2c4b65e0d5ef (patch) | |
tree | 88cf0d32aea197ea8e8198e1206b04c820308615 /libjava/gnu/gcj/io/SimpleSHSStream.java | |
parent | 021c89ed68c151c45021fccf1bb5338ee817314c (diff) | |
download | gcc-6c80c45e3010bfe992b41dd8800d2c4b65e0d5ef.zip gcc-6c80c45e3010bfe992b41dd8800d2c4b65e0d5ef.tar.gz gcc-6c80c45e3010bfe992b41dd8800d2c4b65e0d5ef.tar.bz2 |
Jumbo patch:
* Imported beans and serialization
* Updated IA-64 port
* Miscellaneous bug fixes
From-SVN: r34028
Diffstat (limited to 'libjava/gnu/gcj/io/SimpleSHSStream.java')
-rw-r--r-- | libjava/gnu/gcj/io/SimpleSHSStream.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/libjava/gnu/gcj/io/SimpleSHSStream.java b/libjava/gnu/gcj/io/SimpleSHSStream.java new file mode 100644 index 0000000..bcf8ea5 --- /dev/null +++ b/libjava/gnu/gcj/io/SimpleSHSStream.java @@ -0,0 +1,66 @@ +// SimpleSHSStream.java + +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.gcj.io; +import java.io.Serializable; +import java.io.*; +import java.lang.reflect.*; + +public class SimpleSHSStream extends java.io.DataOutputStream +{ + int counter; + + final int SHS_BLOCKSIZE = 64; + final int SHS_DIGESTSIZE = 20; + + byte buf[]; + byte shs_info[]; + + native static byte [] shsFinal (byte info[]); + native static void shsUpdate (byte info[], byte buf[], int count); + native static byte [] shsInit (); + + private void update (byte b) + { + buf [counter++] = b; + if (counter % SHS_BLOCKSIZE == 0) + { + counter = 0; + shsUpdate (shs_info, buf, SHS_BLOCKSIZE); + } + } + + public void write (int b) throws IOException + { + update ((byte)b); + super.write (b); + } + + public void write (byte[] b, int off, int len) throws IOException + { + for (int i = 0; i < len; i++) + write (b[i+off]); + } + + public byte[] digest() + { + shsUpdate (shs_info, buf, counter); + return shsFinal (shs_info); + } + + public SimpleSHSStream (OutputStream out) + { + super (out); + buf = new byte[SHS_BLOCKSIZE]; + shs_info = shsInit (); + counter = 0; + } +} + |