diff options
author | 2023-07-25 16:09:11 +0100 | |
---|---|---|
committer | 2023-07-26 08:34:47 +0000 | |
commit | e53d5393cedc6e1ec2579df93605389a3b41337c (patch) | |
tree | f8dae30bf74e872988cc09c8a80d9b4c3152a9a5 | |
parent | 200a1b20c5b638a0d8bb5aee9476c1330a468363 (diff) |
hiddenapi: Update SHA1 in the dex header
Ensure that the SHA1 matches the file content.
Test: UNSAFE_DISABLE_HIDDENAPI_FLAGS=true m
Change-Id: I0f34442823b76835e983491e8dc1340b80101e0f
-rw-r--r-- | tools/hiddenapi/Android.bp | 1 | ||||
-rw-r--r-- | tools/hiddenapi/hiddenapi.cc | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/tools/hiddenapi/Android.bp b/tools/hiddenapi/Android.bp index aa7b9f6593..fff94926ab 100644 --- a/tools/hiddenapi/Android.bp +++ b/tools/hiddenapi/Android.bp @@ -41,6 +41,7 @@ cc_defaults { stl: "c++_static", static_libs: [ "libbase", + "libcrypto", ], } diff --git a/tools/hiddenapi/hiddenapi.cc b/tools/hiddenapi/hiddenapi.cc index 5c750af4aa..d62ee17819 100644 --- a/tools/hiddenapi/hiddenapi.cc +++ b/tools/hiddenapi/hiddenapi.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include <openssl/sha.h> + #include <fstream> #include <iostream> #include <iterator> @@ -731,8 +733,9 @@ class DexFileEditor final { header->data_size_ = output.size() - header->data_off_; header->file_size_ = output.size() - header_offset[i]; } + size_t sha1_start = offsetof(DexFile::Header, file_size_); + SHA1(begin + sha1_start, header->file_size_ - sha1_start, header->signature_); header->checksum_ = DexFile::CalculateChecksum(begin, header->file_size_); - // TODO: We should also update the SHA1 signature. } // Write the output file. |