Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
6d938314
Commit
6d938314
authored
May 20, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix zipsigner when using external keys
parent
bcdadc65
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
9 deletions
+50
-9
build.py
build.py
+1
-1
build.gradle
utils/build.gradle
+4
-4
ReusableInputStream.java
...rc/main/java/com/topjohnwu/utils/ReusableInputStream.java
+28
-0
SignAPK.java
utils/src/main/java/com/topjohnwu/utils/SignAPK.java
+15
-2
ZipSigner.java
utils/src/main/java/com/topjohnwu/utils/ZipSigner.java
+2
-2
No files found.
build.py
View file @
6d938314
...
...
@@ -361,7 +361,7 @@ def zip_uninstaller(args):
header
(
'Output: '
+
output
)
def
sign_adjust_zip
(
unsigned
,
output
):
signer_name
=
'zipsigner-2.
1
.jar'
signer_name
=
'zipsigner-2.
2
.jar'
jarsigner
=
os
.
path
.
join
(
'utils'
,
'build'
,
'libs'
,
signer_name
)
if
not
os
.
path
.
exists
(
jarsigner
):
...
...
utils/build.gradle
View file @
6d938314
...
...
@@ -15,7 +15,7 @@ jar {
shadowJar
{
baseName
=
'zipsigner'
classifier
=
null
version
=
2.
1
version
=
2.
2
}
buildscript
{
...
...
@@ -23,7 +23,7 @@ buildscript {
jcenter
()
}
dependencies
{
classpath
'com.github.jengelman.gradle.plugins:shadow:2.0.
2
'
classpath
'com.github.jengelman.gradle.plugins:shadow:2.0.
4
'
}
}
...
...
@@ -33,6 +33,6 @@ repositories {
dependencies
{
implementation
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
implementation
'org.bouncycastle:bcprov-jdk15on:1.5
8
'
implementation
'org.bouncycastle:bcpkix-jdk15on:1.5
8
'
implementation
'org.bouncycastle:bcprov-jdk15on:1.5
9
'
implementation
'org.bouncycastle:bcpkix-jdk15on:1.5
9
'
}
utils/src/main/java/com/topjohnwu/utils/ReusableInputStream.java
0 → 100644
View file @
6d938314
package
com
.
topjohnwu
.
utils
;
import
java.io.BufferedInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
class
ReusableInputStream
extends
BufferedInputStream
{
public
ReusableInputStream
(
InputStream
in
)
{
super
(
in
);
mark
(
Integer
.
MAX_VALUE
);
}
public
ReusableInputStream
(
InputStream
in
,
int
size
)
{
super
(
in
,
size
);
mark
(
Integer
.
MAX_VALUE
);
}
@Override
public
void
close
()
throws
IOException
{
/* Reset at close so we can reuse it */
reset
();
}
public
void
destroy
()
throws
IOException
{
super
.
close
();
}
}
utils/src/main/java/com/topjohnwu/utils/SignAPK.java
View file @
6d938314
...
...
@@ -18,6 +18,7 @@ import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import
org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder
;
import
org.bouncycastle.util.encoders.Base64
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
...
...
@@ -73,19 +74,31 @@ public class SignAPK {
JarMap
input
,
OutputStream
output
)
throws
Exception
{
File
temp1
=
File
.
createTempFile
(
"signAPK"
,
null
);
File
temp2
=
File
.
createTempFile
(
"signAPK"
,
null
);
if
(
cert
==
null
)
{
cert
=
SignAPK
.
class
.
getResourceAsStream
(
"/keys/testkey.x509.pem"
);
}
if
(
key
==
null
)
{
key
=
SignAPK
.
class
.
getResourceAsStream
(
"/keys/testkey.pk8"
);
}
ReusableInputStream
c
=
new
ReusableInputStream
(
cert
);
ReusableInputStream
k
=
new
ReusableInputStream
(
key
);
try
{
try
(
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
temp1
)))
{
signZip
(
c
ert
,
key
,
input
,
out
,
false
);
signZip
(
c
,
k
,
input
,
out
,
false
);
}
ZipAdjust
.
adjust
(
temp1
,
temp2
);
try
(
JarMap
map
=
new
JarMap
(
temp2
,
false
))
{
signZip
(
c
ert
,
key
,
map
,
output
,
true
);
signZip
(
c
,
k
,
map
,
output
,
true
);
}
}
finally
{
temp1
.
delete
();
temp2
.
delete
();
c
.
destroy
();
k
.
destroy
();
}
}
...
...
utils/src/main/java/com/topjohnwu/utils/ZipSigner.java
View file @
6d938314
...
...
@@ -28,8 +28,8 @@ public class ZipSigner {
InputStream
key
=
null
;
if
(
args
.
length
-
argStart
==
4
)
{
cert
=
new
BufferedInputStream
(
new
FileInputStream
(
new
File
(
args
[
argStart
])
));
key
=
new
BufferedInputStream
(
new
FileInputStream
(
new
File
(
args
[
argStart
+
1
])
));
cert
=
new
FileInputStream
(
new
File
(
args
[
argStart
]
));
key
=
new
FileInputStream
(
new
File
(
args
[
argStart
+
1
]
));
argStart
+=
2
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment