From 265133a53a164c56b037d8e746c59b9beaa8330e Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 2 Oct 2017 12:05:47 -0700 Subject: Keymaster: Move test to std::unique_ptr In preparation for UniquePtr removal. Test: none Change-Id: I54c0be6ee938252fc0492ae745aa45e41631d342 --- keymaster_qcom.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'keymaster_qcom.cpp') diff --git a/keymaster_qcom.cpp b/keymaster_qcom.cpp index 0ad3330..e779cbc 100644 --- a/keymaster_qcom.cpp +++ b/keymaster_qcom.cpp @@ -18,6 +18,8 @@ #include #include +#include + #include #include @@ -42,8 +44,6 @@ #include #include -#include - #include "QSEEComAPI.h" #include "keymaster_qcom.h" @@ -80,16 +80,16 @@ struct EVP_PKEY_Delete { EVP_PKEY_free(p); } }; -typedef UniquePtr Unique_EVP_PKEY; +typedef std::unique_ptr Unique_EVP_PKEY; struct RSA_Delete { void operator()(RSA* p) const { RSA_free(p); } }; -typedef UniquePtr Unique_RSA; +typedef std::unique_ptr Unique_RSA; -typedef UniquePtr Unique_keymaster_device_t; +typedef std::unique_ptr Unique_keymaster_device_t; /** * Many OpenSSL APIs take ownership of an argument on success but don't free the argument @@ -172,7 +172,7 @@ static int qcom_km_get_keypair_public(const keymaster0_device_t* dev, return -1; } - UniquePtr key(new unsigned char[len]); + std::unique_ptr key(new unsigned char[len]); if (key.get() == NULL) { ALOGE("Could not allocate memory for public key data"); return -1; @@ -368,7 +368,7 @@ static int qcom_km_generate_keypair(const keymaster0_device_t* dev, ALOGE("Generate key command failed resp->status = %d ret =%d", resp->status, ret); return -1; } else { - UniquePtr keydata(new unsigned char[resp->key_blob_len]); + std::unique_ptr keydata(new unsigned char[resp->key_blob_len]); if (keydata.get() == NULL) { ALOGE("could not allocate memory for key blob"); return -1; @@ -451,7 +451,7 @@ static int qcom_km_import_keypair(const keymaster0_device_t* dev, qcom_km_ion_dealloc(&ihandle); return -1; } else { - UniquePtr keydata(new unsigned char[resp->key_blob_len]); + std::unique_ptr keydata(new unsigned char[resp->key_blob_len]); if (keydata.get() == NULL) { ALOGE("could not allocate memory for key blob"); return -1; @@ -551,7 +551,7 @@ static int qcom_km_sign_data(const keymaster0_device_t* dev, qcom_km_ion_dealloc(&ihandle); return -1; } else { - UniquePtr signedDataPtr(reinterpret_cast(malloc(resp->sig_len))); + std::unique_ptr signedDataPtr(reinterpret_cast(malloc(resp->sig_len))); if (signedDataPtr.get() == NULL) { ALOGE("Sign data memory allocation failed"); qcom_km_ion_dealloc(&ihandle); -- cgit v1.2.3