Search in sources :

Example 1 with MySignature1

use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.

the class SignatureTest method testInitSignPrivateKey.

/*
     * Class under test for void initSign(PrivateKey)
     */
public void testInitSignPrivateKey() throws InvalidKeyException {
    MySignature1 s = new MySignature1("ABC");
    s.initSign(new MyPrivateKey());
    assertEquals("state", MySignature1.SIGN, s.getState());
    assertTrue("initSign() failed", s.runEngineInitSign);
    try {
        Signature signature = getTestSignature();
        signature.initSign(null);
        fail("expected InvalidKeyException");
    } catch (InvalidKeyException e) {
    // ok
    } catch (NoSuchAlgorithmException e) {
        fail("unexpected: " + e);
    }
}
Also used : Signature(java.security.Signature) MySignature1(org.apache.harmony.security.tests.support.MySignature1) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException)

Example 2 with MySignature1

use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.

the class SignatureTest method testInitVerifyPublicKey.

/*
     * Class under test for void initVerify(PublicKey)
     */
public void testInitVerifyPublicKey() throws InvalidKeyException {
    MySignature1 s = new MySignature1("ABC");
    s.initVerify(new MyPublicKey());
    assertEquals("state", MySignature1.VERIFY, s.getState());
    assertTrue("initVerify() failed", s.runEngineInitVerify);
    try {
        Signature sig = getTestSignature();
        sig.initVerify((PublicKey) null);
    } catch (InvalidKeyException e) {
    // ok
    } catch (NoSuchAlgorithmException e) {
        fail("unexpected : " + e);
    }
}
Also used : Signature(java.security.Signature) MySignature1(org.apache.harmony.security.tests.support.MySignature1) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException)

Example 3 with MySignature1

use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.

the class SignatureTest method testUpdatebyte.

/*
     * Class under test for void update(byte)
     */
public void testUpdatebyte() throws Exception {
    MySignature1 s = new MySignature1("ABC");
    try {
        s.update((byte) 1);
        fail("No expected SignatureException");
    } catch (SignatureException e) {
    }
    s.initVerify(new MyPublicKey());
    s.update((byte) 1);
    s.initSign(new MyPrivateKey());
    s.update((byte) 1);
    assertEquals("state", MySignature1.SIGN, s.getState());
    assertTrue("update() failed", s.runEngineUpdate1);
    try {
        Signature sig = getTestSignature();
        sig.update((byte) 42);
        fail("expected SignatureException");
    } catch (SignatureException e) {
    // ok
    }
}
Also used : Signature(java.security.Signature) MySignature1(org.apache.harmony.security.tests.support.MySignature1) SignatureException(java.security.SignatureException)

Example 4 with MySignature1

use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.

the class SignatureTest method testVerifybyteArray.

/*
     * Class under test for boolean verify(byte[])
     */
public void testVerifybyteArray() throws Exception {
    MySignature1 s = new MySignature1("ABC");
    byte[] b = { 1, 2, 3, 4 };
    try {
        s.verify(b);
        fail("No expected SignatureException");
    } catch (SignatureException e) {
    }
    s.initSign(new MyPrivateKey());
    try {
        s.verify(b);
        fail("No expected SignatureException");
    } catch (SignatureException e) {
    }
    s.initVerify(new MyPublicKey());
    s.verify(b);
    assertEquals("state", MySignature1.VERIFY, s.getState());
    assertTrue("verify() failed", s.runEngineVerify);
}
Also used : MySignature1(org.apache.harmony.security.tests.support.MySignature1) SignatureException(java.security.SignatureException)

Example 5 with MySignature1

use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.

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
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) MySignature1(org.apache.harmony.security.tests.support.MySignature1)

Aggregations

MySignature1 (org.apache.harmony.security.tests.support.MySignature1)38 Signature (java.security.Signature)16 SignatureException (java.security.SignatureException)14 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)12 InvalidKeyException (java.security.InvalidKeyException)8 InvalidParameterException (java.security.InvalidParameterException)4 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)2 SecureRandom (java.security.SecureRandom)2 AlgorithmParameterSpec (java.security.spec.AlgorithmParameterSpec)2 KnownFailure (dalvik.annotation.KnownFailure)1