|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.rsa.jsafe.JSAFE_Object
com.rsa.jsafe.JSAFE_MessageDigest
This class instantiates the classes that create and verify signatures, and it defines the functionality. This class defines the factory methods and API for all message digest objects, which are also known as cryptographic hash functions.
See Overview of Crypto-J for background and reference material on using and understanding Crypto-J.
Note: Not all Crypto-J transformations have OIDs assigned to them. See Crypto-J Transformations and Their Associated Classes for a list of transformations that have assigned OIDs.
Copyright © RSA Security Inc., 1997-2005. All rights reserved.
| Constructor Summary | |
JSAFE_MessageDigest()
|
|
| Method Summary | |
static String |
berDecodeAlgorithm(byte[] encoding,
int encOffset)
Determines an algorithm, when given a BER encoding in
|
static byte[] |
berDecodeDigest(byte[] encoding,
int encOffset)
Determines the digest, when given a BER encoding in
|
void |
clearSensitiveData()
Clears sensitive data from an object. |
byte[] |
derEncode(byte[] digest,
int offset)
Creates the DER encoding when given a |
abstract int |
derEncode(byte[] digest,
int digOffset,
byte[] encoding,
int encOffset)
Creates the DER encoding when given a |
byte[] |
digestFinal()
Finalizes the process and returns the resulting digest
in a new |
abstract int |
digestFinal(byte[] output,
int offset)
Finalizes the process and returns the resulting digest in a new
|
abstract void |
digestInit()
Initializes this object for a digest operation. |
abstract void |
digestUpdate(byte[] partIn,
int offset,
int partInLen)
Digests the first |
abstract String |
getAlgorithm()
Returns the standard digest algorithm name. |
abstract byte[] |
getDERAlgorithmID()
Returns a new |
getDevice()
Returns the standard name of the device of record. |
|
String[] |
getDeviceList()
Returns a |
abstract int |
getDigestSize()
Returns the size, in bytes, of the resulting digest. |
abstract int |
getEncodedDigestSize()
Returns the size, in bytes, of the DER encoding of the digest. |
static JSAFE_MessageDigest |
getInstance(byte[] berAlgID,
int offset,
String device)
Builds an object that performs an algorithm using
the possible parameters defined in |
static JSAFE_MessageDigest |
getInstance(String transformation,
String device)
Builds an object that performs the |
static int |
getNextBEROffset(byte[] berAlgID,
int offset)
Gets the next offset after the algorithm ID. |
| Methods inherited from class com.rsa.jsafe.JSAFE_Object |
clone, overwrite, overwrite |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public JSAFE_MessageDigest()
| Method Detail |
public static JSAFE_MessageDigest getInstance(byte[] berAlgID,
int offset,
String device)
throws JSAFE_UnimplementedException,
JSAFE_InvalidParameterException
berAlgID
beginning at offset. This is the BER encoding of the
algorithm identifier. The specified device is used.
berAlgID - A byte array containing the BER encoding of
an algorithm ID.offset - The offset into berAlgID where
the encoding begins.device - A list of devices used to build the object.
JSAFE_MessageDigest object that performs the
transformation as described by the algorithm ID.
JSAFE_UnimplementedException - If the device or devices cannot
perform the designated algorithm, or the toolkit cannot decode the
BER encoding.
JSAFE_InvalidParameterException - If the BER encoding contains
parameters that do not work.
public static int getNextBEROffset(byte[] berAlgID,
int offset)
throws JSAFE_UnimplementedException
berAlgID, the BER encoding of the algorithm ID,
beginning at offset, returns the index to the next
byte in the array.
berAlgID - A byte array containing the BER encoding
of an algorithm ID.offset - The offset into berAlgID where
the encoding begins.
berAlgID of the byte following the
algorithm ID.
JSAFE_UnimplementedException - If the toolkit cannot decode the
BER encoding.
public static JSAFE_MessageDigest getInstance(String transformation,
String device)
throws JSAFE_UnimplementedException,
JSAFE_InvalidParameterException
transformation on the
given device.
transformation - The representation of the desired operation.
The possible values for this string are:
MD2, MD5, SHA1, SHA224,
SHA256, SHA384, SHA512, and
RIPEMD160.device - A list of devices used to build the object
(for example, "Java", "Native/Java").
JSAFE_MessageDigest object that performs the
transformation.
JSAFE_UnimplementedException - If the device or devices cannot
perform the designated algorithm.
JSAFE_InvalidParameterException - If the
transformation contains parameters that do not work.public abstract byte[] getDERAlgorithmID()
byte array containing the DER encoding
of the algorithm ID of the algorithm in this object.
byte array that contains the algorithm ID.public String getDevice()
public String[] getDeviceList()
String array that describes
all the devices used to execute the transformation. Because a
transformation often consists of component algorithms, the
implementation can consist of several component objects.
A device can perform one or more of the algorithms, but it may let
Java or another device perform one or more. For example, because
padding is not time-consuming, a device might let the Crypto-J
implementation perform padding. Returns the name of the devices used
by each component.
String array that describes the device used for a
specific component.public abstract String getAlgorithm()
String describing the digest algorithm.public abstract int getDigestSize()
int that is the size of the output digest.public abstract int getEncodedDigestSize()
int that is the size of the encoded digest output.public abstract void digestInit()
public abstract void digestUpdate(byte[] partIn,
int offset,
int partInLen)
throws JSAFE_InvalidUseException
partInLen bytes of the array
partIn, beginning at offset.
partIn - The data to digest.offset - The offset into partIn where the data begins.partInLen - The length of the data to digest.
JSAFE_InvalidUseException - If the object is not
initialized for a digest operation.
public byte[] digestFinal()
throws JSAFE_InvalidUseException
byte array.
byte array containing the digest.
JSAFE_InvalidUseException - If the object is not initialized.
public abstract int digestFinal(byte[] output,
int offset)
throws JSAFE_InvalidUseException
byte array.
output - The buffer where the output is placed.offset - The offset into output where the writing begins.
output buffer.
JSAFE_InvalidUseException - If the object is not initialized.
public byte[] derEncode(byte[] digest,
int offset)
digest
beginning at offset. Generates the DER encoding of
the DigestInfo. The derEncode() method
assumes the digest is for the algorithm given at instantiation.
This method returns the encoding in a new byte
array.
Use the following ASN.1 definition:
DigestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier,
digest OCTET STRING }
This method considers the digest to be of the algorithm specified
at instantiation. It uses as many of the bytes in the
input buffer as the algorithm specifies.
digest - The digest to encode.offset - The offset into digest where the value begins.
byte array containing the encoded digest.
public abstract int derEncode(byte[] digest,
int digOffset,
byte[] encoding,
int encOffset)
digest
beginning at digOffset, and places the result into
encoding beginning at encOffset.
Generates the DER encoding of the DigestInfo.
The derEncode() method assumes the digest is for the
algorithm given at instantiation.
Use the following ASN.1 definition:
DigestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier,
digest OCTET STRING }
Considers the digest to be the same as the algorithm specified
at instantiation. It uses as many of the bytes in the
input buffer as the algorithm specifies.
digest - The digest to encode.digOffset - The offset into digest where the value begins.encoding - The buffer where the output is placed.encOffset - The offset into encoding where the writing
begins.
public static String berDecodeAlgorithm(byte[] encoding,
int encOffset)
throws JSAFE_InputException
encoding, beginning at encOffset.
It returns the standard name of the algorithm.
Given the encoding, determines which digest algorithm is
represented.
Use the following ASN.1 definition:
DigestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier,
digest OCTET STRING }
encoding - The BER encoding to decode.encOffset - The offset into encoding where the data
begins.
JSAFE_InputException - If the encoding is not a known
digest algorithm.
public static byte[] berDecodeDigest(byte[] encoding,
int encOffset)
throws JSAFE_InputException
encoding, beginning at encOffset.
It returns a new byte array. Note this is a static method.
Use the following ASN.1 definition:
DigestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier,
digest OCTET STRING }
encoding - The BER encoding to decode.encOffset - The offset into encoding where the data
begins.
byte array containing the decoded digest.
JSAFE_InputException - If the encoding is not a known
digest algorithm.public void clearSensitiveData()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||