Codota Logo
DHParameters
Code IndexAdd Codota to your IDE (free)

How to use
DHParameters
in
org.spongycastle.crypto.params

Best Java code snippets using org.spongycastle.crypto.params.DHParameters (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew LinkedList()
  • Codota IconCollections.emptyList()
  • Codota Iconnew ArrayList()
  • Smart code suggestions by Codota
}
origin: com.madgag.spongycastle/prov

JCEDHPublicKey(
  DHPublicKeyParameters  params)
{
  this.y = params.getY();
  this.dhSpec = new DHParameterSpec(params.getParameters().getP(), params.getParameters().getG(), params.getParameters().getL());
}
origin: com.madgag.spongycastle/core

private static DHParameters fromSafeP(String hexP)
{
  BigInteger p = fromHex(hexP), q = p.shiftRight(1);
  return new DHParameters(p, TWO, q);
}
origin: com.madgag.spongycastle/core

public static boolean areCompatibleParameters(DHParameters a, DHParameters b)
{
  return a.getP().equals(b.getP()) && a.getG().equals(b.getG())
    && (a.getQ() == null || b.getQ() == null || a.getQ().equals(b.getQ()));
}
origin: com.madgag.spongycastle/core

  static int getStrength(DHParameters params)
  {
    return params.getL() != 0 ? params.getL() : params.getP().bitLength();
  }
}
origin: com.madgag/sc-light-jdk15on

protected boolean areCompatibleParameters(DHParameters a, DHParameters b)
{
  return a.getP().equals(b.getP()) && a.getG().equals(b.getG());
}
origin: com.madgag/sc-light-jdk15on

BigInteger calculatePrivate(DHParameters dhParams, SecureRandom random)
{
  BigInteger p = dhParams.getP();
  int limit = dhParams.getL();
  if (limit != 0)
  {
    return new BigInteger(limit, random).setBit(limit - 1);
  }
  BigInteger min = TWO;
  int m = dhParams.getM();
  if (m != 0)
  {
    min = ONE.shiftLeft(m - 1);
  }
  BigInteger max = p.subtract(TWO);
  BigInteger q = dhParams.getQ();
  if (q != null)
  {
    max = q.subtract(TWO);
  }
  return BigIntegers.createRandomInRange(min, max, random);
}
origin: com.madgag.spongycastle/core

public int getFieldSize()
{
  return (key.getParameters().getP().bitLength() + 7) / 8;
}
origin: com.madgag/sc-light-jdk15on

  /**
   * given a short term public key from a given party calculate the next
   * message in the agreement sequence. 
   */
  public BigInteger calculateAgreement(
    CipherParameters   pubKey)
  {
    DHPublicKeyParameters   pub = (DHPublicKeyParameters)pubKey;

    if (!pub.getParameters().equals(dhParams))
    {
      throw new IllegalArgumentException("Diffie-Hellman public key has wrong parameters.");
    }

    return pub.getY().modPow(key.getX(), dhParams.getP());
  }
}
origin: com.madgag.spongycastle/core

private BigInteger validate(BigInteger y, DHParameters dhParams)
{
  if (y == null)
  {
    throw new NullPointerException("y value cannot be null");
  }
  // TLS check
  if (y.compareTo(TWO) < 0 || y.compareTo(dhParams.getP().subtract(TWO)) > 0)
  {
    throw new IllegalArgumentException("invalid DH public key");
  }
  if (dhParams.getQ() != null)
  {
    if (ONE.equals(y.modPow(dhParams.getQ(), dhParams.getP())))
    {
      return y;
    }
    throw new IllegalArgumentException("Y value does not appear to be in correct group");
  }
  else
  {
    return y;         // we can't validate without Q.
  }
}
origin: com.madgag/sc-light-jdk15on

  public int hashCode()
  {
    int code = isPrivate() ? 0 : 1;
    
    if (params != null)
    {
      code ^= params.hashCode();
    }
    
    return code;
  }
}
origin: com.madgag/sc-light-jdk15on

public DHParameters(
  BigInteger  p,
  BigInteger  g,
  BigInteger  q,
  int         l)
{
  this(p, g, q, getDefaultMParam(l), l, null, null);
}
origin: com.madgag.spongycastle/core

public boolean equals(
  Object  obj)
{
  if (!(obj instanceof DHKeyParameters))
  {
    return false;
  }
  DHKeyParameters    dhKey = (DHKeyParameters)obj;
  if (params == null)
  {
    return dhKey.getParameters() == null;
  }
  else
  { 
    return params.equals(dhKey.getParameters());
  }
}

origin: com.madgag.spongycastle/core

  BigInteger calculatePublic(DHParameters dhParams, BigInteger x)
  {
    return dhParams.getG().modPow(x, dhParams.getP());
  }
}
origin: com.madgag.spongycastle/core

BigInteger calculatePrivate(DHParameters dhParams, SecureRandom random)
  int limit = dhParams.getL();
  int m = dhParams.getM();
  if (m != 0)
  BigInteger q = dhParams.getQ();
  if (q == null)
    q = dhParams.getP();
origin: com.madgag.spongycastle/core

  public AsymmetricKeyParameter readKey(InputStream stream)
    throws IOException
  {
    byte[] V = new byte[(dhParams.getP().bitLength() + 7) / 8];

    Streams.readFully(stream, V, 0, V.length);

    return new DHPublicKeyParameters(new BigInteger(1, V), dhParams);
  }
}
origin: com.madgag/sc-light-jdk15on

  /**
   * given a message from a given party and the corresponding public key,
   * calculate the next message in the agreement sequence. In this case
   * this will represent the shared secret.
   */
  public BigInteger calculateAgreement(
    DHPublicKeyParameters   pub,
    BigInteger              message)
  {
    if (!pub.getParameters().equals(dhParams))
    {
      throw new IllegalArgumentException("Diffie-Hellman public key has wrong parameters.");
    }

    BigInteger p = dhParams.getP();

    return message.modPow(key.getX(), p).multiply(pub.getY().modPow(privateValue, p)).mod(p);
  }
}
origin: com.madgag/sc-light-jdk15on

  static int getStrength(DHParameters params)
  {
    return params.getL() != 0 ? params.getL() : params.getP().bitLength();
  }
}
origin: casific/murmur

BigInteger xInverse = x.modInverse(DH_GROUP_PARAMETERS.getQ());
BigInteger i = iDoubleBlind.modPow(xInverse, DH_GROUP_PARAMETERS.getP());
origin: com.madgag.spongycastle/core

  public int hashCode()
  {
    int code = isPrivate() ? 0 : 1;
    
    if (params != null)
    {
      code ^= params.hashCode();
    }
    
    return code;
  }
}
origin: com.madgag.spongycastle/core

public DHParameters(
  BigInteger  p,
  BigInteger  g,
  BigInteger  q,
  int         l)
{
  this(p, g, q, getDefaultMParam(l), l, null, null);
}
org.spongycastle.crypto.paramsDHParameters

Most used methods

  • getG
  • getP
  • <init>
  • getL
    Return the private value length in bits - if set, zero otherwise
  • getQ
  • equals
  • getDefaultMParam
  • getM
    Return the minimum length of the private value.
  • hashCode

Popular in Java

  • Updating database using SQL prepared statement
  • getExternalFilesDir (Context)
  • onCreateOptionsMenu (Activity)
  • setContentView (Activity)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • LinkedHashMap (java.util)
    Hash table and linked list implementation of the Map interface, with predictable iteration order. Th
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JLabel (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now