public final class SHA1
extends java.security.MessageDigest
A message digest algorithm represents the functionality of a one-way hash function. A hash function is a computationally efficient function, mapping binary strings (messages) of arbitrary length to binary strings (digests) of some fixed length. Theses algorithms enable the determination of a message's integrity: any change to the message will, with very high probability, result in a different message digest. This property is useful in the generation and verification of digital signatures and message authentication codes, and in the generation of random numbers.
The SHA-1 message digest can process messages of up to 2^64 bits in length, and always produces a 160-bit digest. The algorithm can be described in two stages: pre-processing and hash computation. Pre-processing involves padding a message, parsing the padded message into 512-bit blocks, and setting initialization values to be used in the hash computation. The hash computation generates a message schedule from the padded message and uses that schedule, along with functions, constants, and word operations to iteratively generate a series of hash values. The final hash value generated by the hash computation is used to determine the message digest.
An instance of this algorithm can be obtained using the Java Cryptography
Architecture (JCA), by requesting a 'SHA-1' message digest from the
Entrust cryptographic
service provider. This can be done using the following call:
MessageDigest.getInstance("SHA-1", "Entrust");| Constructor and Description |
|---|
SHA1()
The constructor; creates a new instance of the SHA-1 message digest
algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
engineDigest()
Completes the hash computation by performing final operations such as
padding.
|
protected int |
engineDigest(byte[] buf,
int offset,
int len)
Completes the hash computation by performing final operations such as
padding.
|
protected int |
engineGetDigestLength()
Returns the digest length in bytes.
|
protected void |
engineReset()
Resets the digest for further use.
|
protected void |
engineUpdate(byte input)
Updates the digest using the specified byte.
|
protected void |
engineUpdate(byte[] input,
int offset,
int length)
Updates the digest using the specified array of bytes, starting at the
specified offset.
|
public SHA1()
Applications should not use this constructor, instead the message digest
algorithm should be requested from the appropriate JCA/JCE cryptographic
service provider as follows:
MessageDigest.getInstance("SHA-1", "Entrust").
protected void engineUpdate(byte[] input,
int offset,
int length)
engineUpdate in class java.security.MessageDigestSpiinput - [FIPS 140-2 data input] the array of bytes to use for the
update.offset - [FIPS 140-2 data input] the offset to start from in the array
of bytes.len - [FIPS 140-2 data input] the number of bytes to use, starting
at offset.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected void engineUpdate(byte input)
engineUpdate in class java.security.MessageDigestSpiinput - [FIPS 140-2 data input] the byte to use for the update.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected byte[] engineDigest()
engineDigest has been called, the engine
should be reset (see engineReset). Resetting is
the responsibility of the engine implementor.
engineDigest in class java.security.MessageDigestSpiFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected int engineDigest(byte[] buf,
int offset,
int len)
throws java.security.DigestException
engineDigest has been called, the engine
should be reset (see engineReset). Resetting is
the responsibility of the engine implementor.
engineDigest in class java.security.MessageDigestSpibuf - [FIPS 140-2 data output] the output buffer in which to store
the digestoffset - [FIPS 140-2 data input] offset to start from in the output
bufferlen - [FIPS 140-2 data input] number of bytes within buf allotted
for the digest. Both this default implementation and the SUN
provider do not return partial digests. The presence of this
parameter is solely for consistency in our API's. If the value
of this parameter is less than the actual digest length, the
method will throw a DigestException. This parameter is ignored
if its value is greater than or equal to the actual digest
length.java.security.DigestException - [FIPS 140-2 status output] if an error occurs.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected void engineReset()
engineReset in class java.security.MessageDigestSpiFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected int engineGetDigestLength()
engineGetDigestLength in class java.security.MessageDigestSpiFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operations