Search in sources :

Example 6 with MySignature1

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

the class SignatureTest method testInitSignPrivateKeySecureRandom.

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

Example 7 with MySignature1

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

the class SignatureTest method testGetAlgorithm.

public void testGetAlgorithm() {
    MySignature1 s = new MySignature1("ABC");
    assertEquals("state", MySignature1.UNINITIALIZED, s.getState());
    assertEquals("algorithm", "ABC", s.getAlgorithm());
}
Also used : MySignature1(org.apache.harmony.security.tests.support.MySignature1)

Example 8 with MySignature1

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

the class SignatureTest method testSign.

/*
     * Class under test for byte[] sign()
     */
public void testSign() throws Exception {
    MySignature1 s = new MySignature1("ABC");
    try {
        s.sign();
        fail("No expected SignatureException");
    } catch (SignatureException e) {
    }
    s.initVerify(new MyPublicKey());
    try {
        s.sign();
        fail("No expected SignatureException");
    } catch (SignatureException e) {
    }
    s.initSign(new MyPrivateKey());
    s.sign();
    assertEquals("state", MySignature1.SIGN, s.getState());
    assertTrue("sign() failed", s.runEngineSign);
}
Also used : MySignature1(org.apache.harmony.security.tests.support.MySignature1) SignatureException(java.security.SignatureException)

Example 9 with MySignature1

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

the class SignatureTest method testGetProvider.

public void testGetProvider() {
    MySignature1 s = new MySignature1("ABC");
    assertEquals("state", MySignature1.UNINITIALIZED, s.getState());
    assertNull("provider", s.getProvider());
}
Also used : MySignature1(org.apache.harmony.security.tests.support.MySignature1)

Example 10 with MySignature1

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

the class SignatureTest method testInitVerifyCertificate.

/*
     * Class under test for void initVerify(Certificate)
     */
public void testInitVerifyCertificate() throws InvalidKeyException {
    MySignature1 s = new MySignature1("ABC");
    s.initVerify(new MyCertificate());
    assertEquals("state", MySignature1.VERIFY, s.getState());
    assertTrue("initVerify() failed", s.runEngineInitVerify);
    try {
        Signature sig = getTestSignature();
        sig.initVerify(new MyCertificate());
        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)

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