Examples of modPow()


Examples of java.math.BigInteger.modPow()

                HBCIUtils.log("decrypting message key with (n,d)-algorithm",HBCIUtils.LOG_DEBUG);
                BigInteger exponent=((RSAPrivateKey)(k)).getPrivateExponent();
                BigInteger modulus=((RSAPrivateKey)(k)).getModulus();

                BigInteger c=new BigInteger(+1,cryptedKey);
                plainKey=c.modPow(exponent,modulus).toByteArray();
            } else {
                HBCIUtils.log("decrypting message key with (p,q,dP,dQ,qInv)-algorithm",HBCIUtils.LOG_DEBUG);
                BigInteger p=((RSAPrivateCrtKey2)k).getP();
                BigInteger q=((RSAPrivateCrtKey2)k).getQ();
                BigInteger dP=((RSAPrivateCrtKey2)k).getdP();
View Full Code Here

Examples of java.math.BigInteger.modPow()

            final BigInteger p) throws Exception {
        BigInteger privateKey = BigInteger.valueOf((new SecureRandom().nextInt(Integer.MAX_VALUE)));
        BigInteger privateKeyModPow = g.modPow(privateKey, p);
        this.writeBigInteger(privateKeyModPow, out);
        BigInteger privateKeyModPowOther = this.readBigInteger(in);
        this.sharedKey = privateKeyModPowOther.modPow(privateKey, p);
    }

    private void writeBigInteger(final BigInteger toWrite, final OutputStream out) throws Exception {
        ObjectOutputStream objectOutput = new ObjectOutputStream(out);
        byte[] bigIntBytes = toWrite.toByteArray();
View Full Code Here

Examples of java.math.BigInteger.modPow()

  public void testMod() {
    final BigInteger TWO = BigInteger.ONE.add(BigInteger.ONE);
    for(long n = 3; n < 100; n++) {
      for (long e = 1; e < 100; e++) {
        final long r = TWO.modPow(
            BigInteger.valueOf(e), BigInteger.valueOf(n)).longValue();
        assertEquals("e=" + e + ", n=" + n, r, BaileyBorweinPlouffe.mod(e, n));
      }
    }
  }
View Full Code Here

Examples of java.math.BigInteger.modPow()

      final BigInteger N = BigInteger.valueOf(n);
      for(int j = 1; j < rn[i].length; j++) {
        final long r = rn[i][j][0];
        final long answer = rn[i][j][1];
        final BigInteger R = BigInteger.valueOf(r);
        final long s = R.modPow(TWO, N).longValue();
        if (s != answer)
          assertEquals("r=" + r + ", n=" + n + ", answer=" + answer + " but s=" + s, answer, s);
      }
    }
    t.tick("R.modPow(TWO, N)");
View Full Code Here

Examples of java.math.BigInteger.modPow()

    {
      log.log(20, "ssh-rsa signature: rsa_block_len < 1");
      return false;
    }

    byte[] v = s.modPow(e, n).toByteArray();

    int startpos = 0;

    if ((v.length > 0) && (v[0] == 0x00))
      startpos++;
View Full Code Here

Examples of java.math.BigInteger.modPow()

    public boolean verify(Coin coin)
      throws NoSuchAlgorithmException {
  BigInteger t=coin.generateCoinNumber(this);
  if(t == null)
      return false;
  t=t.modPow(getPrivateKey(),getPrime());
  Util.dumpNumber("y^k=      ",t);

  return t.equals(coin.getSignature());
    }
View Full Code Here

Examples of java.math.BigInteger.modPow()

        // Handbook of Applied Cryptography 4.86
        do
        {
            g = BigIntegers.createRandomInRange(TWO, pMinusTwo, random);
        }
        while (g.modPow(TWO, p).equals(ONE)
            || g.modPow(q, p).equals(ONE));

/*
        // RFC 2631 2.1.1 (and see Handbook of Applied Cryptography 4.81)
        do
View Full Code Here

Examples of java.math.BigInteger.modPow()

        do
        {
            g = BigIntegers.createRandomInRange(TWO, pMinusTwo, random);
        }
        while (g.modPow(TWO, p).equals(ONE)
            || g.modPow(q, p).equals(ONE));

/*
        // RFC 2631 2.1.1 (and see Handbook of Applied Cryptography 4.81)
        do
        {
View Full Code Here

Examples of java.math.BigInteger.modPow()

    {
      log.warning("ssh-rsa signature: rsa_block_len < 1");
      return false;
    }

    byte[] v = s.modPow(e, n).toByteArray();

    int startpos = 0;

    if ((v.length > 0) && (v[0] == 0x00))
      startpos++;
View Full Code Here

Examples of java.math.BigInteger.modPow()

        //
        for (;;)
        {
            g = new BigInteger(qLength, random);

            if (g.modPow(TWO, p).equals(ONE))
            {
                continue;
            }

            if (g.modPow(q, p).equals(ONE))
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.