diff options
Diffstat (limited to 'pki/base/util/src/com/netscape/cmsutil/util/HMACDigest.java')
-rw-r--r-- | pki/base/util/src/com/netscape/cmsutil/util/HMACDigest.java | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/pki/base/util/src/com/netscape/cmsutil/util/HMACDigest.java b/pki/base/util/src/com/netscape/cmsutil/util/HMACDigest.java index eae8cc5f0..e77e37a50 100644 --- a/pki/base/util/src/com/netscape/cmsutil/util/HMACDigest.java +++ b/pki/base/util/src/com/netscape/cmsutil/util/HMACDigest.java @@ -17,12 +17,14 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmsutil.util; + import java.security.MessageDigest; + /** - * This class implements the HMAC algorithm specified in RFC 2104 using any - * MessageDigest. - * + * This class implements the HMAC algorithm specified in RFC 2104 using + * any MessageDigest. + * * @author mikep * @version $Revision$, $Date$ * @see java.security.MessageDigest @@ -49,20 +51,20 @@ public class HMACDigest implements Cloneable { /** * Creates an HMACDigest - * - * @param md The MessageDigest to be used for the HMAC calculation. It must - * be clonable. + * + * @param md The MessageDigest to be used for the HMAC calculation. It + * must be clonable. */ public HMACDigest(MessageDigest md) { mMD = md; } /** - * Creates an HMACDigest and initializes the HMAC function with the given - * key. - * - * @param md The MessageDigest to be used for the HMAC calculation. It must - * be clonable. + * Creates an HMACDigest and initializes the HMAC function + * with the given key. + * + * @param md The MessageDigest to be used for the HMAC calculation. It + * must be clonable. * @param key The key value to be used in the HMAC calculation */ public HMACDigest(MessageDigest md, byte[] key) { @@ -79,16 +81,18 @@ public class HMACDigest implements Cloneable { /** * Initialize the HMAC function - * + * * The HMAC transform looks like: - * - * hash(key XOR opad, hash(key XOR ipad, text)) - * - * where key is an n byte key ipad is the byte 0x36 repeated 64 times opad - * is the byte 0x5c repeated 64 times and text is the data being protected - * + * + * hash(key XOR opad, hash(key XOR ipad, text)) + * + * where key is an n byte key + * ipad is the byte 0x36 repeated 64 times + * opad is the byte 0x5c repeated 64 times + * and text is the data being protected + * * This routine must be called after every reset. - * + * * @param key The password used to protect the hash value */ public void init(byte[] key) { @@ -102,7 +106,7 @@ public class HMACDigest implements Cloneable { mMD.reset(); // Redundant? } - // Copy the key. Truncate if key is too long + // Copy the key. Truncate if key is too long for (i = 0; i < key.length && i < PAD_BYTES; i++) { mKeyIpad[i] = key[i]; mKeyOpad[i] = key[i]; @@ -129,7 +133,7 @@ public class HMACDigest implements Cloneable { /** * Updates the digest using the specified array of bytes. - * + * * @param input the array of bytes. */ public void update(byte[] input) { @@ -137,9 +141,9 @@ public class HMACDigest implements Cloneable { } /** - * Completes the HMAC computation with the outer pad The digest is reset - * after this call is made. - * + * Completes the HMAC computation with the outer pad + * The digest is reset after this call is made. + * * @return the array of bytes for the resulting hash value. */ public byte[] digest() { @@ -171,16 +175,16 @@ public class HMACDigest implements Cloneable { /** * Clone the HMACDigest - * + * * @return a clone if the implementation is cloneable. - * @exception CloneNotSupportedException if this is called on a - * MessageDigest implementation that does not support - * <code>Cloneable</code>. + * @exception CloneNotSupportedException if this is called on a + * MessageDigest implementation that does not support + * <code>Cloneable</code>. */ public Object clone() throws CloneNotSupportedException { int i; - HMACDigest hd = (HMACDigest) super.clone(); + HMACDigest hd = (HMACDigest) super.clone(); hd.mKeyOpad = new byte[PAD_BYTES]; hd.mKeyIpad = new byte[PAD_BYTES]; |