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

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

/**
 * 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()));
}
 
源代码3 项目: swim   文件: RsaPrivateKeyDef.java
private static RsaPrivateKeyDef from(RSAMultiPrimePrivateCrtKey key) {
  FingerTrieSeq<RsaPrimeDef> primeDefs = FingerTrieSeq.empty();
  primeDefs = primeDefs.appended(new RsaPrimeDef(key.getPrimeP(), key.getPrimeExponentP()));
  primeDefs = primeDefs.appended(new RsaPrimeDef(key.getPrimeQ(), key.getPrimeExponentQ(), key.getCrtCoefficient()));
  final RSAOtherPrimeInfo[] otherPrimes = key.getOtherPrimeInfo();
  for (int i = 0, n = otherPrimes.length; i < n; i += 1) {
    primeDefs = primeDefs.appended(RsaPrimeDef.from(otherPrimes[i]));
  }
  return new RsaPrivateKeyDef(key.getModulus(), key.getPublicExponent(), key.getPrivateExponent(), primeDefs, key);
}
 
源代码4 项目: j2objc   文件: RSAOtherPrimeInfoTest.java
/**
 * Test #1 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
 * Assertion: constructs <code>RSAOtherPrimeInfo</code>
 * object using valid parameter
 */
public final void testRSAOtherPrimeInfo01() {
    Object o =
        new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
                              BigInteger.valueOf(2L),
                              BigInteger.valueOf(3L));
    assertTrue(o instanceof RSAOtherPrimeInfo);
}
 
源代码5 项目: j2objc   文件: RSAOtherPrimeInfoTest.java
/**
 * Test #2 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
 * Assertion: NullPointerException if prime is null
 */
public final void testRSAOtherPrimeInfo02() {
    try {
        new RSAOtherPrimeInfo(null,
                              BigInteger.valueOf(2L),
                              BigInteger.valueOf(3L));
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
源代码6 项目: j2objc   文件: RSAOtherPrimeInfoTest.java
/**
 * Test #3 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
 * Assertion: NullPointerException if primeExponent is null
 */
public final void testRSAOtherPrimeInfo03() {
    try {
        new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
                              null,
                              BigInteger.valueOf(3L));
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
源代码7 项目: j2objc   文件: RSAOtherPrimeInfoTest.java
/**
 * Test #4 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
 * Assertion: NullPointerException if crtCoefficient is null
 */
public final void testRSAOtherPrimeInfo04() {
    try {
        new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
                              BigInteger.valueOf(2L),
                              null);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
源代码8 项目: j2objc   文件: RSAOtherPrimeInfoTest.java
/**
 * Test #5 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
 * Assertion: NullPointerException if prime and crtCoefficient is null
 */
public final void testRSAOtherPrimeInfo05() {
    try {
        new RSAOtherPrimeInfo(null,
                              BigInteger.valueOf(2L),
                              null);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
 
源代码9 项目: j2objc   文件: RSAOtherPrimeInfoTest.java
/**
 * Test for <code>getCrtCoefficient()</code> method<br>
 * Assertion: returns CRT coefficient value
 */
public final void testGetCrtCoefficient() {
    RSAOtherPrimeInfo ropi =
        new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
                              BigInteger.valueOf(2L),
                              BigInteger.valueOf(3L));
    assertEquals(3L, ropi.getCrtCoefficient().longValue());
}
 
源代码10 项目: j2objc   文件: RSAOtherPrimeInfoTest.java
/**
 * Test for <code>getPrime()</code> method<br>
 * Assertion: returns prime value
 */
public final void testGetPrime() {
    RSAOtherPrimeInfo ropi =
        new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
                              BigInteger.valueOf(2L),
                              BigInteger.valueOf(3L));
    assertEquals(1L, ropi.getPrime().longValue());
}
 
源代码11 项目: j2objc   文件: RSAOtherPrimeInfoTest.java
/**
 * Test for <code>getExponent()</code> method<br>
 * Assertion: returns prime exponent value
 */
public final void testGetExponent() {
    RSAOtherPrimeInfo ropi =
        new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
                              BigInteger.valueOf(2L),
                              BigInteger.valueOf(3L));
    assertEquals(2L, ropi.getExponent().longValue());
}
 
/**
 * 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()));
}
 
/**
 * Compares array passed as a parameter with reference one<br>
 *
 *  <code>private static final RSAOtherPrimeInfo[] opi</code>
 *
 * @param toBeChecked
 *  Array to be compared
 * @return
 *  true if arrays are equal
 */
private boolean checkOtherPrimeInfo(RSAOtherPrimeInfo[] toBeChecked) {
    if (toBeChecked == null || toBeChecked.length != opi.length) {
        return false;
    }
    for (int i=0; i<opi.length; i++) {
        if (opi[i].getPrime().equals(toBeChecked[i].getPrime()) &&
            opi[i].getExponent().equals(toBeChecked[i].getExponent()) &&
            opi[i].getCrtCoefficient().equals(toBeChecked[i].getCrtCoefficient())) {
            continue;
        }
        return false;
    }
    return true;
}
 
源代码14 项目: swim   文件: RsaPrimeDef.java
public static RsaPrimeDef from(RSAOtherPrimeInfo info) {
  return new RsaPrimeDef(info.getPrime(), info.getExponent(), info.getCrtCoefficient());
}
 
源代码15 项目: swim   文件: RsaPrimeDef.java
public final RSAOtherPrimeInfo toRSAOtherPrimeInfo() {
  return new RSAOtherPrimeInfo(this.factor, this.exponent, this.coefficient);
}
 
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
源代码18 项目: TencentKona-8   文件: RSAMultiPrimePrivateCrtKey.java
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
源代码19 项目: jdk8u60   文件: RSAMultiPrimePrivateCrtKey.java
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
源代码21 项目: openjdk-jdk8u   文件: RSAMultiPrimePrivateCrtKey.java
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
源代码23 项目: Bytecoder   文件: RSAMultiPrimePrivateCrtKey.java
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
源代码24 项目: openjdk-jdk9   文件: RSAMultiPrimePrivateCrtKey.java
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
源代码25 项目: jdk8u-jdk   文件: RSAMultiPrimePrivateCrtKey.java
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
源代码26 项目: Java8CN   文件: RSAMultiPrimePrivateCrtKey.java
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
源代码27 项目: hottub   文件: RSAMultiPrimePrivateCrtKey.java
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
源代码29 项目: openjdk-8   文件: RSAMultiPrimePrivateCrtKey.java
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
源代码30 项目: jdk8u_jdk   文件: RSAMultiPrimePrivateCrtKey.java
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();