Index: C:/harmony/trunk_0427/modules/security/src/test/api/java.injected/java/security/SignatureTest.java =================================================================== --- C:/harmony/trunk_0427/modules/security/src/test/api/java.injected/java/security/SignatureTest.java (revision 418179) +++ C:/harmony/trunk_0427/modules/security/src/test/api/java.injected/java/security/SignatureTest.java (working copy) @@ -24,6 +24,8 @@ import org.apache.harmony.security.tests.support.MySignature1; import junit.framework.TestCase; +import java.security.interfaces.RSAPrivateCrtKey; +import java.math.BigInteger; /** * Tests for Signature constructor and methods @@ -133,6 +135,15 @@ if (!s.runEngineInitSign) { fail("initSign() failed"); } + + try { + Signature sig = Signature.getInstance("SHA1withRSA"); + sig.initSign(new MyRSAPrivateCrtKey()); + fail("Should throw InvalidKeyException"); + } catch (NoSuchAlgorithmException nae) { + } catch (InvalidKeyException ike) { + //expected + } } /* @@ -441,6 +452,33 @@ private class MyPublicKey extends MyKey implements PublicKey {} private class MyPrivateKey extends MyKey implements PrivateKey {} + + private class MyRSAPrivateCrtKey extends MyPrivateKey implements RSAPrivateCrtKey { + public BigInteger getCrtCoefficient() { + return null; + } + public BigInteger getPrimeP() { + return null; + } + public BigInteger getPrimeQ() { + return null; + } + public BigInteger getPrimeExponentP() { + return null; + } + public BigInteger getPrimeExponentQ() { + return null; + } + public BigInteger getPublicExponent() { + return null; + } + public BigInteger getPrivateExponent() { + return null; + } + public BigInteger getModulus() { + return null; + } + } private class MyCertificate extends java.security.cert.Certificate { public MyCertificate() {