Search in sources :

Example 31 with SignatureException

use of java.security.SignatureException in project robovm by robovm.

the class SignatureExceptionTest method testSignatureException08.

/**
     * Test for <code>SignatureException(String, Throwable)</code> constructor
     * Assertion: constructs SignatureException when <code>cause</code> is not
     * null <code>msg</code> is null
     */
public void testSignatureException08() {
    SignatureException tE = new SignatureException(null, tCause);
    if (tE.getMessage() != null) {
        String toS = tCause.toString();
        String getM = tE.getMessage();
        assertTrue("getMessage() must should ".concat(toS), (getM.indexOf(toS) != -1));
    }
    assertNotNull("getCause() must not return null", tE.getCause());
    assertEquals("getCause() must return ".concat(tCause.toString()), tE.getCause(), tCause);
}
Also used : SignatureException(java.security.SignatureException)

Example 32 with SignatureException

use of java.security.SignatureException in project robovm by robovm.

the class SignatureExceptionTest method testSignatureException03.

/**
     * Test for <code>SignatureException(String)</code> constructor Assertion:
     * constructs SignatureException when <code>msg</code> is null
     */
public void testSignatureException03() {
    String msg = null;
    SignatureException tE = new SignatureException(msg);
    assertNull("getMessage() must return null.", tE.getMessage());
    assertNull("getCause() must return null", tE.getCause());
}
Also used : SignatureException(java.security.SignatureException)

Example 33 with SignatureException

use of java.security.SignatureException in project robovm by robovm.

the class SignatureExceptionTest method testSignatureException06.

/**
     * Test for <code>SignatureException(String, Throwable)</code> constructor
     * Assertion: constructs SignatureException when <code>cause</code> is
     * null <code>msg</code> is null
     */
public void testSignatureException06() {
    SignatureException tE = new SignatureException(null, null);
    assertNull("getMessage() must return null", tE.getMessage());
    assertNull("getCause() must return null", tE.getCause());
}
Also used : SignatureException(java.security.SignatureException)

Example 34 with SignatureException

use of java.security.SignatureException in project robovm by robovm.

the class DigestSignatureSpi method engineSign.

protected byte[] engineSign() throws SignatureException {
    byte[] hash = new byte[digest.getDigestSize()];
    digest.doFinal(hash, 0);
    try {
        byte[] bytes = derEncode(hash);
        return cipher.processBlock(bytes, 0, bytes.length);
    } catch (ArrayIndexOutOfBoundsException e) {
        throw new SignatureException("key too small for signature type");
    } catch (Exception e) {
        throw new SignatureException(e.toString());
    }
}
Also used : SignatureException(java.security.SignatureException) SignatureException(java.security.SignatureException) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException)

Example 35 with SignatureException

use of java.security.SignatureException in project robovm by robovm.

the class DSABase method engineVerify.

protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
    byte[] hash = new byte[digest.getDigestSize()];
    digest.doFinal(hash, 0);
    BigInteger[] sig;
    try {
        sig = encoder.decode(sigBytes);
    } catch (Exception e) {
        throw new SignatureException("error decoding signature bytes.");
    }
    return signer.verifySignature(hash, sig[0], sig[1]);
}
Also used : BigInteger(java.math.BigInteger) SignatureException(java.security.SignatureException) SignatureException(java.security.SignatureException)

Aggregations

SignatureException (java.security.SignatureException)329 InvalidKeyException (java.security.InvalidKeyException)171 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)132 Signature (java.security.Signature)132 IOException (java.io.IOException)75 PublicKey (java.security.PublicKey)53 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)39 X509Certificate (java.security.cert.X509Certificate)33 BigInteger (java.math.BigInteger)32 CertificateException (java.security.cert.CertificateException)31 NoSuchProviderException (java.security.NoSuchProviderException)29 PrivateKey (java.security.PrivateKey)25 ByteArrayInputStream (java.io.ByteArrayInputStream)17 KeyFactory (java.security.KeyFactory)15 ArrayList (java.util.ArrayList)15 MySignature1 (org.apache.harmony.security.tests.support.MySignature1)14 UnsupportedEncodingException (java.io.UnsupportedEncodingException)13 ClientException (edu.umass.cs.gnscommon.exceptions.client.ClientException)12 GeneralSecurityException (java.security.GeneralSecurityException)12 MessageDigest (java.security.MessageDigest)12