类java.security.spec.RSAMultiPrimePrivateCrtKeySpec源码实例Demo

下面列出了怎么用java.security.spec.RSAMultiPrimePrivateCrtKeySpec的API类实例代码及写法,或者点击链接到github查看源代码。

/**
 * Test #2 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: NullPointerException if modulus is null
 */
public final void testRSAMultiPrimePrivateCrtKeySpec02() {
    try {
        new RSAMultiPrimePrivateCrtKeySpec(
                null,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
/**
 * Test #3 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: NullPointerException if publicExponent is null
 */
public final void testRSAMultiPrimePrivateCrtKeySpec03() {
    try {
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                null,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
/**
 * Test #4 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: NullPointerException if privateExponent is null
 */
public final void testRSAMultiPrimePrivateCrtKeySpec04() {
    try {
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                null,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
/**
 * Test #5 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: NullPointerException if primeP is null
 */
public final void testRSAMultiPrimePrivateCrtKeySpec05() {
    try {
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                null,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
/**
 * Test #6 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: NullPointerException if primeQ is null
 */
public final void testRSAMultiPrimePrivateCrtKeySpec06() {
    try {
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                null,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
/**
 * Test #7 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: NullPointerException if primeExponentP is null
 */
public final void testRSAMultiPrimePrivateCrtKeySpec07() {
    try {
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                null,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
/**
 * Test #8 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: NullPointerException if primeExponentQ is null
 */
public final void testRSAMultiPrimePrivateCrtKeySpec08() {
    try {
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                null,
                BigInteger.ONE,
                opi);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
/**
 * Test #9 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: NullPointerException if crtCoefficient is null
 */
public final void testRSAMultiPrimePrivateCrtKeySpec09() {
    try {
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                null,
                opi);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
/**
 * Test #10 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: otherPrimeInfo can be null
 */
public final void testRSAMultiPrimePrivateCrtKeySpec10() {
    try {
        new RSAMultiPrimePrivateCrtKeySpec(
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            null);
    } catch (Exception e) {
        fail("Unexpected exception is thrown");
    }
}
 
/**
 * Test #11 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: IllegalArgumentException if otherPrimeInfo length is 0
 */
public final void testRSAMultiPrimePrivateCrtKeySpec11() {
    try {
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                new RSAOtherPrimeInfo[0]);
        fail("Expected IAE not thrown");
    } catch (IllegalArgumentException e) {
    }
}
 
/**
 * Tests that internal state of the object
 * can not be modified by modifying initial array
 */
public final void testIsStatePreserved1() {
    // Create initial array
    RSAOtherPrimeInfo[] opi1 = opi.clone();

    RSAMultiPrimePrivateCrtKeySpec ks = new RSAMultiPrimePrivateCrtKeySpec(
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            opi1);

    // Modify initial array
    opi1[2] = new RSAOtherPrimeInfo(BigInteger.ZERO,
                                    BigInteger.ZERO,
                                    BigInteger.ZERO);

    // Check that above modification
    // does not affect internal state
    assertTrue(checkOtherPrimeInfo(ks.getOtherPrimeInfo()));
}
 
源代码12 项目: Android_Code_Arbiter   文件: ConstantPasswords.java
public void bad10() throws Exception {
    BigInteger bigInteger = new BigInteger("12345", 5);
    new DSAPrivateKeySpec(bigInteger, null, null, null);
    new DSAPublicKeySpec(bigInteger, null, bigInteger, null); // report once
    new DHPrivateKeySpec(bigInteger, null, null);
    new DHPublicKeySpec(bigInteger, null, null);
    new ECPrivateKeySpec(bigInteger, null);
    new RSAPrivateKeySpec(bigInteger, null);
    new RSAMultiPrimePrivateCrtKeySpec(bigInteger, null, null, null, null, null, null, null, null);
    new RSAPrivateCrtKeySpec(bigInteger, null, null, null, null, null, null, null);
    new RSAPublicKeySpec(bigInteger, null);
    new DSAPublicKeyImpl(bigInteger, null, null, null);
}
 
/**
 * Test for <code>getCrtCoefficient()</code> method<br>
 * Assertion: returns crt coefficient
 */
public final void testGetCrtCoefficient() {
    RSAMultiPrimePrivateCrtKeySpec ks =
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
    assertTrue(BigInteger.ONE.equals(ks.getCrtCoefficient()));
}
 
/**
 * Test for <code>getPrimeExponentP()</code> method<br>
 * Assertion: returns prime exponent P
 */
public final void testGetPrimeExponentP() {
    RSAMultiPrimePrivateCrtKeySpec ks =
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
    assertTrue(BigInteger.ONE.equals(ks.getPrimeExponentP()));
}
 
/**
 * Test for <code>getPrimeExponentQ()</code> method<br>
 * Assertion: returns prime exponent Q
 */
public final void testGetPrimeExponentQ() {
    RSAMultiPrimePrivateCrtKeySpec ks =
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
    assertTrue(BigInteger.ONE.equals(ks.getPrimeExponentQ()));
}
 
/**
 * Test for <code>getPrimeP()</code> method<br>
 * Assertion: returns prime P
 */
public final void testGetPrimeP() {
    RSAMultiPrimePrivateCrtKeySpec ks =
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
    assertTrue(BigInteger.ONE.equals(ks.getPrimeP()));
}
 
/**
 * Test for <code>getPrimeQ()</code> method<br>
 * Assertion: returns prime Q
 */
public final void testGetPrimeQ() {
    RSAMultiPrimePrivateCrtKeySpec ks =
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
    assertTrue(BigInteger.ONE.equals(ks.getPrimeQ()));
}
 
/**
 * Test for <code>getPublicExponent()</code> method<br>
 * Assertion: returns public exponent
 */
public final void testGetPublicExponent() {
    RSAMultiPrimePrivateCrtKeySpec ks =
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
    assertTrue(BigInteger.ONE.equals(ks.getPublicExponent()));
}
 
/**
 * Test #1 for <code>getOtherPrimeInfo()</code> method<br>
 * Assertion: returns array of RSAOtherPrimeInfo
 */
public final void testGetOtherPrimeInfo01() {
    RSAMultiPrimePrivateCrtKeySpec ks =
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
    assertTrue(checkOtherPrimeInfo(ks.getOtherPrimeInfo()));
}
 
/**
 * Test #2 for <code>getOtherPrimeInfo()</code> method<br>
 * Assertion: returns null if null has been passed to the
 * constructor as otherPrimeInfo parameter
 */
public final void testGetOtherPrimeInfo02() {
    RSAMultiPrimePrivateCrtKeySpec ks =
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                null);
    assertNull(ks.getOtherPrimeInfo());
}
 
/**
 * Tests that internal state of the object
 * can not be modified using array reference
 * returned by <code>getOtherPrimeInfo()</code>
 * method
 */
public final void testIsStatePreserved2() {
    // Create initial array
    RSAOtherPrimeInfo[] opi1 = opi.clone();

    RSAMultiPrimePrivateCrtKeySpec ks = new RSAMultiPrimePrivateCrtKeySpec(
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            opi1);

    RSAOtherPrimeInfo[] ret = ks.getOtherPrimeInfo();

    // Modify returned array
    ret[2] = new RSAOtherPrimeInfo(BigInteger.ZERO,
            BigInteger.ZERO,
            BigInteger.ZERO);

    // Check that above modification
    // does not affect internal state
    assertTrue(checkOtherPrimeInfo(ks.getOtherPrimeInfo()));
}
 
/**
 * Test for <code>getModulus()</code> method<br>
 * Assertion: returns modulus
 */
public final void testGetModulus() {
    RSAMultiPrimePrivateCrtKeySpec ks =
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
    assertTrue(BigInteger.ONE.equals(ks.getModulus()));
}
 
/**
 * Test for <code>getPrivateExponent()</code> method<br>
 * Assertion: returns private exponent
 */
public final void testGetPrivateExponent() {
    RSAMultiPrimePrivateCrtKeySpec ks =
        new RSAMultiPrimePrivateCrtKeySpec(
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                BigInteger.ONE,
                opi);
    assertTrue(BigInteger.ONE.equals(ks.getPrivateExponent()));
}
 
/**
 * Test #1 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: constructs <code>RSAMultiPrimePrivateCrtKeySpec</code>
 * object using valid parameters
 */
public final void testRSAMultiPrimePrivateCrtKeySpec01() {
    KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec(
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            opi);
    assertTrue(ks instanceof RSAMultiPrimePrivateCrtKeySpec);
}
 
/**
 * Test #12 for
 * <code>RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
 *                                      BigInteger publicExponent,
 *                                      BigInteger privateExponent,
 *                                      BigInteger primeP,
 *                                      BigInteger primeQ,
 *                                      BigInteger primeExponentP,
 *                                      BigInteger primeExponentQ,
 *                                      BigInteger crtCoefficient,
 *                                      RSAOtherPrimeInfo[] otherPrimeInfo)
 * </code> ctor<br>
 * Assertion: constructs <code>RSAMultiPrimePrivateCrtKeySpec</code>
 * object using valid parameters. Constructed object must be
 * instance of RSAPrivateKeySpec.
 */
public final void testRSAMultiPrimePrivateCrtKeySpec12() {
    KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec(
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            BigInteger.ONE,
            opi);
    assertTrue(ks instanceof RSAPrivateKeySpec);
}