net.sourceforge.jradiusclient.util
Class ChapUtil

java.lang.Object
  |
  +--net.sourceforge.jradiusclient.util.ChapUtil

public class ChapUtil
extends java.lang.Object

Released under the LGPL

Version:
$Revision: 1.3 $
Author:
Robert J. Loihl

Field Summary
static int DEFAULT_CHALLENGE_SIZE
           
 
Constructor Summary
ChapUtil()
           
 
Method Summary
static byte[] chapEncrypt(byte chapIdentifier, byte[] plaintextPassword, byte[] chapChallenge)
          This method performs the CHAP encryption according to RFC 2865 section 2.2 for use with Radius Servers using MD5 as the one way hashing algorithm
 byte[] getNextChapChallenge(int size)
          Get a fixed number of bytes to use as a chap challenge, generally you don't want this to be less than the number of bytes outbut by the hash algoritm to be used to encrypt the password, in this case 16 since Radius rfc 2865 section 2.2 specifies MD5 if size is <1 we will use the default of 16
 byte getNextChapIdentifier()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CHALLENGE_SIZE

public static final int DEFAULT_CHALLENGE_SIZE
See Also:
Constant Field Values
Constructor Detail

ChapUtil

public ChapUtil()
Method Detail

getNextChapIdentifier

public byte getNextChapIdentifier()
Returns:
a random byte to use as a chap Identifier

getNextChapChallenge

public byte[] getNextChapChallenge(int size)
Get a fixed number of bytes to use as a chap challenge, generally you don't want this to be less than the number of bytes outbut by the hash algoritm to be used to encrypt the password, in this case 16 since Radius rfc 2865 section 2.2 specifies MD5 if size is <1 we will use the default of 16

Parameters:
size - number of bytes the challenge will be
Returns:
suze bytes of random data to use as a chapchallenge

chapEncrypt

public static final byte[] chapEncrypt(byte chapIdentifier,
                                       byte[] plaintextPassword,
                                       byte[] chapChallenge)
This method performs the CHAP encryption according to RFC 2865 section 2.2 for use with Radius Servers using MD5 as the one way hashing algorithm

Parameters:
chapIdentifier - a byte to help correlate unique challenges/responses
plaintextPassword - exactly what it says.
chapChallenge - the bytes to encode the plaintext password with
Returns:
the encrypted password as a byte array (16 bytes to be exact as a result of the MD5 process)