From 7604f7bcac36402e983db7ca6f391c90d175ab83 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Fri, 6 Sep 2013 09:51:27 -0700 Subject: [PATCH] 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 --- libkeymaster/keymaster_mobicore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } -- 2.20.1