NativeCrypto: add missing native function
This should be covered by NativeCryptoTest as well but there was a missing
native function that caused
tests.security.cert.CertificateCertificateRepTest#testReadResolve
to fail.
There was also a missing OpenSSL error catch that made the same test
fail.
(cherry picked from commit 40875857eb5fe3434cbab6fc4517c6ffa52fdc24)
Bug: 8488314
Change-Id: Ib9cafe486228bae1634de275302876098353ec10
diff --git a/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp b/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
index 3075197..65ac31f 100644
--- a/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
+++ b/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
@@ -394,6 +394,9 @@
case EVP_R_WRONG_PUBLIC_KEY_TYPE:
throwSignatureException(env, message);
break;
+ case EVP_R_UNSUPPORTED_ALGORITHM:
+ throwNoSuchAlgorithmException(env, message);
+ break;
default:
jniThrowRuntimeException(env, message);
break;
@@ -4688,6 +4691,13 @@
return ASN1ToByteArray<X509, i2d_X509>(env, x509);
}
+static jbyteArray NativeCrypto_i2d_X509_PUBKEY(JNIEnv* env, jclass, jlong x509Ref) {
+ X509* x509 = reinterpret_cast<X509*>(static_cast<uintptr_t>(x509Ref));
+ JNI_TRACE("i2d_X509_PUBKEY(%p)", x509);
+ return ASN1ToByteArray<X509_PUBKEY, i2d_X509_PUBKEY>(env, X509_get_X509_PUBKEY(x509));
+}
+
+
template<typename T, T* (*PEM_read_func)(BIO*, T**, pem_password_cb*, void*)>
static jlong PEM_ASN1Object_to_jlong(JNIEnv* env, jlong bioRef) {
BIO* bio = reinterpret_cast<BIO*>(static_cast<uintptr_t>(bioRef));
@@ -7888,6 +7898,7 @@
NATIVE_METHOD(NativeCrypto, d2i_X509_bio, "(J)J"),
NATIVE_METHOD(NativeCrypto, d2i_X509, "([B)J"),
NATIVE_METHOD(NativeCrypto, i2d_X509, "(J)[B"),
+ NATIVE_METHOD(NativeCrypto, i2d_X509_PUBKEY, "(J)[B"),
NATIVE_METHOD(NativeCrypto, PEM_read_bio_X509, "(J)J"),
NATIVE_METHOD(NativeCrypto, PEM_read_bio_PKCS7, "(JI)[J"),
NATIVE_METHOD(NativeCrypto, d2i_PKCS7_bio, "(JI)[J"),