de.uplanet.security
Class KeyedSaltedHashing

java.lang.Object
  extended by de.uplanet.security.KeyedSaltedHashing

@Scriptable
public final class KeyedSaltedHashing
extends java.lang.Object

Keyed Salted Hashing

This class implements a keyed and SALTed hashing algorithm. It is closely related to the mechanism described in RFC 2104, HMAC: Keyed-Hashing for Message Authentication. Beyond that, it supports SALT in a way that is compatible with common password storing strategies

Version:
1.0

Constructor Summary
KeyedSaltedHashing()
          Contruct the hashing class with SHA-1 as the undelying hashing algorithm
KeyedSaltedHashing(java.lang.String p_strAlgorithm)
          Contruct the hashing class with the specified hashing algorithm
 
Method Summary
 boolean equals(KeyedSaltedHashing p_another)
          Compare the digest of this object with the digest of another KeyedSaltedHashing
 byte[] getDigest()
          Get the digest.
 byte[] makeDigest(byte[] p_arHashedPwd, byte[] p_arKey)
          Make the digest.
 byte[] makeDigest(byte[] p_arPwd, byte[] p_arSalt, byte[] p_arKey)
          Make the digest.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyedSaltedHashing

public KeyedSaltedHashing()
                   throws java.security.NoSuchAlgorithmException
Contruct the hashing class with SHA-1 as the undelying hashing algorithm

Throws:
java.security.NoSuchAlgorithmException - If the SHA-1 algorithm is not available in the caller's environment. This should never happen.

KeyedSaltedHashing

public KeyedSaltedHashing(java.lang.String p_strAlgorithm)
                   throws java.security.NoSuchAlgorithmException
Contruct the hashing class with the specified hashing algorithm

Throws:
java.security.NoSuchAlgorithmException - If the algorithm is not available in the caller's environment.
Method Detail

equals

public boolean equals(KeyedSaltedHashing p_another)
Compare the digest of this object with the digest of another KeyedSaltedHashing

Parameters:
p_another - Another instance of KeyedSaltedHashing to compare with.
Returns:
true if the two underlying digests are the same or both digest are null, false otherwise.

makeDigest

public byte[] makeDigest(byte[] p_arPwd,
                         byte[] p_arSalt,
                         byte[] p_arKey)
                  throws java.lang.NullPointerException
Make the digest.

The response digest is computed from the password, the SALT and a key

Parameters:
p_arPwd - The plain password as a byte-array.
p_arSalt - The SALT as a byte-array or null if SALT should not be used.
p_arKey - The key/challenge as a byte-array.
Returns:
The keyed salted digest.
Throws:
java.lang.NullPointerException - if p_arPwd or p_arKey is null

makeDigest

public byte[] makeDigest(byte[] p_arHashedPwd,
                         byte[] p_arKey)
                  throws java.lang.NullPointerException
Make the digest.

The response digest is computed from a hashed password-SALT pair and a key

Parameters:
p_arHashedPwd - The hashed and password-SALT-pair as a byte-array.
p_arKey - The key/challenge as a byte-array.
Returns:
The keyed salted digest.
Throws:
java.lang.NullPointerException - if p_arHashedPwd or p_arKey is null

getDigest

public byte[] getDigest()
Get the digest.

Returns:
The keyed salted digest or null if none is available.


Last updated: 2011-08-11 10-04
Copyright © 2000-2011 United Planet. All Rights Reserved.