public class CryptHash extends CapiHandle
HCRYPTHASH type, and is used for all
situations where an HCRYPTHASH is required for a native call. If
it was obtained from a CSP with a private signing key available, it can also
be used to sign the hashed data.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the handle to the native hash object, releasing memory and
resource.
|
HashAlgorithms |
getAlgorithm()
Return the hash algorithm id of this hash object.
|
static CryptHash |
getHashInstance(CryptProvider provider,
HashAlgorithms hashAlg)
Creates and returns a CAPI hash with the given algorithm, associated with
the given provider.
|
int |
getHashSize()
Returns the hash size.
|
byte[] |
getHashValue()
Completes the hash computation and returns the hash value.
|
CryptProvider |
getProvider()
Return the handle to the provider of this hash object.
|
byte[] |
getSignedHash()
Signs the current hash value and returns the bytes of the signature.
|
void |
setHashValue(byte[] hashValue)
Sets the actual bytes of the hash, so that an arbitrary byte array can be
signed.
|
void |
update(byte[] input,
int offset,
int length)
Updates the hash with the given input data, starting at the given offset,
and hashing the given length.
|
debugInfo, debugInfo, equals, setExtendedDebuggingclearHandle, finalize, getHandle, hashCodepublic static CryptHash getHashInstance(CryptProvider provider, HashAlgorithms hashAlg) throws CapiException
provider - [FIPS 140-2 control input] The CSP that provides the desired
hash algorithm.hashAlg - [FIPS 140-2 control input] The hash algorithmCapiException - [FIPS 140-2 status output] if the specified provider cannot
provide the requested hash algorithm.public void close()
public int getHashSize()
CryptGetHashParam specifying HP_HASHSIZE as the
parameter.
Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsCryptGetHashParampublic CryptProvider getProvider()
Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationspublic HashAlgorithms getAlgorithm()
Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationspublic void update(byte[] input,
int offset,
int length)
throws CapiException
input - [FIPS 140-2 data input] The data to hashoffset - [FIPS 140-2 data input] The starting offsetlength - [FIPS 140-2 data input] The number of bytes to hashCapiException - [FIPS 140-2 status output] The there is any problem updating
the hashFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationspublic byte[] getHashValue()
throws CapiException
update can be made after this call.
CapiException - [FIPS 140-2 status output] if there is any problem computing
the hash value.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationspublic void setHashValue(byte[] hashValue)
throws CapiException
hashValue - [FIPS 140-2 data input] The hash value to set. The length must
be equal to that reported by getHashSize().CapiException - [FIPS 140-2 status output] if there is a problem setting the
hash value.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsCryptSetHashParampublic byte[] getSignedHash()
throws CapiException
CapiException - [FIPS 140-2 status output] if there is a problem signing the
hash.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operations