For the latest news and information visit The GNU Crypto project

## gnu.crypto.sasl.srp
Class SRP

    java.lang.Object
      |
      +--gnu.crypto.sasl.srp.SRP

public final class SRP
extends java.lang.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, java.lang.String user, byte[] p)`
`byte[]` `computeX(byte[] s, java.lang.String user, java.lang.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(java.lang.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(java.math.BigInteger N, java.math.BigInteger g, java.lang.String U, byte[] s, java.math.BigInteger A, java.math.BigInteger B, byte[] K, java.lang.String I, java.lang.String L, byte[] cn, byte[] cCB)`
`byte[]` `generateM2(java.math.BigInteger A, byte[] M1, byte[] K, java.lang.String U, java.lang.String I, java.lang.String o, byte[] sid, int ttl, byte[] cIV, byte[] sIV, byte[] sCB)`
`java.lang.String` `getAlgorithm()`
`static SRP` `instance(java.lang.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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### instance

    public static SRP instance(java.lang.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.

### getAlgorithm

    public java.lang.String getAlgorithm()

  Returns:
    the message digest algorithm name used by this instance.

### 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:
    `java.lang.RuntimeException` - if the implementation of the message digest algorithm does not support cloning.

### 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(java.lang.String src)
                  throws java.io.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:
    `java.io.UnsupportedEncodingException` - if US-ASCII charset is not found.

### 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.

### generateM1

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

    `java.io.UnsupportedEncodingException`

### generateM2

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

    `java.io.UnsupportedEncodingException`

### generateKn

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

### computeX

    public byte[] computeX(byte[] s,
                           java.lang.String user,
                           java.lang.String password)
                    throws java.io.UnsupportedEncodingException

    `java.io.UnsupportedEncodingException`

### computeX

    public byte[] computeX(byte[] s,
                           java.lang.String user,
                           byte[] p)
                    throws java.io.UnsupportedEncodingException

    `java.io.UnsupportedEncodingException`

For the latest news and information visit The GNU Crypto project

Copyright © 2001, 2002, 2003, 2004 Free Software Foundation, Inc.