Helper class for digest algorithms. More...
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 |
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.)
org.ccnx.ccn.impl.security.crypto.util.DigestHelper.DigestHelper | ( | String | digestAlgorithm | ) | throws NoSuchAlgorithmException |
Instantiates a MessageDigest of type digestAlgorithm.
digestAlgorithm | the digest algorithm selected. |
NoSuchAlgorithmException |
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.
digestAlgorithm | the digest algorithm. | |
contents | the array of byte arrays. |
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.
contents | the array of byte arrays. |
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.
digestAlgorithm | the digest algorithm. | |
content1 | first array of bytes. | |
content2 | second array of bytes. |
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.
content1 | first array of bytes. | |
content2 | second array of bytes. |
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.
digestAlgorithm | the digest algorithm. | |
content | the array of bytes. | |
offset | the offset. | |
length | the number of bytes to user, starting at offset. |
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.
content | the array of bytes. | |
offset | the offset. | |
length | the number of bytes to use, starting at offset. |
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.
digestAlgorithm | the digest algorithm. | |
content | the array of bytes. |
NoSuchAlgorithmException |
Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.
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.
content | the array of bytes. |
Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.
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.
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.
encodedDigest | the array of bytes. |
CertificateEncodingException |
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.
digestAlgorithm | the digest algorithm. | |
theDigest | the digest. |
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.
content | the array of bytes. |
CertificateEncodingException | ||
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.
digestAlgorithm | the digest algorithm. | |
content | the array of bytes. |
CertificateEncodingException | ||
NoSuchAlgorithmException |
Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.
String org.ccnx.ccn.impl.security.crypto.util.DigestHelper.getDefaultDigest | ( | ) |
This method is non-static so subclasses can override it.
Reimplemented in org.ccnx.ccn.impl.security.crypto.CCNDigestHelper.
static String org.ccnx.ccn.impl.security.crypto.util.DigestHelper.printBytes | ( | byte[] | binaryObject, | |
int | radix | |||
) | [static] |
Returns an array of bytes as a String.
binaryObject | the array of bytes. | |
radix | the radix. |
static byte [] org.ccnx.ccn.impl.security.crypto.util.DigestHelper.scanBytes | ( | String | encodedString, | |
int | radix | |||
) | [static] |
Returns a String as an array of bytes.
encodedString | the String. | |
radix | the radix. |
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.
content | the array of bytes. | |
offset | the offset. | |
len | the number of bytes to use, starting at offset. |