Package java.math

Examples of java.math.BigInteger.bitLength()


          if (bigValue.bitLength() > 63) {
            throw new NumberFormatException(
              "Number out of range for 64-bit signed integer: " + text);
          }
        } else {
          if (bigValue.bitLength() > 64) {
            throw new NumberFormatException(
              "Number out of range for 64-bit unsigned integer: " + text);
          }
        }
      }
View Full Code Here


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

        // result is (t/d2) / (u'/d1)(v'/d2)
        BigInteger w = t.divide(BigInteger.valueOf(d2));
        if (w.bitLength() > 31) {
            throw new ArithmeticException
                ("overflow: numerator too large after multiply");
        }
        return new Fraction
            (w.intValue(),
View Full Code Here

     */
    public static boolean isPrivateKeyExtractable(final PrivateKey privK) {
        if ( privK instanceof RSAPrivateKey ) {
            final RSAPrivateKey rsa = (RSAPrivateKey)privK;
            final BigInteger result = rsa.getPrivateExponent();
            return result!=null && result.bitLength()>0;
        }
        if ( privK instanceof ECPrivateKey ) {
            final ECPrivateKey ec = (ECPrivateKey)privK;
            final BigInteger result = ec.getS();
            return result!=null && result.bitLength()>0;
View Full Code Here

            return result!=null && result.bitLength()>0;
        }
        if ( privK instanceof ECPrivateKey ) {
            final ECPrivateKey ec = (ECPrivateKey)privK;
            final BigInteger result = ec.getS();
            return result!=null && result.bitLength()>0;
        }
        if ( privK instanceof DHPrivateKey ) {
            final DHPrivateKey dh = (DHPrivateKey)privK;
            final BigInteger result = dh.getX();
            return result!=null && result.bitLength()>0;
View Full Code Here

            return result!=null && result.bitLength()>0;
        }
        if ( privK instanceof DHPrivateKey ) {
            final DHPrivateKey dh = (DHPrivateKey)privK;
            final BigInteger result = dh.getX();
            return result!=null && result.bitLength()>0;
        }
        if ( privK instanceof DSAPrivateKey) {
            final DSAPrivateKey dsa = (DSAPrivateKey)privK;
            final BigInteger result = dsa.getX();
            return result!=null && result.bitLength()>0;
View Full Code Here

            return result!=null && result.bitLength()>0;
        }
        if ( privK instanceof DSAPrivateKey) {
            final DSAPrivateKey dsa = (DSAPrivateKey)privK;
            final BigInteger result = dsa.getX();
            return result!=null && result.bitLength()>0;
        }
        return false;
    }
}
View Full Code Here

            PublicKey pk = cert.getPublicKey();
            if (pk instanceof RSAPublicKey) {
                RSAPublicKey rsapk = (RSAPublicKey) pk;
                assertEquals(rsapk.getAlgorithm(), "RSA");
                BigInteger modulus = rsapk.getModulus();
                int len = modulus.bitLength();
                assertEquals(1024, len);
            } else {
                assertTrue("Public key is not RSA", false);
            }
            assertTrue("CA is not valid for the specified duration.", CertTools.getNotAfter(cert).after(
View Full Code Here

            PublicKey pk = cert.getPublicKey();
            if (pk instanceof RSAPublicKey) {
                RSAPublicKey rsapk = (RSAPublicKey) pk;
                assertEquals(rsapk.getAlgorithm(), "RSA");
                BigInteger modulus = rsapk.getModulus();
                int len = modulus.bitLength();
                assertEquals(1024, len);
            } else {
                assertTrue("Public key is not RSA", false);
            }
            assertTrue("CA is not valid for the specified duration.", CertTools.getNotAfter(cert).after(
View Full Code Here

            PublicKey pk = cert.getPublicKey();
            if (pk instanceof RSAPublicKey) {
                RSAPublicKey rsapk = (RSAPublicKey) pk;
                assertEquals(rsapk.getAlgorithm(), "RSA");
                BigInteger modulus = rsapk.getModulus();
                int len = modulus.bitLength();
                assertEquals(1024, len);
            } else {
                assertTrue("Public key is not RSA", false);
            }
            assertTrue("CA is not valid for the specified duration.", CertTools.getNotAfter(cert).after(
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

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.