gnu.javax.crypto.sasl.srp

Class SRP


public final class SRP
extends Object

A Factory class that returns SRP Singletons that know all SRP-related mathematical computations and protocol-related operations for both the client- and server-sides.

Method Summary

byte[]
computeX(byte[] s, String user, byte[] p)
byte[]
computeX(byte[] s, String user, String password)
byte[]
digest(byte[] src)
Convenience method to return the result of digesting the designated input with a new instance of the SRP message digest algorithm.
byte[]
digest(String src)
Convenience method to return the result of digesting the designated input with a new instance of the SRP message digest algorithm.
byte[]
generateKn(byte[] K, byte[] cn, byte[] sn)
byte[]
generateM1(BigInteger N, BigInteger g, String U, byte[] s, BigInteger A, BigInteger B, byte[] K, String I, String L, byte[] cn, byte[] cCB)
byte[]
generateM2(BigInteger A, byte[] M1, byte[] K, String U, String I, String o, byte[] sid, int ttl, byte[] cIV, byte[] sIV, byte[] sCB)
String
getAlgorithm()
static SRP
instance(String mdName)
Returns an instance of this object that uses the designated message digest algorithm as its digest function.
IMessageDigest
newDigest()
Returns a new instance of the SRP message digest algorithm --which is SHA-160 by default, but could be anything else provided the proper conditions as specified in the SRP specifications.
byte[]
xor(byte[] a, byte[] b)
Convenience method to XOR N bytes from two arrays; N being the output size of the SRP message digest algorithm.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

computeX

public byte[] computeX(byte[] s,
                       String user,
                       byte[] p)
            throws UnsupportedEncodingException

computeX

public byte[] computeX(byte[] s,
                       String user,
                       String password)
            throws UnsupportedEncodingException

digest

public byte[] digest(byte[] src)
Convenience method to return the result of digesting the designated input with a new instance of the SRP message digest algorithm.
Parameters:
src - some bytes to digest.
Returns:
the bytes constituting the result of digesting the designated input with a new instance of the SRP message digest algorithm.

digest

public byte[] digest(String src)
            throws UnsupportedEncodingException
Convenience method to return the result of digesting the designated input with a new instance of the SRP message digest algorithm.
Parameters:
src - a String whose bytes (using US-ASCII encoding) are to be digested.
Returns:
the bytes constituting the result of digesting the designated input with a new instance of the SRP message digest algorithm.
Throws:
UnsupportedEncodingException - if US-ASCII charset is not found.

generateKn

public byte[] generateKn(byte[] K,
                         byte[] cn,
                         byte[] sn)

generateM1

public byte[] generateM1(BigInteger N,
                         BigInteger g,
                         String U,
                         byte[] s,
                         BigInteger A,
                         BigInteger B,
                         byte[] K,
                         String I,
                         String L,
                         byte[] cn,
                         byte[] cCB)
            throws UnsupportedEncodingException

generateM2

public byte[] generateM2(BigInteger A,
                         byte[] M1,
                         byte[] K,
                         String U,
                         String I,
                         String o,
                         byte[] sid,
                         int ttl,
                         byte[] cIV,
                         byte[] sIV,
                         byte[] sCB)
            throws UnsupportedEncodingException

getAlgorithm

public String getAlgorithm()
Returns:
the message digest algorithm name used by this instance.

instance

public static SRP instance(String mdName)
Returns an instance of this object that uses the designated message digest algorithm as its digest function.
Returns:
an instance of this object for the designated digest name.

newDigest

public IMessageDigest newDigest()
Returns a new instance of the SRP message digest algorithm --which is SHA-160 by default, but could be anything else provided the proper conditions as specified in the SRP specifications.
Returns:
a new instance of the underlying SRP message digest algorithm.
Throws:
RuntimeException - if the implementation of the message digest algorithm does not support cloning.

xor

public byte[] xor(byte[] a,
                  byte[] b)
Convenience method to XOR N bytes from two arrays; N being the output size of the SRP message digest algorithm.
Parameters:
a - the first byte array.
b - the second one.
Returns:
N bytes which are the result of the XOR operations on the first N bytes from the designated arrays. N is the size of the SRP message digest algorithm; eg. 20 for SHA-160.

SRP.java -- Copyright (C) 2003, 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.