The way of configuration management under Android: apk signature correlation

Keywords: Linux SHA1 Java Python

How to generate apk signature key file

# Build key method:
sub='/C=CN/ST=ShangHai/L=ShangHai/O=example/OU=CM/CN=example/emailAddress=buildfarm@example.com'
for key in platform shared media testkey;do
    ./development/tools/make_key $key "$sub"
done

How to re sign an apk

The command is as follows:

java -Xmx2048m -jar signapk.jar xxx.x509.pem  xxx.pk8 unsigned.apk signed.apk

pem and pk8 files, for userdebug and eng, are key files in the code. It can be found under the path of build/target/product/security.

How to get sha1 value of signature key

Extract apk file to get RSA file

APK is opened as a zip file. There is a file with the. RSA suffix in the \ META-INF \ directory. The general name is CERT.RSA

Use the keytool command to obtain certificate information (including MD5)
Run the following keytool command: keytool -printcert -file CERT.RSA

keytool -printcert -file CERT.RSA
Owner: EMAILADDRESS=buildfarm@example.com, CN=example, OU=CM, O=example, L=ShangHai, ST=ShangHai, C=CN
Issuer: EMAILADDRESS=buildfarm@example.com, CN=example, OU=CM, O=example, L=ShangHai, ST=ShangHai, C=CN
Serial number: f03839c4296d10e2
Valid from: Tue Nov 22 14:21:36 CST 2016 until: Sat Apr 09 14:21:36 CST 2044
Certificate fingerprints:
MD5: B5:A2:01:A5:8D:54:CF:BE:ED:85:20:B6:5D:81:37:B0
SHA1: 44:1C:6D:43:17:06:FC:95:17:6E:B8:39:CF:A7:B7:E7:5E:C4:C1:AC
SHA256: 97:12:E0:92:B0:23:CE:F9:82:E4:92:EA:08:E8:7E:42:D0:90:75:D4:B1:34:FD:41:A3:63:03:DA:AE:EB:74:DA
Signature algorithm name: SHA1withRSA
Version: 3

Extensions:

#1: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 08 79 56 A2 9D B2 49 28 36 01 47 E5 1C 6C 3F 9E .yV...I(6.G..l?.
0010: 12 40 9B 38 .@.8
]
]

#2: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
CA:true
PathLen:2147483647
]

#3: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 08 79 56 A2 9D B2 49 28 36 01 47 E5 1C 6C 3F 9E .yV...I(6.G..l?.
0010: 12 40 9B 38 .@.8
]
]

How to make ota difference subcontract

ota full package upgrade method:
Push the full package ota zip file ADB under / sdcard / of the phone and change its name to update.zip
adb reboot recovery, the phone will enter an interface and click the upgrade button.

How to do differential subcontracting

The basic commands are as follows:

python Bins/releasetools/ota_from_target_files -v -p Bins/linux-x86 -k  releasekey -i old.zip new.zip  update.zip

-p Bins/linux-x86 where the - p parameter specifies the path of imgdiff and bsdiff tools. If not, errors will be reported when doing differential subcontracting.

Many tools and so files are needed to make the differential package, which can be obtained under the android source compilation environment, generally under the out host. Linux system chooses linux-x
86 that directory.

# This is some files related to the production of ota differential subcontracting. Without these files, it is impossible to make differential subcontracting successfully
# copy bins for ota
src:o:build/tools/releasetools/blockimgdiff.py:                             debug/Bins/releasetools/
src:o:build/tools/releasetools/build_image.py:                              debug/Bins/releasetools/
src:o:build/tools/releasetools/rangelib.py:                                 debug/Bins/releasetools/
src:o:build/tools/releasetools/sparse_img.py:                               debug/Bins/releasetools/
src:o:build/tools/releasetools/ota_from_target_files:                       debug/Bins/releasetools/
src:o:build/tools/releasetools/add_img_to_target_files.py:                  debug/Bins/releasetools/
src:o:build/tools/releasetools/edify_generator.py:                          debug/Bins/releasetools/
src:o:build/tools/releasetools/common.py:                                   debug/Bins/releasetools/
out:o:../../../host/linux-x86/bin/bsdiff:                                   debug/Bins/linux-x86/bin/
out:o:../../../host/linux-x86/bin/imgdiff:                                  debug/Bins/linux-x86/bin/
out:o:../../../host/linux-x86/bin/simg2img:                                 debug/Bins/linux-x86/bin/
out:o:../../../host/linux-x86/bin/make_ext4fs:                              debug/Bins/linux-x86/bin/
out:o:../../../host/linux-x86/bin/mkuserimg.sh:                             debug/Bins/linux-x86/bin/
out:o:../../../host/linux-x86/bin/e2fsck:                                   debug/Bins/linux-x86/bin/
out:o:../../../host/linux-x86/bin/brillo_update_payload:                    debug/Bins/linux-x86/bin/
out:o:../../../host/linux-x86/bin/delta_generator:                          debug/Bins/linux-x86/bin/
out:o:../../../host/linux-x86/bin/lib/shflags/shflags:                      debug/Bins/linux-x86/bin/lib/shflags/
out:o:../../../host/linux-x86/framework/signapk.jar:                        debug/Bins/linux-x86/framework/
out:o:../../../host/linux-x86/lib64/libc++.so:                              debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libconscrypt_openjdk_jni.so:            debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libdivsufsort64.so:                     debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libdivsufsort.so:                       debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libcutils.so:                           debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libselinux.so:                          debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/liblog.so:                              debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libext2fs-host.so:                      debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libext2_blkid-host.so:                  debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libext2_uuid-host.so:                   debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libext2_profile-host.so:                debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libext2_quota-host.so:                  debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libext2_com_err-host.so:                debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libext2_e2p-host.so:                    debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libbase.so:                             debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libbrillo.so:                           debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libbrillo-stream.so:                    debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libchrome.so:                           debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libcrypto-host.so:                      debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libevent-host.so:                       debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libprotobuf-cpp-lite.so:                debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libselinux.so:                          debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libsparse-host.so:                      debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libssl-host.so:                         debug/Bins/linux-x86/lib64/
out:o:../../../host/linux-x86/lib64/libz-host.so:                           debug/Bins/linux-x86/lib64/

Posted by SmokyBarnable on Fri, 03 Apr 2020 22:53:48 -0700