Skip to content

Commit

Permalink
Add as an Android library
Browse files Browse the repository at this point in the history
  • Loading branch information
MuntashirAkon committed Aug 14, 2021
1 parent fcbd58e commit 8e06b63
Show file tree
Hide file tree
Showing 59 changed files with 548 additions and 580 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gradle
.idea
/build
/local.properties
.DS_Store
58 changes: 0 additions & 58 deletions Android.bp

This file was deleted.

1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

Copyright (c) 2020, Muntashir Al-Islam
Copyright (c) 2016, The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
3 changes: 0 additions & 3 deletions OWNERS

This file was deleted.

40 changes: 19 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
# apksig
# apksig for Android

Android port of [apksig](https://android.googlesource.com/platform/tools/apksig) library.

[![](https://jitpack.io/v/MuntashirAkon/apksig-android.svg)](https://jitpack.io/#MuntashirAkon/apksig-android)

apksig is a project which aims to simplify APK signing and checking whether APK signatures are
expected to verify on Android. apksig supports
[JAR signing](https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Signed_JAR_File)
(used by Android since day one) and
[APK Signature Scheme v2](https://source.android.com/security/apksigning/v2.html) (supported since
Android Nougat, API Level 24). apksig is meant to be used outside of Android devices.
Android Nougat, API Level 24).

The key feature of apksig is that it knows about differences in APK signature verification logic
between different versions of the Android platform. apksig thus thoroughly checks whether an APK's
signature is expected to verify on all Android platform versions supported by the APK. When signing
an APK, apksig chooses the most appropriate cryptographic algorithms based on the Android platform
versions supported by the APK being signed.

The project consists of two subprojects:
## Quick start
apksig for Android is available via JitPack.

* apksig -- a pure Java library, and
* apksigner -- a pure Java command-line tool based on the apksig library.
```groovy
// Top level build file
repositories {
maven { url "https://jitpack.io" }
}
// Add to dependencies section
dependencies {
implementation 'com.github.MuntashirAkon:apksig-android:4.1.1'
}
```

## apksig library

## Features
apksig library offers three primitives:

* `ApkSigner` which signs the provided APK so that it verifies on all Android platform versions
Expand All @@ -35,17 +47,3 @@ apksig library offers three primitives:
_NOTE: Some public classes of the library are in packages having the word "internal" in their name.
These are not public API of the library. Do not use \*.internal.\* classes directly because these
classes may change any time without regard to existing clients outside of `apksig` and `apksigner`._


## apksigner command-line tool

apksigner command-line tool offers two operations:

* sign the provided APK so that it verifies on all Android platforms supported by the APK. Run
`apksigner sign` for usage information.
* check whether the provided APK's signatures are expected to verify on all Android platforms
supported by the APK. Run `apksigner verify` for usage information.

The tool determines the range of Android platform versions (API Levels) supported by the APK by
inspecting the APK's AndroidManifest.xml. This behavior can be overridden by specifying the range
of platform versions on the command-line.
18 changes: 0 additions & 18 deletions android_plugin_for_gradle.gradle

This file was deleted.

76 changes: 52 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,41 +1,69 @@
// Generic Gradle project
/*
* Copyright (C) 2020 Muntashir Al-Islam
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: 'java'
apply plugin: 'com.google.protobuf'

sourceCompatibility = '1.8'
apply plugin: 'com.android.library'

repositories {
jcenter()
google()
mavenCentral()
}

buildscript {
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.11'
classpath 'com.android.tools.build:gradle:4.2.2'
}
}

dependencies {
implementation 'com.google.protobuf:protobuf-javalite:3.8.0'
testImplementation 'junit:junit:4.13'
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.68'
testImplementation 'org.conscrypt:conscrypt-openjdk-uber:2.5.1'
wrapper {
distributionType = Wrapper.DistributionType.ALL
}

protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.8.0'
android {
compileSdkVersion 30

defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 2
versionName "4.3.0"
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}

buildTypes {
release {
minifyEnabled false
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}

dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.69'
testImplementation 'org.conscrypt:conscrypt-openjdk-uber:2.5.2'
testImplementation 'org.robolectric:robolectric:4.6.1'
}
97 changes: 0 additions & 97 deletions etc/apksigner

This file was deleted.

Loading

0 comments on commit 8e06b63

Please sign in to comment.