jsdsi
Class Signature

java.lang.Object
  extended byjsdsi.Obj
      extended byjsdsi.Signature
All Implemented Interfaces:
Element, java.io.Serializable

public class Signature
extends Obj
implements Element

A cryptographic signature.

Version:
$Revision: 1.8.2.1 $ $Date: 2005/11/08 03:12:52 $
Author:
Sameer Ajmani, Sean Radford
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class jsdsi.Element
Element.Default
 
Field Summary
 
Fields inherited from class jsdsi.Obj
_obj
 
Constructor Summary
Signature(Principal i, Hash h, SignatureAlgoEnum a, byte[] d)
          Creates a new Signature.
Signature(Principal i, Hash h, java.lang.String a, byte[] d)
          Deprecated. use Signature(Principal, Hash, jsdsi.util.SignatureAlgoEnum, byte[]
 
Method Summary
static Signature create(java.security.KeyPair kp, byte[] bytes, DigestAlgoEnum a)
          Signs the given byte array using the 'default' java.security.Provider.
static Signature create(java.security.KeyPair kp, byte[] bytes, DigestAlgoEnum a, java.lang.String provider)
          Signs the given byte array using the specified java.security.Provider.
static Signature create(java.security.KeyPair kp, byte[] b, java.lang.String a)
          Deprecated.  
static Signature create(java.security.KeyPair kp, byte[] b, java.lang.String a, java.lang.String provider)
          Deprecated.  
static Signature create(java.security.KeyPair kp, java.io.InputStream is, DigestAlgoEnum a)
          Signs the given byte array using the 'default' java.security.Provider.
static Signature create(java.security.KeyPair kp, java.io.InputStream is, DigestAlgoEnum digestEnum, java.lang.String provider)
          Signs the given byte array using the specified java.security.Provider.
static Signature create(java.security.KeyPair kp, java.io.InputStream toSign, java.lang.String a)
          Deprecated.  
static Signature create(java.security.KeyPair kp, java.io.InputStream toSign, java.lang.String a, java.lang.String provider)
          Deprecated.  
static Signature create(java.security.KeyPair kp, Obj o, DigestAlgoEnum a)
          Signs the given JSDSI Obj using the 'default' java.security.Provider.
static Signature create(java.security.KeyPair kp, Obj o, DigestAlgoEnum a, java.lang.String provider)
          Signs the given JSDSI Obj using the specified java.security.Provider.
static Signature create(java.security.KeyPair kp, Obj o, java.lang.String a)
          Deprecated.  
static Signature create(java.security.KeyPair kp, Obj o, java.lang.String a, java.lang.String provider)
          Deprecated.  
 boolean equals(java.lang.Object o)
           
 java.lang.String getAlgorithm()
           
 byte[] getData()
           
 SignatureAlgoEnum getSignatureEnum()
           
 Hash getSignee()
           
 Principal getSigner()
           
 int hashCode()
           
static void main(java.lang.String[] args)
           
 SexpList toSexp()
          Creates an SexpList -representation from this SDSI-object.
 boolean verify(java.security.PublicKey key, byte[] b)
           
 boolean verify(java.security.PublicKey key, byte[] b, java.lang.String provider)
           
 boolean verify(java.security.PublicKey key, java.io.InputStream toCheck)
           
 boolean verify(java.security.PublicKey key, java.io.InputStream toCheck, java.lang.String provider)
          Using the provider, verifies that the corresponding PrivateKey for key generated this Signature for the data given by toCheck
 boolean verify(java.security.PublicKey key, Obj o)
          Using the default security Provider, verifies that the corresponding PrivateKey for key generated this Signature for o
 boolean verify(java.security.PublicKey key, Obj o, java.lang.String provider)
           
 
Methods inherited from class jsdsi.Obj
parseObj, parseObj, readResolve, toByteArray, toString, toString, toTransport
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Signature

public Signature(Principal i,
                 Hash h,
                 SignatureAlgoEnum a,
                 byte[] d)
Creates a new Signature.

Parameters:
i - the signer
h - hash of the signed data
a - signature algorithm
d - signature value (not the data to sign)

Signature

public Signature(Principal i,
                 Hash h,
                 java.lang.String a,
                 byte[] d)
Deprecated. use Signature(Principal, Hash, jsdsi.util.SignatureAlgoEnum, byte[]

Creates a new Signature.

Parameters:
i - the signer
h - hash of the signed data
a - signature algorithm
d - signature value (not the data to sign)
Method Detail

create

public static Signature create(java.security.KeyPair kp,
                               Obj o,
                               DigestAlgoEnum a)
Signs the given JSDSI Obj using the 'default' java.security.Provider.

Parameters:
kp - KeyPair containing the PrivateKey to sign with.
o - JSDSI Obj to sign.
a - hash algorythm to use.
Returns:
the signature.
Throws:
JsdsiRuntimeException - on error

create

public static Signature create(java.security.KeyPair kp,
                               byte[] bytes,
                               DigestAlgoEnum a)
Signs the given byte array using the 'default' java.security.Provider.

Parameters:
kp - KeyPair containing the PrivateKey to sign with.
bytes - data to sign.
a - hash algorythm to use.
Returns:
the signature.
Throws:
JsdsiRuntimeException - on error

create

public static Signature create(java.security.KeyPair kp,
                               java.io.InputStream is,
                               DigestAlgoEnum a)
Signs the given byte array using the 'default' java.security.Provider.

Parameters:
kp - KeyPair containing the PrivateKey to sign with.
is - data to sign.
a - hash algorythm to use.
Returns:
the signature.
Throws:
JsdsiRuntimeException - on error

create

public static Signature create(java.security.KeyPair kp,
                               Obj o,
                               DigestAlgoEnum a,
                               java.lang.String provider)
Signs the given JSDSI Obj using the specified java.security.Provider.

Parameters:
kp - KeyPair containing the PrivateKey to sign with.
o - JSDSI Obj to sign.
a - hash algorythm to use.
Returns:
the signature.
Throws:
JsdsiRuntimeException - on error

create

public static Signature create(java.security.KeyPair kp,
                               byte[] bytes,
                               DigestAlgoEnum a,
                               java.lang.String provider)
Signs the given byte array using the specified java.security.Provider.

Parameters:
kp - KeyPair containing the PrivateKey to sign with.
bytes - data to sign.
a - hash algorythm to use.
Returns:
the signature.
Throws:
JsdsiRuntimeException - on error

create

public static Signature create(java.security.KeyPair kp,
                               java.io.InputStream is,
                               DigestAlgoEnum digestEnum,
                               java.lang.String provider)
Signs the given byte array using the specified java.security.Provider.

Parameters:
kp - KeyPair containing the PrivateKey to sign with.
is - data to sign.
digestEnum - hash algorythm to use.
Returns:
the signature.
Throws:
JsdsiRuntimeException - on error

create

public static Signature create(java.security.KeyPair kp,
                               Obj o,
                               java.lang.String a)
                        throws java.security.NoSuchAlgorithmException,
                               java.security.InvalidKeyException,
                               java.security.NoSuchProviderException,
                               java.security.SignatureException
Deprecated.  

Signs the given JSDSI Obj using the 'default' java.security.Provider.

Parameters:
kp - the KeyPair containing the PrivateKey to sign with.
o - the JSDSI Obj to sign.
a - the name of the signing algorythm to use.
Returns:
the signature.
Throws:
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.SignatureException

create

public static Signature create(java.security.KeyPair kp,
                               Obj o,
                               java.lang.String a,
                               java.lang.String provider)
                        throws java.security.NoSuchAlgorithmException,
                               java.security.InvalidKeyException,
                               java.security.NoSuchProviderException,
                               java.security.SignatureException
Deprecated.  

Signs the given JSDSI Obj.

Parameters:
kp - the KeyPair containing the PrivateKey to sign with.
o - the JSDSI Obj to sign.
a - the name of the signing algorythm to use.
provider - the name of the security Provider to use.
Returns:
the signature.
Throws:
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.SignatureException

create

public static Signature create(java.security.KeyPair kp,
                               byte[] b,
                               java.lang.String a)
                        throws java.security.NoSuchAlgorithmException,
                               java.security.InvalidKeyException,
                               java.security.NoSuchProviderException,
                               java.security.SignatureException
Deprecated.  

Signs some data given as a byte[] using the 'default' java.security.Provider.

Parameters:
kp - the KeyPair containing the PrivateKey to sign with.
b - the data to sign.
a - the name of the signing algorythm to use.
Returns:
the signature.
Throws:
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.SignatureException

create

public static Signature create(java.security.KeyPair kp,
                               byte[] b,
                               java.lang.String a,
                               java.lang.String provider)
                        throws java.security.NoSuchAlgorithmException,
                               java.security.InvalidKeyException,
                               java.security.NoSuchProviderException,
                               java.security.SignatureException
Deprecated.  

Signs some data given as a byte[].

Parameters:
kp - the KeyPair containing the PrivateKey to sign with.
b - the data to sign.
a - the name of the signing algorythm to use.
provider - the name of the security Provider to use.
Returns:
the signature.
Throws:
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.SignatureException

create

public static Signature create(java.security.KeyPair kp,
                               java.io.InputStream toSign,
                               java.lang.String a)
                        throws java.security.InvalidKeyException,
                               java.security.NoSuchAlgorithmException,
                               java.security.NoSuchProviderException,
                               java.security.SignatureException
Deprecated.  

Signs some data given as an java.io.InputStream using the 'default' java.security.Provider.

Parameters:
kp - the KeyPair containing the PrivateKey to sign with.
toSign - the InputStream with the data to sign.
a - the name of the signing algorythm to use.
Returns:
the signature.
Throws:
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.SignatureException

create

public static Signature create(java.security.KeyPair kp,
                               java.io.InputStream toSign,
                               java.lang.String a,
                               java.lang.String provider)
                        throws java.security.NoSuchAlgorithmException,
                               java.security.NoSuchProviderException,
                               java.security.InvalidKeyException,
                               java.security.SignatureException
Deprecated.  

Signs some data given as a java.io.InputStream.

Parameters:
kp - the KeyPair containing the PrivateKey to sign with.
toSign - the InputStream with the data to sign.
a - the name of the signing algorythm to use
provider - the name of the security Provider to use.
Returns:
the signature.
Throws:
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.SignatureException

verify

public boolean verify(java.security.PublicKey key,
                      Obj o)
               throws java.security.InvalidKeyException,
                      java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      java.security.SignatureException
Using the default security Provider, verifies that the corresponding PrivateKey for key generated this Signature for o

Parameters:
key - the PublicKey
o - the jsdsi object that was (alledgedly) signed
Returns:
true if the signature verifies
Throws:
JsdsiRuntimeException - on error
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.SignatureException

verify

public boolean verify(java.security.PublicKey key,
                      Obj o,
                      java.lang.String provider)
               throws java.security.InvalidKeyException,
                      java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      java.security.SignatureException
Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.SignatureException

verify

public boolean verify(java.security.PublicKey key,
                      byte[] b)
               throws java.security.InvalidKeyException,
                      java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      java.security.SignatureException
Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.SignatureException

verify

public boolean verify(java.security.PublicKey key,
                      byte[] b,
                      java.lang.String provider)
               throws java.security.InvalidKeyException,
                      java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      java.security.SignatureException
Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.SignatureException

verify

public boolean verify(java.security.PublicKey key,
                      java.io.InputStream toCheck)
               throws java.security.InvalidKeyException,
                      java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      java.security.SignatureException
Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.SignatureException

verify

public boolean verify(java.security.PublicKey key,
                      java.io.InputStream toCheck,
                      java.lang.String provider)
               throws java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      java.security.InvalidKeyException,
                      java.security.SignatureException
Using the provider, verifies that the corresponding PrivateKey for key generated this Signature for the data given by toCheck

Parameters:
key - the PublicKey
toCheck - an InputStream of data
Returns:
true if the signature verifies
Throws:
JsdsiRuntimeException - on error
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.InvalidKeyException
java.security.SignatureException

getSigner

public Principal getSigner()
Returns:
the principal representing the signer.

getSignee

public Hash getSignee()
Returns:
the hash of the signed data.

getAlgorithm

public java.lang.String getAlgorithm()
Returns:
the JDK name for the signature algorithm.

getSignatureEnum

public SignatureAlgoEnum getSignatureEnum()
Returns:
the signature algorythm

getData

public byte[] getData()
Returns:
the value of the signature.

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in class Obj
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Specified by:
hashCode in class Obj
See Also:
Object.hashCode()

toSexp

public SexpList toSexp()
Description copied from class: Obj
Creates an SexpList -representation from this SDSI-object.

Specified by:
toSexp in interface Element
Specified by:
toSexp in class Obj
Returns:
an SexpList that represents this SDSI-object.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2002-2006 JSDSI. All Rights Reserved.