All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class IS.hi.logir.cryptonite.Fingerprint

java.lang.Object
   |
   +----IS.hi.logir.cryptonite.Fingerprint

public class Fingerprint
extends Object
implements Serializable
This class is used to hold a fingerprint of a particular data buffer. The idea is to calculate a fingerprint in such a way that it is extremely difficult to create another buffer that gives the same fingerprint. If that buffer also has to match some other criteria, such as being a valid text file in a particular language, then it becomes next to impossible.

All this depends on the hash function used to create the fingerprint being a good one. Fingerprints are created by the various subclasses of FingerprintState, so you should look there for information about a particular hash function.

You should be very careful about saving fingerprints. If a fingerprint is not calculated at run-time, then it should not be trusted, since it may have been tampered with in storage or transit. This is why the private fingerprint field of the Key class is marked as transient and re-calcualted when the class is deserialized.

Author:
Logi Ragnarsson (logir@hi.is)
See Also:
FingerprintState, Signature

Variable Index

 o algorithm
algorithm holds the name of the algorithm used to create this fingerprint.
 o fp
fp holds the actual bytes of the fingerprint value.
 o nibble

Constructor Index

 o Fingerprint(String, byte[])
Creates a new Fingerprint object given algorithm name and the hash value from fp.
 o Fingerprint(String, byte[], int)
Creates a new Fingerprint object given algorithm name and the hash value from fp[0..n-1].

Method Index

 o equals(Object)
return true if obj is a fingerprint equal to this.
 o get(String, byte[])
Creates a fingerprint for the buffer buf using the named fingerprint-class.
 o getBytes()
Return an array of the bytes in the fingerprint.
 o getName()
Return the name of the algorithm used for this hash.
 o hashCode()
 o toString()
Return a string represesntation of this fingerprint.

Variables

 o fp
 protected byte fp[]
fp holds the actual bytes of the fingerprint value.

 o algorithm
 protected String algorithm
algorithm holds the name of the algorithm used to create this fingerprint.

 o nibble
 private static char nibble[]

Constructors

 o Fingerprint
 public Fingerprint(String algorithm,
                    byte fp[],
                    int n)
Creates a new Fingerprint object given algorithm name and the hash value from fp[0..n-1].

 o Fingerprint
 public Fingerprint(String algorithm,
                    byte fp[])
Creates a new Fingerprint object given algorithm name and the hash value from fp.

Methods

 o get
 public static Fingerprint get(String name,
                               byte buf[]) throws BadFingerprintClassException
Creates a fingerprint for the buffer buf using the named fingerprint-class.

A fingerprint class with the specified name must previously have been registered by calling the registerIncludedClasses method on the FingerprintState class. This is automatically done for classes included with cryptonite but any other classes must be registered manually.

 o getName
 public String getName()
Return the name of the algorithm used for this hash.

 o getBytes
 public byte[] getBytes()
Return an array of the bytes in the fingerprint.

 o equals
 public boolean equals(Object obj)
return true if obj is a fingerprint equal to this.

Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Overrides:
hashCode in class Object
 o toString
 public String toString()
Return a string represesntation of this fingerprint.

Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index