Skip to content

Commit a5a0aa0

Browse files
authored
Fix NativeCrypto.X509_verify() exceptions. (#1203)
Re-throw IllegalBlockSizeException as SignatureException from OpenSSLX509Certificate.verify(), as per the API contract and fix the signature in NativeCrypto. The only other user of the native method, OpenSSLX509CRL, already had this fix.
1 parent 59de319 commit a5a0aa0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

common/src/main/java/org/conscrypt/NativeCrypto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ static native long X509_get_notAfter(long x509ctx, OpenSSLX509Certificate holder
535535
static native byte[] X509_get_serialNumber(long x509ctx, OpenSSLX509Certificate holder);
536536

537537
static native void X509_verify(long x509ctx, OpenSSLX509Certificate holder, NativeRef.EVP_PKEY pkeyCtx)
538-
throws BadPaddingException;
538+
throws BadPaddingException, IllegalBlockSizeException;
539539

540540
static native byte[] get_X509_tbs_cert(long x509ctx, OpenSSLX509Certificate holder);
541541

common/src/main/java/org/conscrypt/OpenSSLX509Certificate.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.TimeZone;
5050

5151
import javax.crypto.BadPaddingException;
52+
import javax.crypto.IllegalBlockSizeException;
5253
import javax.security.auth.x500.X500Principal;
5354
import org.conscrypt.OpenSSLX509CertificateFactory.ParsingException;
5455

@@ -384,8 +385,8 @@ private void verifyOpenSSL(OpenSSLKey pkey) throws CertificateException, Signatu
384385
NativeCrypto.X509_verify(mContext, this, pkey.getNativeRef());
385386
} catch (RuntimeException e) {
386387
throw new CertificateException(e);
387-
} catch (BadPaddingException e) {
388-
throw new SignatureException();
388+
} catch (BadPaddingException | IllegalBlockSizeException e) {
389+
throw new SignatureException(e);
389390
}
390391
}
391392

0 commit comments

Comments
 (0)