com.ibm.security.pkcs7
Class DigestInfo

java.lang.Object
  |
  +--com.ibm.security.pkcsutil.PKCSDerObject
        |
        +--com.ibm.security.pkcs7.DigestInfo

public final class DigestInfo
extends PKCSDerObject
implements Cloneable

Implements the ASN.1 DigestInfo type.

DigestInfo ::= SEQUENCE { digestAlgorithm DigestAlgorithmIdentifier, digest Digest } Digest ::= OCTET STRING

DigestInfo objects are immutable; they cannot be changed once created.


Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
 
Constructor Summary
DigestInfo(byte[] der)
          Create a DigestInfo object with a DER-encoded byte array.
DigestInfo(byte[] der, String provider)
          Create a DigestInfo object with a DER-encoded byte array.
DigestInfo(String algname, AlgorithmParameters params, byte[] digest)
          Create an DigestInfo object with the specified values.
DigestInfo(String algname, AlgorithmParameters params, byte[] digest, String provider)
          Create an DigestInfo object with the specified values.
DigestInfo(String filename, boolean base64)
          Create a DigestInfo with the filename of the DER-encoded or BASE64-encoded object.
DigestInfo(String filename, boolean base64, String provider)
          Create a DigestInfo with the filename of the DER-encoded or BASE64-encoded object.
 
Method Summary
 Object clone()
          Creates a clone of this DigestInfo.
protected  void decode(com.ibm.security.pkcs7.DerValue encoding)
          Initializes an DigestInfo object from a DerValue.
 void encode(OutputStream os)
          Encodes this object to an OutputStream.
 boolean equals(Object other)
          Determines if this DigestInfo object is equivalent to the input object.
 byte[] getDigest()
          Returns a copy of the byte array of the digest for this DigestInfo object.
 AlgorithmId getDigestAlgorithm()
          Returns a copy of the digest AlgorithmId for this DigestInfo object.
 String toString()
          Returns a string representation of this DigestInfo object.
 
Methods inherited from class com.ibm.security.pkcsutil.PKCSDerObject
decode, decode, encode, getObjectIdentifier, hashCode, read, readBASE64, write, write, writeBASE64
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DigestInfo

public DigestInfo(byte[] der)
           throws IOException
Create a DigestInfo object with a DER-encoded byte array.
Parameters:
der - a DER-encoded byte array encoding a DigestInfo object.
Throws:
IOException - on decoding errors.

DigestInfo

public DigestInfo(byte[] der,
                  String provider)
           throws IOException
Create a DigestInfo object with a DER-encoded byte array.
Parameters:
der - a DER-encoded byte array encoding a DigestInfo object.
provider - the name of the java security provider to use.
Throws:
IOException - on decoding errors.

DigestInfo

public DigestInfo(String algname,
                  AlgorithmParameters params,
                  byte[] digest)
           throws IOException,
                  NoSuchAlgorithmException
Create an DigestInfo object with the specified values.
Parameters:
algname - the message digest algorithm that created the input digest.
params - the parameters used in the digest algorithm.
digest - a message digest.
Throws:
IllegalArgumentException - if an input argument is null.
NoSuchAlgorithmException - if the algorithm name is invalid.
IOException - if the algorithm identifier cannot be constructed from the name and parameters.

DigestInfo

public DigestInfo(String algname,
                  AlgorithmParameters params,
                  byte[] digest,
                  String provider)
           throws IOException,
                  NoSuchAlgorithmException
Create an DigestInfo object with the specified values.
Parameters:
algname - the message digest algorithm that created the input digest.
params - the parameters used in the digest algorithm.
digest - a message digest.
provider - the name of the java security provider to use
Throws:
IllegalArgumentException - if an input argument is null.
NoSuchAlgorithmException - if the algorithm name is invalid.
IOException - if the algorithm identifier cannot be constructed from the name and parameters.

DigestInfo

public DigestInfo(String filename,
                  boolean base64)
           throws IOException
Create a DigestInfo with the filename of the DER-encoded or BASE64-encoded object.
Parameters:
filename - name of the DER-encoded or base64-encoded object
base64 - true if BASE64-encoded, false if DER-encoded
Throws:
IOException - on decoding errors.

DigestInfo

public DigestInfo(String filename,
                  boolean base64,
                  String provider)
           throws IOException
Create a DigestInfo with the filename of the DER-encoded or BASE64-encoded object.
Parameters:
filename - name of the DER-encoded or base64-encoded object
base64 - true if BASE64-encoded, false if DER-encoded
provider - the name of the java security provider to use
Throws:
IOException - on decoding errors.
Method Detail

clone

public Object clone()
Creates a clone of this DigestInfo.
Overrides:
clone in class Object
Returns:
clone of this DigestInfo object.

encode

public void encode(OutputStream os)
            throws IOException
Encodes this object to an OutputStream.
Overrides:
encode in class PKCSDerObject
Parameters:
os - the OutputStream to write the encoded data to.
Throws:
IOException - on encoding errors.

decode

protected void decode(com.ibm.security.pkcs7.DerValue encoding)
               throws IOException
Initializes an DigestInfo object from a DerValue. The DER encoding must be in the format specified by the DigestInfo ASN.1 notation.
Parameters:
encoding - a DER-encoded DigestInfo object.
Throws:
IOException - on parsing error.

equals

public boolean equals(Object other)
Determines if this DigestInfo object is equivalent to the input object.
Overrides:
equals in class PKCSDerObject
Parameters:
other - the object to compare this one to.
Returns:
true, if the two objects are equivalent, false otherwise.

getDigestAlgorithm

public AlgorithmId getDigestAlgorithm()
                               throws IOException
Returns a copy of the digest AlgorithmId for this DigestInfo object.
Returns:
the digest AlgorithmId

getDigest

public byte[] getDigest()
Returns a copy of the byte array of the digest for this DigestInfo object.
Returns:
a copy of the byte array of the digest

toString

public String toString()
Returns a string representation of this DigestInfo object.
Overrides:
toString in class PKCSDerObject
Returns:
a string representation of this object.