net.i2p.data
Class Signature

java.lang.Object
  extended by net.i2p.data.DataStructureImpl
      extended by net.i2p.data.SimpleDataStructure
          extended by net.i2p.data.Signature
All Implemented Interfaces:
Serializable, DataStructure

public class Signature
extends SimpleDataStructure

Defines the signature as defined by the I2P data structure spec. By default, a signature is a 40-byte array verifying the authenticity of some data using the DSA-SHA1 algorithm. The signature is the 20-byte R followed by the 20-byte S, both are unsigned integers. As of release 0.9.8, signatures of arbitrary length and type are supported. See SigType.

Author:
jrandom
See Also:
Serialized Form

Field Summary
static byte[] FAKE_SIGNATURE
          Deprecated. to be removed
static int SIGNATURE_BYTES
          40
 
Fields inherited from class net.i2p.data.SimpleDataStructure
_data
 
Constructor Summary
Signature()
           
Signature(byte[] data)
           
Signature(SigType type)
          Unknown type not allowed as we won't know the length to read in the data.
Signature(SigType type, byte[] data)
          Should we allow an unknown type here?
 
Method Summary
 boolean equals(Object obj)
          Warning - this returns true for two different classes with the same size and same data, e.g.
 SigType getType()
           
 int hashCode()
          We assume the data has enough randomness in it, so use the first 4 bytes for speed.
 int length()
          The legal length of the byte array in this data structure
 String toString()
           
 
Methods inherited from class net.i2p.data.SimpleDataStructure
calculateHash, fromBase64, fromByteArray, getData, readBytes, setData, toBase64, toByteArray, writeBytes
 
Methods inherited from class net.i2p.data.DataStructureImpl
read
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SIGNATURE_BYTES

public static final int SIGNATURE_BYTES
40


FAKE_SIGNATURE

public static final byte[] FAKE_SIGNATURE
Deprecated. to be removed
all zeros

Constructor Detail

Signature

public Signature()

Signature

public Signature(SigType type)
Unknown type not allowed as we won't know the length to read in the data.

Parameters:
type - non-null
Since:
0.9.8

Signature

public Signature(byte[] data)

Signature

public Signature(SigType type,
                 byte[] data)
Should we allow an unknown type here?

Parameters:
type - non-null
Since:
0.9.8
Method Detail

length

public int length()
Description copied from class: SimpleDataStructure
The legal length of the byte array in this data structure

Specified by:
length in class SimpleDataStructure

getType

public SigType getType()
Returns:
non-null
Since:
0.9.8

toString

public String toString()
Overrides:
toString in class SimpleDataStructure
Since:
0.9.8

hashCode

public int hashCode()
Description copied from class: SimpleDataStructure
We assume the data has enough randomness in it, so use the first 4 bytes for speed. If this is not the case, override in the extending class.

Overrides:
hashCode in class SimpleDataStructure
Since:
0.9.17

equals

public boolean equals(Object obj)
Description copied from class: SimpleDataStructure
Warning - this returns true for two different classes with the same size and same data, e.g. SessionKey and SessionTag, but you wouldn't put them in the same Set, would you?

Overrides:
equals in class SimpleDataStructure
Since:
0.9.17