iaik.security.md
Class Md2
java.lang.Object
|
+--java.security.MessageDigestSpi
|
+--java.security.MessageDigest
|
+--iaik.security.md.Md2
- public class Md2
- extends MessageDigest
- implements java.lang.Cloneable, java.io.Serializable
This class implements the MD2 message digest algorithm by
Burt Kaliski as described in
This class extends the java.security.MessageDigest class
and applications should use one of the getInstance methods
presented there to create a MessageDigest-MD2 object.
Generally, an application wishing to compute the message digest of some
data has to perform three steps:
- First an instance of the desired message digest algorithm has to be
created using a proper
getInstance method, e.g.:
MessageDigest md2 = MessageDigest.getInstance("MD2");
- Second, the data to be hashed is supplied to the MessageDigest object
just created by one or more calls to one of the
update methods,
e.g:
md2.update(m1);
md2.update(m2);
...
- Finally, the hash value can be computed using one of the
digest methods:
byte[] hash_value = md2.digest();
There are several ways for combining update and
digest methods for computing a message digest. Since
this class implements the Cloneable interface,
MD2 MessageDigest objects may be used for compute intermediate
hashes through cloning (see
http://java.sun.com/products/JDK/1.1/docs/guide/security/CryptoSpec.html).
When the hash value successfully has been computed, the MD2 MessageDigest
object automatically resets for being able to be supplied with new data to
be hashed.
The MD2 algorithm may be combined with a public-key algorithm (e.g. RSA) to
be used as digital signature algorithm (see iaik.security.rsa.Md2RSASignature).
- See Also:
Md2RSASignature,
SHA,
Md5, Serialized Form
|
Constructor Summary |
Md2()
Creates a new MD2 message digest object. |
|
Method Summary |
java.lang.Object |
clone()
Returns a clone of this Md2 Object. |
void |
destroyCriticalData()
|
byte[] |
engineDigest()
SPI: Returns the result of this hash computation and resets
this MD2 message digest object for being supplied with new data to
be hashed. |
void |
engineReset()
SPI: Resets this MD2 message digest object for being supplied
with new data. |
void |
engineUpdate(byte input)
SPI: Updates the data to be hashed with the specified byte. |
void |
engineUpdate(byte[] input,
int offset,
int len)
SPI: Updates the data to be hashed with the specified number of
bytes, beginning at the specified offset within the given byte array. |
protected void |
finalize()
|
| Methods inherited from class java.security.MessageDigest |
digest,
digest,
digest,
getAlgorithm,
getDigestLength,
getInstance,
getInstance,
getProvider,
isEqual,
reset,
toString,
update,
update,
update |
| Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Md2
public Md2()
- Creates a new MD2 message digest object.
Applications do not use this constructor. They shall use
MessageDigest.getInstance("MD2");
for creating a MesssageDigest object.
- See Also:
MessageDigest.getInstance(java.lang.String)
engineUpdate
public void engineUpdate(byte[] input,
int offset,
int len)
- SPI: Updates the data to be hashed with the specified number of
bytes, beginning at the specified offset within the given byte array.
- Overrides:
- engineUpdate in class MessageDigestSpi
- Parameters:
input - the byte array holding the data to be used for this update
operation.offset - the offset, indicating the start position within the given
byte array.len - the number of bytes to be obtained from the given byte array,
starting at the given position.
engineUpdate
public void engineUpdate(byte input)
- SPI: Updates the data to be hashed with the specified byte.
- Overrides:
- engineUpdate in class MessageDigestSpi
- Parameters:
input - the byte to be used for updating.
engineReset
public void engineReset()
- SPI: Resets this MD2 message digest object for being supplied
with new data.
This method is called by engineDigest
after the actual hash computation has been finished to automatically reset
the message digest object for being supplied with new data for starting a
new hash computation.
- Overrides:
- engineReset in class MessageDigestSpi
- See Also:
engineDigest()
engineDigest
public byte[] engineDigest()
- SPI: Returns the result of this hash computation and resets
this MD2 message digest object for being supplied with new data to
be hashed.
- Overrides:
- engineDigest in class MessageDigestSpi
- Returns:
- a byte array holding the calculated hash value
clone
public java.lang.Object clone()
- Returns a clone of this Md2 Object.
- Overrides:
- clone in class MessageDigest
- Returns:
- a clone of this Md2 Object
destroyCriticalData
public void destroyCriticalData()
finalize
protected void finalize()
- Overrides:
- finalize in class java.lang.Object