Search in sources :

Example 16 with MySignature1

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

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 17 with MySignature1

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

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 18 with MySignature1

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

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);
    }
}
Also used : InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) Signature(java.security.Signature) MySignature1(org.apache.harmony.security.tests.support.MySignature1) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) AlgorithmParameterSpec(java.security.spec.AlgorithmParameterSpec)

Example 19 with MySignature1

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

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 20 with MySignature1

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

the class SignatureTest method testSetParameterStringObject.

/*
     * Class under test for void setParameter(String, Object)
     */
@SuppressWarnings("deprecation")
public void testSetParameterStringObject() {
    MySignature1 s = new MySignature1("ABC");
    s.setParameter("aaa", new Object());
    try {
        Signature sig = getTestSignature();
        sig.setParameter("TestParam", new Integer(42));
        fail("expected InvalidParameterException");
    } catch (InvalidParameterException e) {
    // expected
    } catch (NoSuchAlgorithmException e) {
        fail("unexpected: " + e);
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Signature(java.security.Signature) MySignature1(org.apache.harmony.security.tests.support.MySignature1) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

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