iaik.smime.attributes
Class SMIMECapability

java.lang.Object
  extended by iaik.smime.attributes.SMIMECapability
All Implemented Interfaces:
ASN1Type

public class SMIMECapability
extends java.lang.Object
implements ASN1Type

The S/MIMEv3 type SMIMECapability.

S/MIMEv3 (RFC 5751) specifies the SMimeCapability to be used by an S/MIME for announcing that it is able to handle some particular algorithm capabilities. For that purpose the S/MIME client creates a SMIMECapability object where it references the algorithm it is able to handle by its algorithm object identifier. If necessary the SMIMECapability object additionally may include parameters providing information required to differentiate between two instances of the same algorithm (for instance key length for RC2). Any SMIMECapability a client want to announce is collected and included into a SMIMECapabilities attribute in preference order.

 SMIMECapability ::= SEQUENCE {
   capabilityID OBJECT IDENTIFIER,
   parameters ANY DEFINED BY capabilityID OPTIONAL } 
 
 SMIMECapabilities ::= SEQUENCE OF SMIMECapability
 
When creating a SMIMECapability object the OID of the algorithm has to be specified for announcing to be capable to handle the corresponding algorithm. Any parameters (e.g. key length supported for some particular algorithm) to be additionally announced can be included by calling method setParameters. Since the parameters may have any ASN.1 representation method setParameters simple expects them as an ASN1Object. So, for instance, parameters announcing that the client is capable to handle RC2 for a key length of 128 bits, would be an ASN.1 INTEGER:
  
 SMIMECapability rc2_128Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_128Capability.setParameters(new INTEGER(128));
 
If the client also is capable to handle RC2 for key lengths of 40 and 64 bits, create a SMIMECapability object for these two key lengths, too, and -- together with any further capabilities to be announced -- subsequently set it for the SMIMECapabilities attribute, e.g.:
 // RC2 128
 SMIMECapability rc2_128Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_128Capability.setParameters(new INTEGER(128));
 // RC2 64
 SMIMECapability rc2_64Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_64Capability.setParameters(new INTEGER(64));
 // RC2 40
 SMIMECapability rc2_40Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_40Capability.setParameters(new INTEGER(40));
 // any further capabilities
 ...
 // add the capabilities in preference order to an SMIMECapabilities attribute:
 SMIMECapability[] capabilities = { ..., rc2_128Capability, rc2_64Capability, rc2_40Capability, ...};
 SMIMECapabilities smimeCapabilities = new SMIMECapabilities(capabilities);
 

See Also:
SMIMECapabilities

Constructor Summary
SMIMECapability()
          Empty default constructor.
SMIMECapability(ASN1Object obj)
          Creates an SMIMECapability from an ASN1Object.
SMIMECapability(ObjectID capabilityID)
          Creates an SMIMECapability for the given capability (algorithm) id.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes an SMIMECapability from an ASN1Object.
 boolean equals(java.lang.Object obj)
          Compares this SMIMECapability to the specified object.
 ObjectID getCapabilityID()
          Gets the capability ID of this SMIMECapability object.
 ASN1Object getParameters()
          Gets the algorithm specific parameters (if included) announced by this SMIMECapability.
 int hashCode()
          Returns a hashcode for this SMIMECapability.
 void setParameters(ASN1Object parameters)
          Sets the algorithm specific parameters (if required) to be announced by this SMIMECapability.
 ASN1Object toASN1Object()
          Returns this SMIMECapability as ASN1Object.
 java.lang.String toString()
          Returns a string representation of this SMIMECapability.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SMIMECapability

public SMIMECapability()
Empty default constructor. Required for dynamic object creation only. Shall NOT be used by an application


SMIMECapability

public SMIMECapability(ObjectID capabilityID)
Creates an SMIMECapability for the given capability (algorithm) id.

Use method setParameters for setting any parameters to be included.

Parameters:
capabilityID - the capabilty oid identifying the algorithm for which to create a SMimeCapabililty

SMIMECapability

public SMIMECapability(ASN1Object obj)
                throws CodingException
Creates an SMIMECapability from an ASN1Object.

Parameters:
obj - the SMIMECapability as ASN1Object
Throws:
CodingException - if an error occurs while parsing the ASN1Object
Method Detail

getCapabilityID

public ObjectID getCapabilityID()
Gets the capability ID of this SMIMECapability object.

Returns:
the capabilityID

getParameters

public ASN1Object getParameters()
Gets the algorithm specific parameters (if included) announced by this SMIMECapability.

Since the parameters may have any ASN.1 representation this method simple returns the parameters as ASN1Object. So, for instance, parameters announcing that the client is capable to handle RC2 for a key length of 128 bits, would be encoded as an ASN.1 INTEGER:

  
 INTEGER rc2KeyLength = (INTEGER)capability.getParameters();
 int keyLength = ((BigInteger)rc2KeyLength.getValue()).intValue();
 

Returns:
the parameters announced with this SMIMECapability, or null if no parameters are included

setParameters

public void setParameters(ASN1Object parameters)
Sets the algorithm specific parameters (if required) to be announced by this SMIMECapability.

Since the parameters may have any ASN.1 representation this method simple expects them as an ASN1Object. So, for instance, parameters announcing that the client is capable to handle RC2 for a key length of 128 bits, would be an ASN.1 INTEGER:

  
 SMIMECapability rc2_128Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_128Capability.setParameters(new INTEGER(128));
 
If the client also is capable to handle RC2 for key lengths of 40 and 64 bits, create a SMIMECapability object for these two key lengths, too, and -- together with any further capabilities to be announced -- subsequently set it for the SMIMECapabilities attribute, e.g.:
 // RC2 128
 SMIMECapability rc2_128Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_128Capability.setParameters(new INTEGER(128));
 // RC2 64
 SMIMECapability rc2_64Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_64Capability.setParameters(new INTEGER(64));
 // RC2 40
 SMIMECapability rc2_40Capability = new SMIMECapability(AlgorithmID.rc2_CBC.getAlgorithm());
 rc2_40Capability.setParameters(new INTEGER(40));
 // any further capabilities
 ...
 // add the capabilities in preference order to an SMIMECapabilities attribute:
 SMIMECapability[] capabilities = { ..., rc2_128Capability, rc2_64Capability, rc2_40Capability, ...};
 SMIMECapabilities smimeCapabilities = new SMIMECapabilities(capabilities);
 

Parameters:
parameters - the parameters to be announced with this SMIMECapability

toASN1Object

public ASN1Object toASN1Object()
                        throws CodingException
Returns this SMIMECapability as ASN1Object.

Specified by:
toASN1Object in interface ASN1Type
Returns:
this SMIMECapability as ASN1Object
Throws:
CodingException - if the ASN1Object cannot be created because no capability ID is set

decode

public void decode(ASN1Object obj)
            throws CodingException
Decodes an SMIMECapability from an ASN1Object.

Specified by:
decode in interface ASN1Type
Parameters:
obj - the SMIMECapability as ASN1Object
Throws:
CodingException - if an error occurs while parsing the ASN1Object

equals

public boolean equals(java.lang.Object obj)
Compares this SMIMECapability to the specified object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare this SMIMECapability against.
Returns:
true, if the given object is equal to this SMIMECapability, false otherwise

hashCode

public int hashCode()
Returns a hashcode for this SMIMECapability.

The hashcode is calculated from the capabilityID only.

Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode for this SMIMECapability

toString

public java.lang.String toString()
Returns a string representation of this SMIMECapability.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this SMIMECapability

This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note).

IAIK-CMS 6.0, (c) 2002 IAIK, (c) 2003, 2023 SIC