All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.www.dsig.SignatureSuite

java.lang.Object
   |
   +----w3c.www.dsig.SignatureSuite

public class SignatureSuite
extends Object
The class w3c.www.dsig.SignatureSuite implements a generic DSig Signature Suite as specified in the DSig Label specification. Implementations of specific Signature Suites need to subclass this class, it therefore also defines the basic API for all signature suites.

Applications will never need to create instances of this class using the constructors. Instances will either be created when using w3c.www.dsig.SigSuiteRegistry.getInstance(urlString) or automatically by the parser (which uses the same mechanism insternally). For a more detailed description of the API for application programmers please consult the Using the W3C's DSig Reference Implementation document.

Programmers who want to write their on signature suite for the DSig implementation will need to do the following:

  1. Create a subclass of w3c.www.dsig.SignatureSuite
  2. Override the following dummy methods of the baseclass:
  3. Register the signature suite using w3c.www.dsig.SigSuiteRegistry.addAlgorithm(MyUrl, MySigSuiteClass.getClass());
For a sample implementation of a signature suite see w3c.www.dsig.SigSuiteDSS.

See Also:
SigSuiteDSS

Variable Index

 o SIGSUITE_ID
The string identifying a signature suite in a label, Signature.
 o suiteValues
A hashtable with the (name, value) pairs of this signature suite.

Constructor Index

 o SignatureSuite(String, String)
Constructor with the identifying URL as parameter, for use by subclasses.

Method Index

 o addValuePair(Object, Object, Object)
Add the pair (key, val) as an S-Expression under entryname, entryname and key should be Strings.
 o Base64ToBigInt(String)
Decode a Base 64 encoded BigInteger.
 o Base64ToByteArray(String)
Decode a Base 64 encoded byte array.
 o BigInteger2ByteArrayWithLengthPrefix(BigInteger)
Convert a BigInteger to a byte array in the format suitable for hashing of integers.
 o BigIntToBase64(BigInteger)
Encode a BigInteger in Base 64 encoding.
 o ByteArrayToBase64(byte[])
Encode an array of bytes in Base 64 encoding.
 o getBy()
Return the contents of the ByX field.
 o getByType()
Return the type of the 'By' information used in this signature suite object.
 o getKeyLength()
Return the length of the key used to create this signature in bits, or -1 if it is unknown.
 o getShortName()
Return the short name of the cryptographic algorithm implemented by this signature suite.
 o getSuiteValues()
Return the SigSuite key-value pair
 o getURL()
Return the URL identifying this signature suite object.
 o parse(Vector)
Parse the input data into a geneirc Sigature Suite object.
 o parse2(Vector)
Another method for the parser.
 o removeBy()
Removes all ByX entries from the signature suite.
 o setBy(String, Object)
Set the By information in the label.
 o sign(DSigLabelInterface, PrivateKey)
Sign the PICSLabel using the given private key and update the label with the signature.
 o toString()
Return a string representation of this signature suite, suitable for inclusion in a Signature Label.
 o toVector()
 o verify(DSigLabelInterface, PublicKey)
Verify if this signature suite object signs the given label using the given public key.

Variables

 o suiteValues
 protected Hashtable suiteValues
A hashtable with the (name, value) pairs of this signature suite.

 o SIGSUITE_ID
 public static final String SIGSUITE_ID
The string identifying a signature suite in a label, Signature.

Constructors

 o SignatureSuite
 protected SignatureSuite(String suiteURL,
                          String shortName)
Constructor with the identifying URL as parameter, for use by subclasses. Applications will never need to create instances of a signature suite via a constructor, see the comments at the top of this class.

Methods

 o getSuiteValues
 public final Hashtable getSuiteValues()
Return the SigSuite key-value pair

 o getURL
 public final String getURL()
Return the URL identifying this signature suite object.

 o getShortName
 public final String getShortName()
Return the short name of the cryptographic algorithm implemented by this signature suite. This should be the name used to identify the signature algorithm in the Java Security API, e.g. MD5/RSA. If no such equivalent exists this method returns null.

Note that this name is purely informational, in particular there is absolutely no guarantee that there is only one signature suite for each short name or that this signature suite performs exactly like the algorithm in the Java Security API, nor does it imply that this algorithm is installed in the Java Security API at all. However, it still might be usefull to determine which types of keys the signature suite accepts.

 o addValuePair
 protected void addValuePair(Object entryname,
                             Object key,
                             Object val)
Add the pair (key, val) as an S-Expression under entryname, entryname and key should be Strings. The result of this call will be:
   (Signature
      ...
      (entryname
         (key val)
      )
   )
 

 o verify
 public Trivalue verify(DSigLabelInterface label,
                        PublicKey pubkey)
Verify if this signature suite object signs the given label using the given public key. If the pubKey is null, the public key specified in the given label will be used if possible (usually with byKey or byName).

The SignatureSuite base class only provides a dummy function the subclasses need to override.

 o sign
 public DSigLabelInterface sign(DSigLabelInterface label,
                                PrivateKey privkey)
Sign the PICSLabel using the given private key and update the label with the signature. If successful, return the label, if signing could not be performed for some reason, return null.

The SignatureSuite base class only provides a dummy function the subclasses need to override.

 o getKeyLength
 public int getKeyLength()
Return the length of the key used to create this signature in bits, or -1 if it is unknown. Note that this size is algorithm dependent, e.g. 512 bits for RSA are drastically different from 512 for some elliptic curve algorithm. Also note, that for some signature suites it might not be possible to deduce the keysize from a signature or it might be available only after signature verification was performed (and the keylength could be deduced from the public key given there).

The SignatureSuite base class only provides a dummy function the subclasses need to override.

 o setBy
 public SignatureSuite setBy(String type,
                             Object signer)
Set the By information in the label. Set the ByX type to type with the value signer. If a signature suite does not support the given type, the by information remains unchanged and this method returns null.

How signer is interpreted and what type it needs to have is signature suite dependent. However, when using ByKey or ByHash signer always has to be an instance of PublicKey, for ByName it has to be a string.

This method has to be called after after signing to have any effect.

The SignatureSuite base class only provides a dummy function the subclasses need to override.

 o getByType
 public String getByType()
Return the type of the 'By' information used in this signature suite object. It can be 'ByName', 'ByKey', 'ByHash', or a signature suite dependent string. If the 'By' information is not available, this methods returns null.

The SignatureSuite base class only provides a dummy function the subclasses need to override.

 o getBy
 public Object getBy()
Return the contents of the ByX field. The type of the returned object will be the same as the type of the object when using setBy(), however, for ByHash this method of course cannot return the key itself, it will a byte array of the hash of the key as it is contained in the label.

In case of an error, this method returns null.

The SignatureSuite base class only provides a dummy function the subclasses need to override.

 o removeBy
 protected void removeBy()
Removes all ByX entries from the signature suite. This is automatically called before a new ByX option is set, so there is no need for a user program to use this method.

 o parse
 public void parse(Vector data) throws DSigException
Parse the input data into a geneirc Sigature Suite object. It contains two types of information: the SigSuite URL and a Hashtable of the key-value pair.

Throws: DSigException
if the data cannot be parsed correctly.
 o parse2
 public static SignatureSuite parse2(Vector data) throws DSigException
Another method for the parser.

Throws: DSigException
if the data cannot be parsed correctly.
 o ByteArrayToBase64
 public static String ByteArrayToBase64(byte ba[])
Encode an array of bytes in Base 64 encoding. Included here as signature suite implementations will frequently need it.

 o Base64ToByteArray
 public static byte[] Base64ToByteArray(String b64)
Decode a Base 64 encoded byte array. Returns null if the input was not properly encoded. Included here as signature suite implementations will frequently need it.

 o BigIntToBase64
 public static String BigIntToBase64(BigInteger bi)
Encode a BigInteger in Base 64 encoding. Included here as signature suite implementations will frequently need it.

 o Base64ToBigInt
 public static BigInteger Base64ToBigInt(String b64)
Decode a Base 64 encoded BigInteger. Return the BigInteger object or null if the input was not properly encoded. Included here as signature suite implementations will frequently need it.

 o BigInteger2ByteArrayWithLengthPrefix
 public static byte[] BigInteger2ByteArrayWithLengthPrefix(BigInteger bi)
Convert a BigInteger to a byte array in the format suitable for hashing of integers. That is, prefixed with one or more length bytes as defined in the sample signature specifications for DSS and RSA from the W3C.

The format produced is compatible with ASN.1 BER encoding of integers, it only lacks the leading object identifier.

 o toVector
 public Vector toVector()
 o toString
 public final String toString()
Return a string representation of this signature suite, suitable for inclusion in a Signature Label.

Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index