spki
Class Signature

java.lang.Object
  |
  +--spki.BaseObj
        |
        +--spki.Signature

public class Signature
extends BaseObj
implements SeqEntry

SPKI Signature class.

Formal definition:

 <hash-of-obj>:: <hash> ;
 <signer>:: <principal> ;
 <sig-params>:: <byte-string> | <s-expr>+ ;
 <sig-val>:: "(" <pub-sig-alg-id> <sig-params> ")" ;
 <signature>:: "(" "signature" <hash-of-obj> <signer> <sig-val> ")" ;
 

Currently, only those signature-schemes provided by Cryptix and Sun JDK-1.2 are suppored. Actual support is dependent on the implementation of PrivateKey and PublicKey classes: for now it's rsa-pkcs1-sha1.

TODO: Support <s-expr> as <sig-params>.

Version:
$Id: Signature.java,v 1.20 2002/07/27 10:34:55 tep Exp $
Author:
Tep Narula <tep@win.trlabs.ca>, adapted from SPKI.SPKIHash by Per Harald Myrvang <perm@pasta.cs.uit.no>
See Also:
Hash, Principal, PublicKey, PrivateKey

Field Summary
private static String __ME
          This class's full name.
private  Hash hash
          Hash of the object signed.
private  Principal principal
          Verifying principal.
static String SEXP_NAME
          This class S-Expression type name, used by toSExpression() and other methods.
private  String sig_alg_id
          Signature algorithm id used.
private  byte[] sig_params
          Signature value.
 
Fields inherited from class spki.BaseObj
__ME, cache_sexp, cached_sexp, DEFAULT_HASH_ALG, locked, SEXP_NAME
 
Constructor Summary
protected Signature()
          Don't use me!
  Signature(Hash hash, Principal principal, String alg_id, byte[] sig_params)
          Create an immutable Signature object from pre-fab signature parameters.
  Signature(SExpression sexp)
          Create an immutable Signature object from an S-Expression.
 
Method Summary
 boolean equals(Signature that)
          Compare this object against the given object.
 String getAlgId()
          Get the signature algorithm ID.
 Hash getObjHash()
          Get the hash of the signed object.
 Principal getPrincipal()
          Get the verifying principal.
 byte[] getSigParams()
          Get the signature value.
 SExpression toSExpression()
          Build an SExpression representing this object.
 
Methods inherited from class spki.BaseObj
disableSExpressionCaching, enableSExpressionCaching, extractHashAlgId, getCachedSExpression, isLocked, isSListOfType, lock, providerToSPKI, setCachedSExpression, spkiToProvider, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

__ME

private static final String __ME
This class's full name.

SEXP_NAME

public static final String SEXP_NAME
This class S-Expression type name, used by toSExpression() and other methods.
See Also:
toSExpression()

hash

private Hash hash
Hash of the object signed.

principal

private Principal principal
Verifying principal. May hold a public key or just the hash of the public key.

sig_alg_id

private String sig_alg_id
Signature algorithm id used.

sig_params

private byte[] sig_params
Signature value.
Constructor Detail

Signature

protected Signature()
Don't use me!
See Also:
Signature(SExpression), Signature(spki.Hash,spki.interfaces.Principal,String,byte[])

Signature

public Signature(SExpression sexp)
          throws SPKIException,
                 ParseException
Create an immutable Signature object from an S-Expression.
See Also:
BaseObj.BaseObj(SExpression)

Signature

public Signature(Hash hash,
                 Principal principal,
                 String alg_id,
                 byte[] sig_params)
          throws SPKIException
Create an immutable Signature object from pre-fab signature parameters.
Parameters:
hash - the Hash of the object being signed.
principal - the verifying principal, may hold a full public key or just a has of the public key.
alg_id - the signature algorithm ID, ignored if the given principal already holds a full public key.
sig_params - the signature value.
Throws:
SPKIException - if something went wrong.
Method Detail

toSExpression

public SExpression toSExpression()
                          throws SPKIException
Description copied from interface: SPKIObject
Build an SExpression representing this object.
Overrides:
toSExpression in class BaseObj
Tags copied from interface: SPKIObject
Returns:
SExpression object representing this object, or null.
Throws:
SPKIException - if something went wrong during conversion.

getObjHash

public Hash getObjHash()
Get the hash of the signed object.
Returns:
Hash of the signed object.

getPrincipal

public Principal getPrincipal()
Get the verifying principal.
Returns:
Principal verifying the signature.

getAlgId

public String getAlgId()
Get the signature algorithm ID.
Returns:
String containing the signature algorithm ID.

getSigParams

public byte[] getSigParams()
Get the signature value.
Returns:
A copy of the byte array containing the signature value.

equals

public boolean equals(Signature that)
Compare this object against the given object.
Parameters:
that - the Signature object to compare this object against.
Returns:
true if both Signature contains the same object-hash, principal, and signature value, false otherwise.
See Also:
Hash.equals(Hash), Principal.equals(spki.interfaces.Principal)