com.ibm.security.pkcs12
Class MacData

java.lang.Object
  |
  +--com.ibm.security.pkcsutil.PKCSDerObject
        |
        +--com.ibm.security.pkcs12.MacData

public final class MacData
extends PKCSDerObject
implements Cloneable

Implements the PKCS #12 MacData type.

MacData ::= SEQUENCE { mac DigestInfo, macSalt OCTET STRING, iterations INTEGER DEFAULT 1 }

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

See Also:
DigestInfo

Fields inherited from class com.ibm.security.pkcsutil.PKCSDerObject
provider
 
Constructor Summary
MacData(byte[] der)
          Create a MacData object with a DER byte array.
MacData(byte[] der, String provider)
          Create a MacData object with a DER byte array.
MacData(DigestInfo mac, byte[] salt, int iterations)
          Create a MacData from the input values.
MacData(DigestInfo mac, byte[] salt, int iterations, String provider)
          Create a MacData from the input values.
MacData(String filename, boolean base64)
          Create a MacData with the filename of the DER-encoded or BASE64-encoded object.
MacData(String filename, boolean base64, String provider)
          Create a MacData with the filename of the DER-encoded or BASE64-encoded object.
 
Method Summary
 Object clone()
          Creates a clone of this MacData object.
protected  void decode(com.ibm.security.pkcs12.DerValue encoding)
          Initialize a MacData object from an input stream.
 void encode(OutputStream out)
          Encodes this object to a DER OutputStream.
 boolean equals(Object other)
          Determines if this MacData object is equivalent to the input object.
 int getIterations()
          Returns the iteration count value.
 DigestInfo getMac()
          Returns a copy of the MAC digest.
 byte[] getSalt()
          Returns a copy of the salt.
 String toString()
          Returns a string representation of this MacData 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

MacData

public MacData(byte[] der)
        throws IOException
Create a MacData object with a DER byte array.

MacData

public MacData(byte[] der,
               String provider)
        throws IOException
Create a MacData object with a DER byte array.

MacData

public MacData(DigestInfo mac,
               byte[] salt,
               int iterations)
Create a MacData from the input values.

MacData

public MacData(DigestInfo mac,
               byte[] salt,
               int iterations,
               String provider)
Create a MacData from the input values.

MacData

public MacData(String filename,
               boolean base64)
        throws IOException
Create a MacData 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.

MacData

public MacData(String filename,
               boolean base64,
               String provider)
        throws IOException
Create a MacData 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 - a provider to be used
Throws:
IOException - on decoding errors.
Method Detail

encode

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

equals

public boolean equals(Object other)
Determines if this MacData 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.

clone

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

toString

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

getMac

public DigestInfo getMac()
Returns a copy of the MAC digest.

getSalt

public byte[] getSalt()
Returns a copy of the salt.

getIterations

public int getIterations()
Returns the iteration count value.

decode

protected void decode(com.ibm.security.pkcs12.DerValue encoding)
               throws IOException
Initialize a MacData object from an input stream. The data on that input stream must be a DER-encoded MacData object.
Parameters:
encoding - an input stream with a DER-encoded MacData object.
Throws:
IOException - on parsing errors.