use of java.security.Signature in project robovm by robovm.
the class Signature2Test method test_initSignLjava_security_PrivateKeyLjava_security_SecureRandom_mismatch.
public void test_initSignLjava_security_PrivateKeyLjava_security_SecureRandom_mismatch() throws Exception {
try {
Signature sig = Signature.getInstance("DSA");
sig.initSign(getRsaKeys().getPrivate(), new SecureRandom());
fail();
} catch (InvalidKeyException expected) {
}
}
use of java.security.Signature in project robovm by robovm.
the class Signature2Test method test_verify$B.
/**
* java.security.Signature#verify(byte[])
*/
public void test_verify$B() throws Exception {
Signature sig = Signature.getInstance("DSA");
try {
sig.verify(new byte[] { 0, 1, 2, 3 });
fail();
} catch (SignatureException expected) {
}
sig.initSign(getDsaKeys().getPrivate());
sig.update(MESSAGE.getBytes());
byte[] signature = sig.sign();
sig.initVerify(getDsaKeys().getPublic());
sig.update(MESSAGE.getBytes());
assertTrue("Sign/Verify does not pass", sig.verify(signature));
}
use of java.security.Signature in project robovm by robovm.
the class Signature2Test method test_getInstanceLjava_lang_StringLjava_lang_String_java_security_Provider.
/**
* java.security.Signature#getInstance(java.lang.String,
* java.security.Provider)
*/
public void test_getInstanceLjava_lang_StringLjava_lang_String_java_security_Provider() throws Exception {
Provider[] providers = Security.getProviders("Signature.DSA");
for (int i = 0; i < providers.length; i++) {
Signature signature = Signature.getInstance("DSA", providers[i]);
assertEquals("DSA", signature.getAlgorithm());
assertEquals(providers[i], signature.getProvider());
}
try {
Signature.getInstance((String) null, (Provider) null);
fail();
} catch (NullPointerException expected) {
}
try {
Signature.getInstance("DSA", (Provider) null);
fail();
} catch (IllegalArgumentException expected) {
}
try {
Signature.getInstance((String) null, providers[0]);
fail();
} catch (NullPointerException expected) {
}
try {
Signature.getInstance("bogus", providers[0]);
fail();
} catch (NoSuchAlgorithmException expected) {
}
}
use of java.security.Signature in project robovm by robovm.
the class Signature2Test method test_initSignLjava_security_PrivateKeyLjava_security_SecureRandom.
public void test_initSignLjava_security_PrivateKeyLjava_security_SecureRandom() throws Exception {
Signature sig = Signature.getInstance("DSA");
sig.initSign(getDsaKeys().getPrivate(), new SecureRandom());
}
use of java.security.Signature in project robovm by robovm.
the class Signature2Test method test_getParameterLjava_lang_String.
/**
* java.security.Signature#getParameter(java.lang.String)
*/
@SuppressWarnings("deprecation")
public void test_getParameterLjava_lang_String() throws Exception {
Signature sig = Signature.getInstance("DSA");
try {
sig.getParameter("r");
sig.getParameter("s");
} catch (UnsupportedOperationException e) {
}
}
Aggregations