1# apksig 2 3apksig is a project which aims to simplify APK signing and checking whether APK signatures are 4expected to verify on Android. apksig supports 5[JAR signing](https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Signed_JAR_File) 6(used by Android since day one) and 7[APK Signature Scheme v2](https://source.android.com/security/apksigning/v2.html) (supported since 8Android Nougat, API Level 24). apksig is meant to be used outside of Android devices. 9 10The key feature of apksig is that it knows about differences in APK signature verification logic 11between different versions of the Android platform. apksig thus thoroughly checks whether an APK's 12signature is expected to verify on all Android platform versions supported by the APK. When signing 13an APK, apksig chooses the most appropriate cryptographic algorithms based on the Android platform 14versions supported by the APK being signed. 15 16The project consists of two subprojects: 17 18 * apksig -- a pure Java library, and 19 * apksigner -- a pure Java command-line tool based on the apksig library. 20 21 22## apksig library 23 24apksig library offers three primitives: 25 26 * `ApkSigner` which signs the provided APK so that it verifies on all Android platform versions 27 supported by the APK. The range of platform versions can be customized. 28 * `ApkVerifier` which checks whether the provided APK is expected to verify on all Android 29 platform versions supported by the APK. The range of platform versions can be customized. 30 * `(Default)ApkSignerEngine` which abstracts away signing APKs from parsing and building APKs. 31 This is useful in optimized APK building pipelines, such as in Android Plugin for Gradle, 32 which need to perform signing while building an APK, instead of after. For simpler use cases 33 where the APK to be signed is available upfront, the `ApkSigner` above is easier to use. 34 35_NOTE: Some public classes of the library are in packages having the word "internal" in their name. 36These are not public API of the library. Do not use \*.internal.\* classes directly because these 37classes may change any time without regard to existing clients outside of `apksig` and `apksigner`._ 38 39 40## apksigner command-line tool 41 42apksigner command-line tool offers two operations: 43 44 * sign the provided APK so that it verifies on all Android platforms supported by the APK. Run 45 `apksigner sign` for usage information. 46 * check whether the provided APK's signatures are expected to verify on all Android platforms 47 supported by the APK. Run `apksigner verify` for usage information. 48 49The tool determines the range of Android platform versions (API Levels) supported by the APK by 50inspecting the APK's AndroidManifest.xml. This behavior can be overridden by specifying the range 51of platform versions on the command-line. 52