use of java.security.spec.RSAPublicKeySpec in project robovm by robovm.
the class CipherTest method testRSA_ECB_NoPadding_GetParameters_NoneProvided_Success.
private void testRSA_ECB_NoPadding_GetParameters_NoneProvided_Success(String provider) throws Exception {
KeyFactory kf = KeyFactory.getInstance("RSA");
RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(RSA_2048_modulus, RSA_2048_publicExponent);
final PublicKey pubKey = kf.generatePublic(pubKeySpec);
Cipher c = Cipher.getInstance("RSA/ECB/NoPadding", provider);
assertNull("Parameters should be null", c.getParameters());
}
use of java.security.spec.RSAPublicKeySpec in project robovm by robovm.
the class RSAPublicKeySpecTest method testGetPublicExponent.
/**
* Test for <code>getPublicExponent()</code> method<br>
* Assertion: returns public exponent
*/
public final void testGetPublicExponent() {
RSAPublicKeySpec rpks = new RSAPublicKeySpec(BigInteger.valueOf(3L), BigInteger.valueOf(1234567890L));
assertTrue(BigInteger.valueOf(1234567890L).equals(rpks.getPublicExponent()));
}
use of java.security.spec.RSAPublicKeySpec in project robovm by robovm.
the class RSAPublicKeySpecTest method testRSAPublicKeySpec02.
/**
* Test #2 for <code>RSAPublicKeySpec</code> constructor
* Assertion: Constructs <code>RSAPublicKeySpec</code>
* object using valid parameters
*/
public final void testRSAPublicKeySpec02() {
KeySpec ks = new RSAPublicKeySpec(null, null);
assertTrue(ks instanceof RSAPublicKeySpec);
}
use of java.security.spec.RSAPublicKeySpec in project JustAndroid by chinaltz.
the class AbRsa method getPublicKey.
/**
* 使用N、e值还原公钥
*
* @param modulus
* @param publicExponent
* @return
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
public static PublicKey getPublicKey(String modulus, String publicExponent) throws NoSuchAlgorithmException, InvalidKeySpecException {
BigInteger bigIntModulus = new BigInteger(modulus);
BigInteger bigIntPrivateExponent = new BigInteger(publicExponent);
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(bigIntModulus, bigIntPrivateExponent);
KeyFactory keyFactory = KeyFactory.getInstance(ALGORITHM);
PublicKey publicKey = keyFactory.generatePublic(keySpec);
return publicKey;
}
use of java.security.spec.RSAPublicKeySpec in project smartmodule by carozhu.
the class RSAUtils method getPublicKey.
/**
* 使用N、e值还原公钥
*
* @param modulus
* @param publicExponent
* @return
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
public static PublicKey getPublicKey(String modulus, String publicExponent) throws NoSuchAlgorithmException, InvalidKeySpecException {
BigInteger bigIntModulus = new BigInteger(modulus);
BigInteger bigIntPrivateExponent = new BigInteger(publicExponent);
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(bigIntModulus, bigIntPrivateExponent);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_PAIR);
PublicKey publicKey = keyFactory.generatePublic(keySpec);
return publicKey;
}
Aggregations