Current location - Quotes Website - Personality signature - Apk packaging process
Apk packaging process
Aapt defines a resource ID for each non-asset directory resource, which is a 4-byte (byte = 32bit) number in the format of PPTTNNNN, where PP stands for the package to which the resource belongs, TT stands for the type of resource, and NNNN stands for the name (entry ID) of the resource under this type.

Decompress the signed apk. Usually, there are three files in the META-INF directory: MANIFEST. MF,CERT。 SF and CERT RSA: Different certificates and signatures here may get different names.

The APK package is installed according to RSA- >; SF-& gt; Check the order of MF in turn: * * First, restore the signature information with the public key information, and then compare with. SF file, and then. MF files use the same aggregation algorithm, and then. MF is relatively consistent.

disadvantaged

Simply put, v2 signature mode is to add a new block (signature block) to the original apk block, and the new block stores signature, digest, signature algorithm, certificate chain and some additional attributes. The block has a specific format.

The format of apk is signed and becomes the following four parts.

Among them, the third part has an offset value directly pointing to the starting position of the second part, and each second part, such as the central directory header 1 ... the central directory header n, has a cheap field pointing to the corresponding first part.

The signature block includes the encryption protection of the first part, the second part and the third part of apk, the digest algorithm and the binary content of the signature algorithm. The signature block itself is not encrypted. It should be noted that because the third part contains the reference offset to the second part, if the signature block changes, such as adding a signature algorithm or adding information such as the signer, this offset will change. Therefore, when calculating the digest information, it is necessary to eliminate the spacing and calculate it based on the offset of the third part to the signature block.

Next, let's take a look at the specific apk signature block format, which is divided into four parts:

How to find the location of v2 block: record it at the end of ZIP center->; Actual offset of the central directory->; Fix the magic value, and then you can locate the position of v2 block.

V2 signature block is responsible for protecting the integrity of parts 1, 3 and 4, and the integrity of the signed data block in V2 block of APK signature scheme contained in the second part. The integrity of 1, 3 and 4 parts is protected by the content digest, which is stored in the signature data block, and the integrity of the signature data block is guaranteed by the signature. The following is the process of calculating the summary.

The following calculation method shall be adopted for the abstracts of parts 1, 3 and 4.

From the above, we can know that the v2 mode block is somewhat similar to.