Save This Page
Home » crypto-143 » org.bouncycastle.crypto.agreement.srp » [javadoc | source]
    1   package org.bouncycastle.crypto.agreement.srp;
    2   
    3   import java.math.BigInteger;
    4   
    5   import org.bouncycastle.crypto.Digest;
    6   
    7   /**
    8    * Generates new SRP verifier for user
    9    */
   10   public class SRP6VerifierGenerator
   11   {
   12       protected BigInteger N;
   13       protected BigInteger g;
   14       protected Digest digest;
   15   
   16       public SRP6VerifierGenerator()
   17       {
   18       }
   19   
   20       /**
   21        * Initialises generator to create new verifiers
   22        * @param N The safe prime to use (see DHParametersGenerator)
   23        * @param g The group parameter to use (see DHParametersGenerator)
   24        * @param digest The digest to use. The same digest type will need to be used later for the actual authentication
   25        * attempt. Also note that the final session key size is dependent on the chosen digest.
   26        */
   27       public void init(BigInteger N, BigInteger g, Digest digest)
   28       {
   29           this.N = N;
   30           this.g = g;
   31           this.digest = digest;
   32       }
   33   
   34       /**
   35        * Creates a new SRP verifier
   36        * @param salt The salt to use, generally should be large and random
   37        * @param identity The user's identifying information (eg. username)
   38        * @param password The user's password
   39        * @return A new verifier for use in future SRP authentication
   40        */
   41       public BigInteger generateVerifier(byte[] salt, byte[] identity, byte[] password)
   42       {
   43       	BigInteger x = SRP6Util.calculateX(digest, N, salt, identity, password);
   44   
   45           return g.modPow(x, N);
   46       }
   47   }

Save This Page
Home » crypto-143 » org.bouncycastle.crypto.agreement.srp » [javadoc | source]