Class SRP6PrivateKey

  • All Implemented Interfaces:
    SRP6IntegerVariable

    public final class SRP6PrivateKey
    extends AbstractSRP6IntegerVariable
    SRP-6 Private Key (x).

    This variable is computed as:

     x = H(s | p)
     
    where H() is a one-way hash function, | a concatenation operator, s a random salt and p the client's password [1].

    In an article that documents refinements to the protocol, another formula is used:

     x = H(s | I | P)
     
    where I is cleartext username, or identity, and P cleartext password [2].

    RFC 2945 further specifies x as:

     x = H(s | H(I | ":" | P))
     
    where I is cleartext username, or identity, and P cleartext password [3].

    Use of I within x avoids a malicious server from being able to learn if two users share the same password (refer to this SO question for more info).

    If there isn't a suitable constructor for your version of the protocol, you can set a custom private key like so:

     // ByteOrder byteOrder = ...
     SRP6IntegerVariable x =
         new SRP6CustomIntegerVariable(
             new Hash(
                 // custom args
             ),
             byteOrder
         );
     

    References:

    • Constructor Detail

      • SRP6PrivateKey

        public SRP6PrivateKey​(ImmutableMessageDigest hashFunction,
                              Bytes salt,
                              Bytes cleartextUsername,
                              Bytes cleartextPassword,
                              ByteOrder endianness)
        Constructs a new SRP-6 Private Key as specified in RFC 2945.
         x = H(s | H(I | ":" | P))
         
        Parameters:
        hashFunction - a one-way hash function - H()
        salt - SRP-6 variable: salt (s)
        cleartextUsername - SRP-6 variable: cleartext username - identity (I)
        cleartextPassword - SRP-6 variable: cleartext password (P)
        endianness - the byte order to use when converting the resulting hash to integer
      • SRP6PrivateKey

        public SRP6PrivateKey​(ImmutableMessageDigest hashFunction,
                              Bytes salt,
                              Bytes password,
                              ByteOrder endianness)
        Constructs a new SRP-6 Private Key from salt and password.
         x = H(s | p)
         
        Parameters:
        hashFunction - a one-way hash function - H()
        salt - SRP-6 variable: salt (s)
        password - SRP-6 variable: password (p)
        endianness - the byte order to use when converting the resulting hash to integer
    • Method Detail

      • bytes

        public Bytes bytes​(ByteOrder preferredOrder)
        Description copied from interface: SRP6IntegerVariable
        Returns this SRP-6 Integer Variable as a byte sequence in the preferred byte order.

        The representation returned must be minimal. That is, all leading (or trailing, depending on the preferredOrder) zero bytes have to be trimmed.

        Number zero is hence defined as an empty byte sequence.

        Parameters:
        preferredOrder - the preferred byte order of the byte sequence that represents this SRP-6 Integer Variable
        Returns:
        the byte sequence that represents this SRP-6 Integer Variable in the preferred byte order