I would like to implement security check - signature verification of application (or dex file) to verify that unmodified application uses my shared native library (*.so) build with NDK. I would like to perform all signature checks directly in C++, without Java. Currently I found out that it is possible to access apk file here: /data/app/--1/base.apk. From apk file I guess it's possible to get contents of original dex file probably even without extraction as apk file is aligned.
I say original dex file because if I understand correctly (and correct me if I'm wrong) dex file is converted into ELF shared object when apk is installed - binary executable specific to architecture of device. That was the reason why I was not able to check/verify signature of *.dex file listed in /proc/self/maps (example: /data/dalvik-cache/x86/data@[email protected]@[email protected]) because it's not possible to know signature at compile time because dex file will be changed.
I know the method of checking original dex file is not very secure because I think it could be bypassed on rooted device easily by replacing optimized dex file - just run dex2oat on custom dex file and place it in (/data/dalvik-cache/...).
Offhand, I can't think of a way to do this.
I can think of several (and they're all mad as a hatter):
It may fail for silly people like me, who use an Intel based device.