org.ccnx.ccn.impl.security.crypto.util.DigestHelper Class Reference

Helper class for digest algorithms. More...

Inheritance diagram for org.ccnx.ccn.impl.security.crypto.util.DigestHelper:

org.ccnx.ccn.impl.security.crypto.CCNDigestHelper

List of all members.

Public Member Functions

 DigestHelper ()
 Instantiates a MessageDigest of type DEFAULT_DIGEST_ALGORITHM.
 DigestHelper (String digestAlgorithm) throws NoSuchAlgorithmException
 Instantiates a MessageDigest of type digestAlgorithm.
String getDefaultDigest ()
 This method is non-static so subclasses can override it.
void update (byte[] content, int offset, int len)
 Updates the digest using the specified array of bytes, starting at the specified offset.
void update (byte[] content)
byte[] digest ()
 Completes the hash computation by performing final operations such as padding.

Static Public Member Functions

static byte[] digest (byte[] content)
 Static method to hash an array of bytes with DEFAULT_DIGEST_ALGORITHM.
static byte[] digest (String digestAlgorithm, byte[] content) throws NoSuchAlgorithmException
 Static method to hash an array of bytes with a specified digest algorithm.
static byte[] digest (byte[] content, int offset, int length)
 Static method to hash an array of bytes with DEFAULT_DIGEST_ALGORITHM, starting at the specified offset.
static byte[] digest (String digestAlgorithm, byte[] content, int offset, int length) throws NoSuchAlgorithmException
 Static method to hash an array of bytes with a specified digest algorithm, starting at the specified offset.
static byte[] digest (byte[] content1, byte[] content2)
 Helper function for building Merkle hash trees.
static byte[] digest (String digestAlgorithm, byte[] content1, byte[] content2) throws NoSuchAlgorithmException
 Helper function for building Merkle hash trees.
static byte[] digest (byte[][] contents)
 Helper function for building Merkle hash trees.
static byte[] digest (String digestAlgorithm, byte[][] contents) throws NoSuchAlgorithmException
 Helper function for building Merkle hash trees.
static byte[] encodedDigest (String digestAlgorithm, byte[] content) throws CertificateEncodingException, NoSuchAlgorithmException
 Digests some array of bytes with the specified digest algorithm and wraps it in a DigestInfo.
static byte[] encodedDigest (byte[] content) throws CertificateEncodingException
 Digests some array of bytes with DEFAULT_DIGEST_ALGORITHM and wraps it in a DigestInfo.
static byte[] digestEncoder (String digestAlgorithm, byte[] theDigest)
 Takes a specified digest and wraps it in a DigestInfo for the specified digest algorithm.
static DigestInfo digestDecoder (byte[] encodedDigest) throws CertificateEncodingException
 Returns the DigestInfo corresponding to a specified array of bytes.
static String printBytes (byte[] binaryObject, int radix)
 Returns an array of bytes as a String.
static byte[] scanBytes (String encodedString, int radix)
 Returns a String as an array of bytes.

Static Public Attributes

static String DEFAULT_DIGEST_ALGORITHM = "SHA-1"
static int DEFAULT_DIGEST_LENGTH = 20

Protected Attributes

MessageDigest _md


Detailed Description

Helper class for digest algorithms.

Includes static methods to compute the digest of an array of bytes with DEFAULT_DIGEST_ALGORITHM ("SHA-1" by default). Includes methods for computing Merkle hash trees (hash computation of the concatenation of two or more arrays of bytes.)


Constructor & Destructor Documentation

org.ccnx.ccn.impl.security.crypto.util.DigestHelper.DigestHelper ( String  digestAlgorithm  )  throws NoSuchAlgorithmException

Instantiates a MessageDigest of type digestAlgorithm.

Parameters:
digestAlgorithm the digest algorithm selected.
Exceptions:
NoSuchAlgorithmException 


Member Function Documentation

String org.ccnx.ccn.impl.security.crypto.util.DigestHelper.getDefaultDigest (  ) 

This method is non-static so subclasses can override it.

Returns:
the default digest algorithm.

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

void org.ccnx.ccn.impl.security.crypto.util.DigestHelper.update ( byte[]  content,
int  offset,
int  len 
)

Updates the digest using the specified array of bytes, starting at the specified offset.

Parameters:
content the array of bytes.
offset the offset.
len the number of bytes to use, starting at offset.

byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digest (  ) 

Completes the hash computation by performing final operations such as padding.

The digest is reset after this call is made.

Returns:
the array of bytes for the resulting hash value.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digest ( byte[]  content  )  [static]

Static method to hash an array of bytes with DEFAULT_DIGEST_ALGORITHM.

Parameters:
content the array of bytes.
Returns:
the array of bytes for the resulting hash value.

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digest ( String  digestAlgorithm,
byte[]  content 
) throws NoSuchAlgorithmException [static]

Static method to hash an array of bytes with a specified digest algorithm.

Parameters:
digestAlgorithm the digest algorithm.
content the array of bytes.
Returns:
the array of bytes for the resulting hash value.
Exceptions:
NoSuchAlgorithmException 

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digest ( byte[]  content,
int  offset,
int  length 
) [static]

Static method to hash an array of bytes with DEFAULT_DIGEST_ALGORITHM, starting at the specified offset.

Parameters:
content the array of bytes.
offset the offset.
length the number of bytes to use, starting at offset.
Returns:
the array of bytes for the resulting hash value.

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digest ( String  digestAlgorithm,
byte[]  content,
int  offset,
int  length 
) throws NoSuchAlgorithmException [static]

Static method to hash an array of bytes with a specified digest algorithm, starting at the specified offset.

Parameters:
digestAlgorithm the digest algorithm.
content the array of bytes.
offset the offset.
length the number of bytes to user, starting at offset.
Returns:
the array of bytes for the resulting hash value.
Exceptions:
NoSuchAlgorithmException 

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digest ( byte[]  content1,
byte[]  content2 
) [static]

Helper function for building Merkle hash trees.

Returns digest of two concatenated byte arrays. If either is null, simply includes the non-null array. The digest is computed with DEFAULT_DIGEST_ALGORITHM.

Parameters:
content1 first array of bytes.
content2 second array of bytes.
Returns:
the array of bytes for the resulting hash value.

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digest ( String  digestAlgorithm,
byte[]  content1,
byte[]  content2 
) throws NoSuchAlgorithmException [static]

Helper function for building Merkle hash trees.

Returns digest of two concatenated byte arrays. If either is null, simply includes the non-null array. The digest is computed with the specified digest algorithm.

Parameters:
digestAlgorithm the digest algorithm.
content1 first array of bytes.
content2 second array of bytes.
Returns:
the array of bytes for the resulting hash value.
Exceptions:
NoSuchAlgorithmException 

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digest ( byte  contents[][]  )  [static]

Helper function for building Merkle hash trees.

Returns the digest of an array of byte arrays. The digest is computed with DEFAULT_DIGEST_ALGORITHM.

Parameters:
contents the array of byte arrays.
Returns:
the array of bytes for the resulting hash value.

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digest ( String  digestAlgorithm,
byte  contents[][] 
) throws NoSuchAlgorithmException [static]

Helper function for building Merkle hash trees.

Returns the digest of an array of byte arrays. The digest is computed with the specified digest algorithm.

Parameters:
digestAlgorithm the digest algorithm.
contents the array of byte arrays.
Returns:
the array of bytes of the resulting hash value.
Exceptions:
NoSuchAlgorithmException 

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.encodedDigest ( String  digestAlgorithm,
byte[]  content 
) throws CertificateEncodingException, NoSuchAlgorithmException [static]

Digests some array of bytes with the specified digest algorithm and wraps it in a DigestInfo.

Parameters:
digestAlgorithm the digest algorithm.
content the array of bytes.
Returns:
the array of bytes of the resulting DigestInfo.
Exceptions:
CertificateEncodingException 
NoSuchAlgorithmException 

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.encodedDigest ( byte[]  content  )  throws CertificateEncodingException [static]

Digests some array of bytes with DEFAULT_DIGEST_ALGORITHM and wraps it in a DigestInfo.

Parameters:
content the array of bytes.
Returns:
the array of bytes of the resulting DigestInfo.
Exceptions:
CertificateEncodingException 
NoSuchAlgorithmException 

Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digestEncoder ( String  digestAlgorithm,
byte[]  theDigest 
) [static]

Takes a specified digest and wraps it in a DigestInfo for the specified digest algorithm.

Parameters:
digestAlgorithm the digest algorithm.
theDigest the digest.
Returns:
the array of bytes of the resulting DigestInfo.

static DigestInfo org.ccnx.ccn.impl.security.crypto.util.DigestHelper.digestDecoder ( byte[]  encodedDigest  )  throws CertificateEncodingException [static]

Returns the DigestInfo corresponding to a specified array of bytes.

Parameters:
encodedDigest the array of bytes.
Returns:
the corresponding DigestInfo.
Exceptions:
CertificateEncodingException 

static String org.ccnx.ccn.impl.security.crypto.util.DigestHelper.printBytes ( byte[]  binaryObject,
int  radix 
) [static]

Returns an array of bytes as a String.

Parameters:
binaryObject the array of bytes.
radix the radix.
Returns:
the corresponding String.

static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.scanBytes ( String  encodedString,
int  radix 
) [static]

Returns a String as an array of bytes.

Parameters:
encodedString the String.
radix the radix.
Returns:
the corresponding array of bytes.


The documentation for this class was generated from the following file:

Generated on Thu Feb 16 00:44:58 2012 for Content-Centric Networking in Java by  doxygen 1.5.6