use of org.apache.harmony.security.tests.support.MySignature1 in project j2objc by google.
the class SignatureTest method testVerifybyteArrayintint.
/*
* Class under test for boolean verify(byte[], int, int)
*/
public void testVerifybyteArrayintint() throws Exception {
MySignature1 s = new MySignature1("ABC");
byte[] b = { 1, 2, 3, 4 };
try {
s.verify(b, 0, 3);
fail("No expected SignatureException");
} catch (SignatureException e) {
}
s.initSign(new MyPrivateKey());
try {
s.verify(b, 0, 3);
fail("No expected SignatureException");
} catch (SignatureException e) {
}
s.initVerify(new MyPublicKey());
try {
s.verify(b, 0, 5);
fail("No expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
}
s.verify(b, 0, 3);
assertEquals("state", MySignature1.VERIFY, s.getState());
assertTrue("verify() failed", s.runEngineVerify);
}
use of org.apache.harmony.security.tests.support.MySignature1 in project j2objc by google.
the class SignatureTest method testGetParameter.
@SuppressWarnings("deprecation")
public void testGetParameter() {
MySignature1 s = new MySignature1("ABC");
s.getParameter("aaa");
try {
MySignature se = new MySignature();
se.getParameter("test");
} catch (InvalidParameterException e) {
// ok
}
}
use of org.apache.harmony.security.tests.support.MySignature1 in project j2objc by google.
the class SignatureTest method testConstructor.
/*
* Class under test for Signature(String)
*/
public void testConstructor() {
String[] algorithms = { "SHA256WITHRSA", "NONEWITHDSA", "SHA384WITHRSA", "MD5ANDSHA1WITHRSA", "SHA512WITHRSA", "SHA1WITHRSA", "SHA1WITHDSA", "MD5WITHRSA" };
for (int i = 0; i < algorithms.length; i++) {
MySignature1 s = new MySignature1(algorithms[i]);
assertEquals(algorithms[i], s.getAlgorithm());
assertNull(s.getProvider());
assertEquals(0, s.getState());
}
MySignature1 s1 = new MySignature1(null);
assertNull(s1.getAlgorithm());
assertNull(s1.getProvider());
assertEquals(0, s1.getState());
MySignature1 s2 = new MySignature1("ABCD@#&^%$)(*&");
assertEquals("ABCD@#&^%$)(*&", s2.getAlgorithm());
assertNull(s2.getProvider());
assertEquals(0, s2.getState());
}
use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.
the class SignatureTest method testVerifybyteArrayintint.
/*
* Class under test for boolean verify(byte[], int, int)
*/
public void testVerifybyteArrayintint() throws Exception {
MySignature1 s = new MySignature1("ABC");
byte[] b = { 1, 2, 3, 4 };
try {
s.verify(b, 0, 3);
fail("No expected SignatureException");
} catch (SignatureException e) {
}
s.initSign(new MyPrivateKey());
try {
s.verify(b, 0, 3);
fail("No expected SignatureException");
} catch (SignatureException e) {
}
s.initVerify(new MyPublicKey());
try {
s.verify(b, 0, 5);
fail("No expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
}
s.verify(b, 0, 3);
assertEquals("state", MySignature1.VERIFY, s.getState());
assertTrue("verify() failed", s.runEngineVerify);
}
use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.
the class SignatureTest method testSetParameterAlgorithmParameterSpec.
/*
* Class under test for void setParameter(AlgorithmParameterSpec)
*/
public void testSetParameterAlgorithmParameterSpec() throws InvalidAlgorithmParameterException {
MySignature1 s = new MySignature1("ABC");
try {
s.setParameter((java.security.spec.AlgorithmParameterSpec) null);
fail("No expected UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
}
try {
Signature sig = getTestSignature();
sig.setParameter(new AlgorithmParameterSpec() {
});
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected: " + e);
} catch (NoSuchAlgorithmException e) {
fail("unexpected: " + e);
}
}
Aggregations