java.security.spec.RSAOtherPrimeInfo Java Examples

The following examples show how to use java.security.spec.RSAOtherPrimeInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RSAMultiPrimePrivateCrtKeySpecTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * 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()));
}
 
Example #2
Source File: RSAMultiPrimePrivateCrtKeySpecTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * 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) {
    }
}
 
Example #3
Source File: RSAMultiPrimePrivateCrtKeySpecTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: RsaPrivateKeyDef.java    From swim with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #5
Source File: RSAMultiPrimePrivateCrtKeySpecTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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()));
}
 
Example #6
Source File: RSAOtherPrimeInfoTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example #7
Source File: RSAOtherPrimeInfoTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example #8
Source File: RSAOtherPrimeInfoTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example #9
Source File: RSAOtherPrimeInfoTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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) {
    }
}
 
Example #10
Source File: RSAOtherPrimeInfoTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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) {
    }
}
 
Example #11
Source File: RSAOtherPrimeInfoTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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) {
    }
}
 
Example #12
Source File: RSAOtherPrimeInfoTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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) {
    }
}
 
Example #13
Source File: RSAOtherPrimeInfoTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #14
Source File: RsaPrimeDef.java    From swim with Apache License 2.0 4 votes vote down vote up
public final RSAOtherPrimeInfo toRSAOtherPrimeInfo() {
  return new RSAOtherPrimeInfo(this.factor, this.exponent, this.coefficient);
}
 
Example #15
Source File: RsaPrimeDef.java    From swim with Apache License 2.0 4 votes vote down vote up
public static RsaPrimeDef from(RSAOtherPrimeInfo info) {
  return new RsaPrimeDef(info.getPrime(), info.getExponent(), info.getCrtCoefficient());
}
 
Example #16
Source File: RSAMultiPrimePrivateCrtKey.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #17
Source File: RSAMultiPrimePrivateCrtKey.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #18
Source File: RSAMultiPrimePrivateCrtKey.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #19
Source File: RSAMultiPrimePrivateCrtKey.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #20
Source File: RSAMultiPrimePrivateCrtKey.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #21
Source File: RSAMultiPrimePrivateCrtKey.java    From JDKSourceCode1.8 with MIT License 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #22
Source File: RSAMultiPrimePrivateCrtKey.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #23
Source File: RSAMultiPrimePrivateCrtKey.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #24
Source File: RSAMultiPrimePrivateCrtKey.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #25
Source File: RSAMultiPrimePrivateCrtKey.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #26
Source File: RSAMultiPrimePrivateCrtKey.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #27
Source File: RSAMultiPrimePrivateCrtKey.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #28
Source File: RSAMultiPrimePrivateCrtKey.java    From j2objc with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #29
Source File: RSAMultiPrimePrivateCrtKey.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();
 
Example #30
Source File: RSAMultiPrimePrivateCrtKey.java    From jdk-1.7-annotated with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the otherPrimeInfo or null if there are only
 * two prime factors (p and q).
 *
 * @return the otherPrimeInfo.
 */
public RSAOtherPrimeInfo[] getOtherPrimeInfo();