diff options
author | Mike McTernan <mikemcternan@google.com> | 2024-04-08 15:37:23 +0100 |
---|---|---|
committer | Mike McTernan <mikemcternan@google.com> | 2024-04-08 16:08:36 +0100 |
commit | 2d76f6d0bc01d618ee28756a5843732c15dc35ca (patch) | |
tree | bc10f9ee2cad950cc70547d5592409db72c50d3b | |
parent | 93e253ae87e019dbe0c88216c9ab0bb5ed2f0db8 (diff) | |
download | cast-auth-main.tar.gz |
The function returns a bool to identify the keytype, but would return an
error code on memory failure. Change the function to avoid the memory
allocation failure path.
Bug: 332371854
Test: build.py qemu-generic-arm64-test-debug --test com.android.trusty.cast_auth.test
Change-Id: Idc0f4b2484ec5b00bf97eed3647196ef2da463bb
-rw-r--r-- | app/cast_auth_impl.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/app/cast_auth_impl.cc b/app/cast_auth_impl.cc index cfa8a0f..b1ccdb4 100644 --- a/app/cast_auth_impl.cc +++ b/app/cast_auth_impl.cc @@ -45,13 +45,10 @@ constexpr int MESSAGE_MAX_BYTES = PAYLOAD_MAX_BYTES + BINDER_MAX_BYTES; using android::binder::Status; bool is_plaintext_rsa_2048_private_key(const std::vector<uint8_t>& key) { - bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(key.data(), key.size())); - if (!bio) { - TLOGE("is_plaintext_rsa_2048_private_key: failed to allocate memory for the " - "device key\n"); - return ERR_NO_MEMORY; - } - bssl::UniquePtr<RSA> rsa(d2i_RSAPrivateKey_bio(bio.get(), NULL)); + const uint8_t* key_data = key.data(); + + bssl::UniquePtr<RSA> rsa(d2i_RSAPrivateKey(NULL, &key_data, key.size())); + return rsa && RSA_size(rsa.get()) == RSA_2048_SIZE_BYTES; } |