java.lang.Object
org.bouncycastle.tls.crypto.impl.jcajce.srp.SRP6Server

public class SRP6Server extends Object
Implements the server side SRP-6a protocol. Note that this class is stateful, and therefore NOT threadsafe. This implementation of SRP is based on the optimized message sequence put forth by Thomas Wu in the paper "SRP-6: Improvements and Refinements to the Secure Remote Password Protocol, 2002"
  • Field Details Link icon

  • Constructor Details Link icon

    • SRP6Server Link icon

      public SRP6Server()
  • Method Details Link icon

    • init Link icon

      public void init(BigInteger N, BigInteger g, BigInteger v, TlsHash digest, SecureRandom random)
      Initialises the server to accept a new client authentication attempt
      Parameters:
      N - The safe prime associated with the client's verifier
      g - The group parameter associated with the client's verifier
      v - The client's verifier
      digest - The digest algorithm associated with the client's verifier
      random - For key generation
    • init Link icon

      public void init(SRP6Group group, BigInteger v, TlsHash digest, SecureRandom random)
    • generateServerCredentials Link icon

      public BigInteger generateServerCredentials()
      Generates the server's credentials that are to be sent to the client.
      Returns:
      The server's public value to the client
    • calculateSecret Link icon

      public BigInteger calculateSecret(BigInteger clientA) throws IllegalArgumentException
      Processes the client's credentials. If valid the shared secret is generated and returned.
      Parameters:
      clientA - The client's credentials
      Returns:
      A shared secret BigInteger
      Throws:
      IllegalArgumentException - If client's credentials are invalid
    • selectPrivateValue Link icon

      protected BigInteger selectPrivateValue()
    • verifyClientEvidenceMessage Link icon

      public boolean verifyClientEvidenceMessage(BigInteger clientM1) throws IllegalStateException
      Authenticates the received client evidence message M1 and saves it only if correct. To be called after calculating the secret S.
      Parameters:
      clientM1 - the client side generated evidence message
      Returns:
      A boolean indicating if the client message M1 was the expected one.
      Throws:
      IllegalStateException
    • calculateServerEvidenceMessage Link icon

      public BigInteger calculateServerEvidenceMessage() throws IllegalStateException
      Computes the server evidence message M2 using the previously verified values. To be called after successfully verifying the client evidence message M1.
      Returns:
      M2: the server side generated evidence message
      Throws:
      IllegalStateException
    • calculateSessionKey Link icon

      public BigInteger calculateSessionKey() throws IllegalArgumentException
      Computes the final session key as a result of the SRP successful mutual authentication To be called after calculating the server evidence message M2.
      Returns:
      Key: the mutual authenticated symmetric session key
      Throws:
      IllegalStateException
      IllegalArgumentException