/** * Create a {@link SimulatedTlsSRPIdentityManager} that implements the algorithm from RFC 5054 2.5.1.3 * * @param group the {@link SRP6GroupParameters} defining the group that SRP is operating in * @param seedKey the secret "seed key" referred to in RFC 5054 2.5.1.3 * @return an instance of {@link SimulatedTlsSRPIdentityManager} */ public static SimulatedTlsSRPIdentityManager getRFC5054Default(SRP6GroupParameters group, byte[] seedKey) { SRP6VerifierGenerator verifierGenerator = new SRP6VerifierGenerator(); verifierGenerator.init(group, TlsUtils.createHash(HashAlgorithm.sha1)); HMac mac = new HMac(TlsUtils.createHash(HashAlgorithm.sha1)); mac.init(new KeyParameter(seedKey)); return new SimulatedTlsSRPIdentityManager(group, verifierGenerator, mac); }
public boolean accept(SRP6GroupParameters group) { for (int i = 0; i < groups.size(); ++i) { if (areGroupsEqual(group, (SRP6GroupParameters)groups.elementAt(i))) { return true; } } return false; }
private void testWithRandomParams(int bits) throws CryptoException { DHParametersGenerator paramGen = new DHParametersGenerator(); paramGen.init(bits, 25, random); DHParameters parameters = paramGen.generateParameters(); testMutualVerification(new SRP6GroupParameters(parameters.getP(), parameters.getG())); }
public SimulatedTlsSRPIdentityManager(SRP6GroupParameters group, SRP6VerifierGenerator verifierGenerator, Mac mac) { this.group = group; this.verifierGenerator = verifierGenerator; this.mac = mac; }
protected boolean areGroupsEqual(SRP6GroupParameters a, SRP6GroupParameters b) { return a == b || (areParametersEqual(a.getN(), b.getN()) && areParametersEqual(a.getG(), b.getG())); }
public TlsSRPLoginParameters(SRP6GroupParameters group, BigInteger verifier, byte[] salt) { this.group = group; this.verifier = verifier; this.salt = salt; }
public SRP6GroupParameters getGroup() { return group; }
public void init(SRP6GroupParameters group, BigInteger v, Digest digest, SecureRandom random) { init(group.getN(), group.getG(), v, digest, random); }
public void init(SRP6GroupParameters group, Digest digest) { this.N = group.getN(); this.g = group.getG(); this.digest = digest; }
private static SRP6GroupParameters fromNG(String hexN, String hexG) { return new SRP6GroupParameters(fromHex(hexN), fromHex(hexG)); }
public void init(SRP6GroupParameters group, Digest digest, SecureRandom random) { init(group.getN(), group.getG(), digest, random); }
private void testMutualVerification(SRP6GroupParameters group) throws CryptoException { byte[] I = "username".getBytes(); byte[] P = "password".getBytes(); byte[] s = new byte[16]; random.nextBytes(s); SRP6VerifierGenerator gen = new SRP6VerifierGenerator(); gen.init(group, new SHA256Digest()); BigInteger v = gen.generateVerifier(s, I, P); SRP6Client client = new SRP6Client(); client.init(group, new SHA256Digest(), random); SRP6Server server = new SRP6Server(); server.init(group, v, new SHA256Digest(), random); BigInteger A = client.generateClientCredentials(s, I, P); BigInteger B = server.generateServerCredentials(); BigInteger clientS = client.calculateSecret(B); BigInteger serverS = server.calculateSecret(A); if (!clientS.equals(serverS)) { fail("SRP agreement failed - client/server calculated different secrets"); } }
public static final WoWSRP6Server init(SRP6GroupParameters params, BigInteger v, byte[] I, byte[] s, Digest digest, SecureRandom random) { WoWSRP6Server srp = new WoWSRP6Server(); srp.initInternal(params, v, I, s, digest, random); return srp; }
private final void initInternal(SRP6GroupParameters params, BigInteger v, byte[] I, byte[] s, Digest digest, SecureRandom random) { this.I = I.clone(); this.s = s.clone(); super.init(params.getN(), params.getG(), v, digest, random); }
@Override public final void init(SRP6GroupParameters params, BigInteger v, Digest digest, SecureRandom random) { throw new UnsupportedOperationException(); }
/** * Check whether the given SRP group parameters are acceptable for use. * * @param group the {@link SRP6GroupParameters} to check * @return true if (and only if) the specified group parameters are acceptable */ boolean accept(SRP6GroupParameters group);