    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:
   - `sign()`
   - `verify()`
   - the `setBy()` and `getBy()` methods
   - the `getKeyLength()` method (not required but recommended)
   - the class also needs to have a public constructor without parameters that calls `super(url, shortName)` where url is the string identifying the algorithm it implements and shortName is the string that would identify the algorithm according to the Java Security naming conventions. ShortName may also be null.
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

##

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

##

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

##

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

##

suiteValues

     protected Hashtable suiteValues

  A hashtable with the (name, value) pairs of this signature suite.

SIGSUITE_ID

     public static final String SIGSUITE_ID

  The string identifying a signature suite in a label, `Signature`.

##

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.

##

getSuiteValues

     public final Hashtable getSuiteValues()

  Return the SigSuite key-value pair

getURL

     public final String getURL()

  Return the URL identifying this signature suite object.

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.

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)
            )
         )

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.

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.

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.

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.

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.

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.

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.

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.

parse2

     public static SignatureSuite parse2(Vector data) throws DSigException

  Another method for the parser.

  Throws: DSigException
    if the data cannot be parsed correctly.

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.

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.

BigIntToBase64

     public static String BigIntToBase64(BigInteger bi)

  Encode a BigInteger in Base 64 encoding. Included here as signature suite implementations will frequently need it.

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.

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.

toVector

     public Vector toVector()

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