Package java.math

Examples of java.math.BigInteger.bitLength()


    CVCertificate req = (CVCertificate)parsedObject;
    PublicKey pubKey = req.getCertificateBody().getPublicKey();
    assertNotNull(pubKey);
    assertEquals("CVC", pubKey.getFormat());
    BigInteger modulus = ((RSAPublicKey)pk).getModulus();
    int len = modulus.bitLength();
    assertEquals(1024, len);

    // Test verification of an authenticated request
    parsedObject = CertificateParser.parseCVCObject(cvcreqrenew);
    CVCAuthenticatedRequest authreq = (CVCAuthenticatedRequest)parsedObject;
View Full Code Here


    PublicKey pk = cert.getPublicKey();
    assertNotNull(pk);
    assertEquals("RSA", pk.getAlgorithm());
    if (pk instanceof RSAPublicKey) {
      BigInteger modulus = ((RSAPublicKey) pk).getModulus();
      int len = modulus.bitLength();
      assertEquals(1024, len);
    } else {
      assertTrue(false);
    }
    String subjectdn = CertTools.getSubjectDN(cert);
View Full Code Here

        q = params.getQ();
        g = params.getG();
        x = ((DSAPrivateKey) privateKey).getX();

        // checks described in DSA standard
        n = p.bitLength();
        if (p.compareTo(BigInteger.valueOf(1)) != 1 || n < 512 || n > 1024
                || (n & 077) != 0) {
            throw new InvalidKeyException(Messages.getString("security.169")); //$NON-NLS-1$
        }
        if (q.signum() != 1 && q.bitLength() != 160) {
View Full Code Here

        q = params.getQ();
        g = params.getG();
        y = ((DSAPublicKey) publicKey).getY();

        // checks described in DSA standard
        n1 = p.bitLength();
        if (p.compareTo(BigInteger.valueOf(1)) != 1 || n1 < 512 || n1 > 1024
                || (n1 & 077) != 0) {
            throw new InvalidKeyException(Messages.getString("security.169")); //$NON-NLS-1$
        }
        if (q.signum() != 1 || q.bitLength() != 160) {
View Full Code Here

        int tmodd1 = t.mod(BigInteger.valueOf(d1)).intValue();
        int d2 = (tmodd1==0)?d1:MathUtils.gcd(tmodd1, d1);

        // result is (t/d2) / (u'/d1)(v'/d2)
        BigInteger w = t.divide(BigInteger.valueOf(d2));
        if (w.bitLength() > 31) {
            throw MathRuntimeException.createArithmeticException(LocalizedFormats.NUMERATOR_OVERFLOW_AFTER_MULTIPLY,
                                                                 w);
        }
        return new Fraction (w.intValue(),
                MathUtils.mulAndCheck(denominator/d1,
View Full Code Here

        BigInteger oldRoot;
        BigInteger newRoot;
        BigInteger two = new BigInteger("2");

        BigInteger num = number;
        newRoot = num.shiftRight(num.bitLength() / 2);
        do {
            oldRoot = newRoot;
            newRoot = oldRoot.multiply(oldRoot).add(num).divide(oldRoot)
                    .divide(two);
        } while (newRoot.subtract(oldRoot).abs().compareTo(two) > 0);
View Full Code Here

            BigInteger h = e.multiply(BigInteger.valueOf(3));

            ECPoint R = this;

            for (int i = h.bitLength() - 2; i > 0; i--)
            {            
                R = R.twice();      

                if (h.testBit(i) && !e.testBit(i))
                {                   
View Full Code Here

        {
            // not properly initilaized... deal with it
        }
       
        BigInteger n = ((ECPrivateKeyParameters)this.key).getParameters().getN();
        int nBitLength = n.bitLength();
       
        BigInteger e = new BigInteger(1, digest);
        int eBitLength = e.bitLength();
       
        ECPrivateKeyParameters  privKey = (ECPrivateKeyParameters)key;
View Full Code Here

       
        BigInteger n = ((ECPrivateKeyParameters)this.key).getParameters().getN();
        int nBitLength = n.bitLength();
       
        BigInteger e = new BigInteger(1, digest);
        int eBitLength = e.bitLength();
       
        ECPrivateKeyParameters  privKey = (ECPrivateKeyParameters)key;
              
        if (eBitLength > nBitLength)
        {
View Full Code Here

            // not properly initilaized... deal with it
        }
       
        ECPublicKeyParameters pubKey = (ECPublicKeyParameters)key;
        BigInteger n = pubKey.getParameters().getN();
        int nBitLength = n.bitLength();
       
        BigInteger e = new BigInteger(1, digest);
        int eBitLength = e.bitLength();
       
        if (eBitLength > nBitLength)
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.