OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [gnu/] [gcj/] [io/] [SimpleSHSStream.java] - Blame information for rev 22

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
// SimpleSHSStream.java
2
 
3
/* Copyright (C) 2000  Free Software Foundation
4
 
5
   This file is part of libgcj.
6
 
7
This software is copyrighted work licensed under the terms of the
8
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9
details.  */
10
 
11
package gnu.gcj.io;
12
import java.io.Serializable;
13
import java.io.*;
14
import java.lang.reflect.*;
15
 
16
public class SimpleSHSStream extends java.io.DataOutputStream
17
{
18
  int counter;
19
 
20
  final int SHS_BLOCKSIZE = 64;
21
  final int SHS_DIGESTSIZE = 20;
22
 
23
  byte buf[];
24
  byte shs_info[];
25
 
26
  native static byte [] shsFinal (byte info[]);
27
  native static void shsUpdate (byte info[], byte buf[], int count);
28
  native static byte [] shsInit ();
29
 
30
  private void update (byte b)
31
  {
32
    buf [counter++] = b;
33
    if (counter % SHS_BLOCKSIZE == 0)
34
      {
35
        counter = 0;
36
        shsUpdate (shs_info, buf, SHS_BLOCKSIZE);
37
      }
38
  }
39
 
40
  public void write (int b) throws IOException
41
  {
42
    update ((byte)b);
43
    super.write (b);
44
  }
45
 
46
  public void write (byte[] b, int off, int len) throws IOException
47
  {
48
    for (int i = 0; i < len; i++)
49
      write (b[i+off]);
50
  }
51
 
52
  public byte[] digest()
53
  {
54
    shsUpdate (shs_info, buf, counter);
55
    return shsFinal (shs_info);
56
  }
57
 
58
  public SimpleSHSStream (OutputStream out)
59
  {
60
    super (out);
61
    buf = new byte[SHS_BLOCKSIZE];
62
    shs_info = shsInit ();
63
    counter = 0;
64
  }
65
}
66
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.