|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.security.MessageDigestSpi de.cscc.crypto.provider.RIPEMD160MessageDigestEngine
RIPEMD160MessageDigestEngine Class. This class does the RIPEMD-160 algorithm via delegation to RIPEMD160MessageDigestImpl and is implemented as JCA (Java Cryptogrphy Architecture) Service Provider. You can not instance these class direct, because it is enabled through the JCA API.
The sum of all added bytes from engineUpdate(byte)
and engineUpdate(byte[], int, int)
are processed by the RIPEMD-160
message digest algorithm with engineDigest()
or
engineDigest(byte[], int, int)
.
How does it work: ================= RIPEMD-160 works only with whole 512 bit blocks. 512bits == 64 bytes == 16 words ------------------------------------------------- |00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15| ------------------------------------------------- / \ / \ / \ / \ / \ ------------- |32 bit word| <-- 32 bit word = 4 byte ------------- |00|01|02|03| <-- 4 bytes = 4 x 8 bit = 32 bit -------------
Here is a simple Code Example:
import java.security.Security; import java.security.Provider; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import de.cscc.crypto.provider.HBCI; import java.io.IOException; public class MyMessageDigest{ public static void main(String args[]){ // add Provider int i = Security.addProvider(new de.cscc.crypto.provider.JHBCI()); System.out.println("Provider inserted at position " + i + "."); // get provider Provider p = Security.getProvider("JHBCI"); System.out.println("My Provider Name is " + p.getName()); System.out.println("My Provider Version is " + p.getVersion()); System.out.println("My Provider Info is " + p.getInfo()); // get MessageDigest Object through the JCA API MessageDigest myRIPEMD1 = null; MessageDigest myRIPEMD2 = null, try{ myRIPEMD1 = MessageDigest.getInstance("RIPEMD160"); } catch(NoSuchAlgorithmException e){ e.printStackTrace(); } // put the messaeg in the MessageDigest object byte[] myByte = {'a','b','c'}; myRIPEMD1.update(myByte); // clone the object try { myRIPEMD2 = myRIPEMD1.clone } catch (CloneNotSupportedException e) { e.printStackTrace(); } // get the Message Digests byte[] messageDigest1 = myRIPEMD1.digest(); byte[] messageDigest2 = myRIPEMD2.digest(); // now the byte arrays messageDigest[12] holds a 20 byte long message // digest of the message "abc" and should be in binary form: // 0x8eb208f7e05d987a9b044a8e98c6b087f15a0bfc // verify the two digests boolean verify = MessageDigest.isEqual(messageDigest1, messageDigest2); System.out.println("The two digests are equal: " + verify); } }
Constructor Summary | |
RIPEMD160MessageDigestEngine()
Creates new RIPEMD160MessageDigestEngine. |
Method Summary | |
Object |
clone()
Creates and returns a deep of this object. |
protected byte[] |
engineDigest()
If the whole message added to the message digest object, you should invoke the digest method at your API object (MessageDigest). |
protected int |
engineDigest(byte[] buf,
int offset,
int len)
If the whole message added to the message digest object, you should invoke the digest method at your API Object (MessageDigest). |
protected int |
engineGetDigestLength()
Returns the length of the message digest in byte. |
protected void |
engineReset()
Resets the message digest object, for further use. |
protected void |
engineUpdate(byte value)
Updates the internal message buffer with byte value . |
protected void |
engineUpdate(byte[] values,
int offset,
int len)
Updates the internal message buffer with byte[] value ,
starting at offset, ending at len. |
boolean |
equals(Object obj)
Compares two RIPEMD160MessageDigestEngine objects. |
int |
hashCode()
Returns a hash code value for the object. |
String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public RIPEMD160MessageDigestEngine()
java.security.MessageDigest.getInstance()
.
Method Detail |
public Object clone() throws CloneNotSupportedException
CloneNotSupportedException
- if the object's class does not
support the Cloneable
interface. Subclasses
that override the clone
method can also
throw this exception to indicate that an instance cannot
be cloned.Cloneable
public boolean equals(Object obj)
obj
- RIPEMD160MessageDigestEngine object to compare.
public int hashCode()
java.util.Hashtable
.
equals(java.lang.Object)
,
Hashtable
public String toString()
protected byte[] engineDigest()
protected int engineDigest(byte[] buf, int offset, int len) throws DigestException
buf
- the message digest in 20 byte long byte array.
This byte array contains the 160 bit digest in binary form.offset
- begin of buffer.len
- end of buffer.
DigestException
- If the difference between len-offset less than
20 bytes a DigestException will be thrown.protected int engineGetDigestLength()
protected void engineReset()
protected void engineUpdate(byte value)
byte value
.
value
- message byte.protected void engineUpdate(byte[] values, int offset, int len)
byte[] value
,
starting at offset, ending at len.
values
- message byte array.offset
- begin of message byte array.len
- end of message byte array.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |