Package gnu.javax.crypto.key.srp6

Examples of gnu.javax.crypto.key.srp6.SRPKeyPairGenerator


        harness.debug(x);
        harness.fail("while initialising User");
      }
    harness.check(!A.isComplete(), "User is ready");

    B = new SRP6Host();

    final Map mapB = new HashMap();
    mapB.put(SRP6KeyAgreement.SHARED_MODULUS, N);
    mapB.put(SRP6KeyAgreement.GENERATOR, g);
    mapB.put(SRP6KeyAgreement.HASH_FUNCTION, Registry.MD5_HASH);
View Full Code Here


      {
        harness.debug(x);
        harness.fail("while setting up the test");
      }

    A = new SRP6SaslClient();

    final Map mapA = new HashMap();
    mapA.put(SRP6KeyAgreement.HASH_FUNCTION, Registry.MD5_HASH);
    mapA.put(SRP6KeyAgreement.USER_IDENTITY, I);
    mapA.put(SRP6KeyAgreement.USER_PASSWORD, p.getBytes());
View Full Code Here

        harness.debug(x);
        harness.fail("while initialising Client");
      }
    harness.check(!A.isComplete(), "Client is ready");

    B = new SRP6SaslServer();

    final Map mapB = new HashMap();
    mapB.put(SRP6KeyAgreement.HASH_FUNCTION, Registry.MD5_HASH);
    mapB.put(SRP6KeyAgreement.HOST_PASSWORD_DB, tpasswd);
View Full Code Here

      {
        harness.debug(x);
        harness.fail("while setting up the test");
      }

    A = new SRP6User();

    final Map mapA = new HashMap();
    mapA.put(SRP6KeyAgreement.SHARED_MODULUS, N);
    mapA.put(SRP6KeyAgreement.GENERATOR, g);
    mapA.put(SRP6KeyAgreement.HASH_FUNCTION, Registry.MD5_HASH);
View Full Code Here

        String[] mpi = tpasswd.lookupConfig(entry[2]);
        BigInteger N = new BigInteger(1, Util.fromBase64(mpi[0]));
        BigInteger g = new BigInteger(1, Util.fromBase64(mpi[1]));

        IKeyPairGenerator kpg = new SRPKeyPairGenerator();
        HashMap attributes = new HashMap();
        attributes.put(SRPKeyPairGenerator.SHARED_MODULUS, N);
        attributes.put(SRPKeyPairGenerator.GENERATOR, g);
        kpg.setup(attributes);

        KeyPair clientKP = kpg.generate();
        BigInteger A = ((SRPPublicKey) clientKP.getPublic()).getY();
        BigInteger a = ((SRPPrivateKey) clientKP.getPrivate()).getX();

        attributes.put(SRPKeyPairGenerator.USER_VERIFIER, v);
        kpg.setup(attributes);

        KeyPair serverKP = kpg.generate();
        BigInteger B = ((SRPPublicKey) serverKP.getPublic()).getY();
        BigInteger b = ((SRPPrivateKey) serverKP.getPrivate()).getX();

        // compute u = H(A | B)
        IMessageDigest hash = srp.newDigest();
View Full Code Here

    final String[] mpi = tpasswd.lookupConfig(entry[2]);
    final BigInteger N = new BigInteger(1, Util.fromBase64(mpi[0]));
    final BigInteger g = new BigInteger(1, Util.fromBase64(mpi[1]));

    final IKeyPairGenerator kpg = new SRPKeyPairGenerator();
    final HashMap attributes = new HashMap();
    attributes.put(SRPKeyPairGenerator.SHARED_MODULUS, N);
    attributes.put(SRPKeyPairGenerator.GENERATOR, g);
    kpg.setup(attributes);

    final KeyPair clientKP = kpg.generate();
    final BigInteger A = ((SRPPublicKey) clientKP.getPublic()).getY();
    final BigInteger a = ((SRPPrivateKey) clientKP.getPrivate()).getX();

    attributes.put(SRPKeyPairGenerator.USER_VERIFIER, v);
    kpg.setup(attributes);

    final KeyPair serverKP = kpg.generate();
    final BigInteger B = ((SRPPublicKey) serverKP.getPublic()).getY();
    final BigInteger b = ((SRPPrivateKey) serverKP.getPrivate()).getX();

    // compute u = H(A | B)
    //      IMessageDigest hash = srp.newDigest();
View Full Code Here

public class TestOfSRPKeyGeneration implements Testlet
{
  public void test(TestHarness harness)
  {
    harness.checkPoint("TestOfSRPKeyGeneration");
    SRPKeyPairGenerator kpg = new SRPKeyPairGenerator();
    HashMap map = new HashMap();
    map.put(SRPKeyPairGenerator.MODULUS_LENGTH, new Integer(530));

    try
      {
        kpg.setup(map);
        harness.fail("L should be >= 512, <= 2048 and of the form 512 + 256n");
      }
    catch (IllegalArgumentException x)
      {
        harness.check(true,
                      "L should be >= 512, <= 2048 and of the form 512 + 256n");
      }

    map.put(SRPKeyPairGenerator.MODULUS_LENGTH, new Integer(512));
    map.put(SRPKeyPairGenerator.USE_DEFAULTS, Boolean.FALSE);
    kpg.setup(map);
    KeyPair kp = kpg.generate();

    BigInteger N1 = ((SRPPublicKey) kp.getPublic()).getN();
    BigInteger N2 = ((SRPPrivateKey) kp.getPrivate()).getN();
    harness.check(N1.equals(N2), "N1.equals(N2)");
View Full Code Here

      }

    pk1 = ((SRPPublicKey) pubK).getEncoded(IKeyPairCodec.RAW_FORMAT);
    pk2 = ((SRPPrivateKey) secK).getEncoded(IKeyPairCodec.RAW_FORMAT);

    IKeyPairCodec codec = new SRPKeyPairRawCodec();
    PublicKey newPubK = codec.decodePublicKey(pk1);
    PrivateKey newSecK = codec.decodePrivateKey(pk2);

    harness.check(pubK.equals(newPubK),
                  "SRP public key Raw encoder/decoder test");
    harness.check(secK.equals(newSecK),
                  "SRP private key Raw encoder/decoder test");
View Full Code Here

  {
    harness.checkPoint("TestOfSRPCodec.testKeyPairRawCodec");
    setUp();

    SRPPublicKey pubK = (SRPPublicKey) kp.getPublic();
    SRPPrivateKey secK = (SRPPrivateKey) kp.getPrivate();

    byte[] pk1, pk2;
    try
      { // an invalid format ID
        pk1 = ((SRPPublicKey) pubK).getEncoded(0);
        harness.fail("Succeeded with unknown format ID");
      }
    catch (IllegalArgumentException x)
      {
        harness.check(true, "Recognised unknown format ID");
      }

    pk1 = ((SRPPublicKey) pubK).getEncoded(IKeyPairCodec.RAW_FORMAT);
    pk2 = ((SRPPrivateKey) secK).getEncoded(IKeyPairCodec.RAW_FORMAT);

    IKeyPairCodec codec = new SRPKeyPairRawCodec();
    PublicKey newPubK = codec.decodePublicKey(pk1);
    PrivateKey newSecK = codec.decodePrivateKey(pk2);

    harness.check(pubK.equals(newPubK),
                  "SRP public key Raw encoder/decoder test");
    harness.check(secK.equals(newSecK),
                  "SRP private key Raw encoder/decoder test");
  }
View Full Code Here

  public void testPrivateKeyValueOf(TestHarness harness)
  {
    harness.checkPoint("TestOfSRPCodec.testPrivateKeyValueOf");
    setUp();

    SRPPrivateKey privateK = (SRPPrivateKey) kp.getPrivate();

    byte[] pk = ((SRPPrivateKey) privateK).getEncoded(IKeyPairCodec.RAW_FORMAT);
    PrivateKey newSecK = SRPPrivateKey.valueOf(pk);

    harness.check(privateK.equals(newSecK),
                  "SRP public key valueOf(<raw-value>) test");
  }
View Full Code Here

TOP

Related Classes of gnu.javax.crypto.key.srp6.SRPKeyPairGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.