use of java.security.spec.KeySpec in project robovm by robovm.
the class RSAPrivateCrtKeySpecTest method testRSAPrivateCrtKeySpec02.
/**
* Test #2 for <code>RSAPrivateCrtKeySpec</code> constructor
* Assertion: Constructs <code>RSAPrivateCrtKeySpec</code>
* object using valid parameters
*/
public final void testRSAPrivateCrtKeySpec02() {
KeySpec ks = new RSAPrivateCrtKeySpec(BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, BigInteger.ONE);
assertTrue(ks instanceof RSAPrivateKeySpec);
}
use of java.security.spec.KeySpec in project robovm by robovm.
the class RSAPrivateKeySpecTest method testRSAPrivateKeySpec.
/**
* Test for <code>RSAPrivateKeySpec(BigInteger,BigInteger)</code> ctor
* Assertion: constructs <code>RSAPrivateKeySpec</code>
* object using valid parameters
*/
public final void testRSAPrivateKeySpec() {
KeySpec ks = new RSAPrivateKeySpec(BigInteger.valueOf(1234567890L), BigInteger.valueOf(3L));
assertTrue(ks instanceof RSAPrivateKeySpec);
}
use of java.security.spec.KeySpec in project robovm by robovm.
the class RSAPublicKeySpecTest method testRSAPublicKeySpec01.
/**
* Test #1 for <code>RSAPublicKeySpec</code> constructor
* Assertion: Constructs <code>RSAPublicKeySpec</code>
* object using valid parameters
*/
public final void testRSAPublicKeySpec01() {
KeySpec ks = new RSAPublicKeySpec(BigInteger.valueOf(1234567890L), BigInteger.valueOf(3L));
assertTrue(ks instanceof RSAPublicKeySpec);
}
use of java.security.spec.KeySpec in project platform_frameworks_base by android.
the class BackupManagerService method buildCharArrayKey.
private SecretKey buildCharArrayKey(String algorithm, char[] pwArray, byte[] salt, int rounds) {
try {
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(algorithm);
KeySpec ks = new PBEKeySpec(pwArray, salt, rounds, PBKDF2_KEY_SIZE);
return keyFactory.generateSecret(ks);
} catch (InvalidKeySpecException e) {
Slog.e(TAG, "Invalid key spec for PBKDF2!");
} catch (NoSuchAlgorithmException e) {
Slog.e(TAG, "PBKDF2 unavailable!");
}
return null;
}
use of java.security.spec.KeySpec in project XobotOS by xamarin.
the class JCESecretKeyFactory method engineGetKeySpec.
protected KeySpec engineGetKeySpec(SecretKey key, Class keySpec) throws InvalidKeySpecException {
if (keySpec == null) {
throw new InvalidKeySpecException("keySpec parameter is null");
}
if (key == null) {
throw new InvalidKeySpecException("key parameter is null");
}
if (SecretKeySpec.class.isAssignableFrom(keySpec)) {
return new SecretKeySpec(key.getEncoded(), algName);
}
try {
Class[] parameters = { byte[].class };
Constructor c = keySpec.getConstructor(parameters);
Object[] p = new Object[1];
p[0] = key.getEncoded();
return (KeySpec) c.newInstance(p);
} catch (Exception e) {
throw new InvalidKeySpecException(e.toString());
}
}
Aggregations