From: Kenny Root Date: Fri, 6 Sep 2013 16:51:27 +0000 (-0700) Subject: Use EVP_PKEY_get1_RSA to get RSA reference X-Git-Tag: cm-11.0-XNPH22R-bacon-03d77315ea~1^2~17 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7604f7bcac36402e983db7ca6f391c90d175ab83;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_exynos5.git Use EVP_PKEY_get1_RSA to get RSA reference EVP_PKEY structures could be of any number of key types. Switch to EVP_PKEY_get1_RSA because that will check that the key type before it tries to pull out the RSA pointer. This prevents crashes when the key type is not actually RSA. Bug: 10647482 Change-Id: I6848db52b04ed11331138ac00f0796574a87fa6a --- diff --git a/libkeymaster/keymaster_mobicore.cpp b/libkeymaster/keymaster_mobicore.cpp index f2d5d55..c093cb4 100644 --- a/libkeymaster/keymaster_mobicore.cpp +++ b/libkeymaster/keymaster_mobicore.cpp @@ -165,8 +165,8 @@ static int exynos_km_import_keypair(const keymaster_device_t* dev, OWNERSHIP_TRANSFERRED(pkcs8); /* change key format */ - RSA* rsa = pkey.get()->pkey.rsa; - if (rsa == NULL) { + Unique_RSA rsa(EVP_PKEY_get1_RSA(pkey.get())); + if (rsa.get() == NULL) { logOpenSSLError("get rsa key format"); return -1; }