|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.fasteasytrade.JRandTest.Algo.Cipher com.fasteasytrade.JRandTest.Algo.SHA1
SHA-1 Message Digest class.
LapInt number theory library Copyright (c) 2001-2002 Lapo Luchini
<lapo@lapo.it>
From package lapint.crypto.
Follows the FIPS PUB
180-1 standard which elaborates a message digest from given data (length
<2^64 bytes).
As of version 1.10 I obtained the following stats using Linux 2.4.8 on a
P3-850:
21.56 Mb/s (100%)
Adam Back C implementation, compiled
with GCC 2.95 -O213.09 Mb/s ( 61%)
This Java implementation, compiled
natively with GCC 2.95 -O210.04 Mb/s ( 47%)
This Java implementation, compiled with
JIKES and executed with KAFFE JIT314.62 Mb/s (100%)
Adam Back C implementation, compiled
with GCC 2.95 -O210.20 Mb/s ( 70%)
This Java implementation, compiled
natively with JET 2.50beta 7.87 Mb/s ( 54%)
This Java implementation, compiled with
JIKES and executed with Sun JVM 1.4.0 6.34 Mb/s ( 43%)
Sun's MessageDigest.getInstance("SHA1")
executed with Sun JVM 1.4.0
Field Summary | |
private int[] |
H
Partial hash |
private static char[] |
hex
Used to convert number to Hex strings |
private boolean |
reset
Wherever next update should start from scratch |
static int[] |
TEST_0_HASH
First official test result |
static String |
TEST_0_STRING
First official test |
static int[] |
TEST_1_HASH
Second official test result |
static String |
TEST_1_STRING
Second official test |
static int[] |
TEST_2_HASH
Third official test result |
static String |
TEST_2_STRING
Third official test |
private long |
totb
Total bytes digested |
private int[] |
W
Internal buffer |
Constructor Summary | |
SHA1()
Creates a SHA1 object. |
Method Summary | |
Object |
clone()
|
private void |
digest_finalize()
Finalize the hash calculation, as defined in the standard. |
int[] |
digest32()
Returns the digest and resets the object to calculate another digest. |
byte[] |
digest8()
Returns the digest and resets the object to calculate another digest. |
int[] |
getH()
get internal hash vector |
byte[] |
getHAsBytes()
get internal hash vector as vector of bytes |
void |
getHAsBytes(byte[] v)
get internal hash vector as vector of bytes |
void |
init(byte[] m)
init internal buffer with IV (of bytes) |
void |
init(int[] m)
init internal buffer with IV (of ints) |
static void |
main(String[] args)
Method to self-test the class from command line. |
static void |
selfTest()
Self test using standard tests and write to standard output the result. |
static String |
toHex(byte[] v)
Formats a number in an hex string. |
private void |
update_buffers()
Internally used when the buffer is ready for the digest. |
void |
update(byte m)
|
void |
update(byte[] m)
Feeds more bytes to the digest. |
void |
update(int[] m)
Updates the hash with more ints (big-endian). |
void |
update(long[] m)
Updates the hash with more longs (big-endian). |
Methods inherited from class com.fasteasytrade.JRandTest.Algo.Cipher |
compareBytes |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private int[] H
private transient int[] W
private long totb
private boolean reset
private static char[] hex
public static final String TEST_0_STRING
public static final String TEST_1_STRING
public static final String TEST_2_STRING
public static final int[] TEST_0_HASH
public static final int[] TEST_1_HASH
public static final int[] TEST_2_HASH
Constructor Detail |
public SHA1()
Method Detail |
public Object clone()
public byte[] digest8()
update()
will start from scratch. clone()
to get partial digests.
public int[] digest32()
update()
will start from scratch. clone()
to get partial digests.
private void digest_finalize()
public void update(byte m)
public void init(byte[] m)
m
- IV vector of bytespublic void init(int[] m)
m
- IV vector of integers (32 bits)public void update(byte[] m)
m
- bytes to elaborate (any length is valid)public void update(int[] m)
m
- an array of ints to addpublic void update(long[] m)
m
- an array of ints to addprivate final void update_buffers()
public static void main(String[] args)
args
- command line parameterspublic static void selfTest()
public static final String toHex(byte[] v)
v
- number to format
public int[] getH()
public byte[] getHAsBytes()
public void getHAsBytes(byte[] v)
v
- H interbnal vector is copied into v
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |