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
f37f3306
Commit
f37f3306
authored
Jan 26, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update with latest :crypto
parent
40082d45
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
31 deletions
+15
-31
InstallMagisk.java
src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+2
-4
BootSigner.java
src/main/java/com/topjohnwu/magisk/utils/BootSigner.java
+11
-20
Const.java
src/main/java/com/topjohnwu/magisk/utils/Const.java
+0
-2
ZipUtils.java
src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
+2
-5
No files found.
src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
f37f3306
...
...
@@ -205,11 +205,9 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
AssetManager
assets
=
mm
.
getAssets
();
try
(
InputStream
in
=
new
FileInputStream
(
patched_boot
);
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
signed
));
InputStream
keyIn
=
assets
.
open
(
Const
.
PRIVATE_KEY_NAME
);
InputStream
certIn
=
assets
.
open
(
Const
.
PUBLIC_KEY_NAME
)
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
signed
))
)
{
SignBoot
.
doSignature
(
"/boot"
,
in
,
out
,
keyIn
,
certIn
);
SignBoot
.
doSignature
(
"/boot"
,
in
,
out
,
null
,
null
);
}
shell
.
run
(
null
,
null
,
"mv -f "
+
signed
+
" "
+
patched_boot
);
}
...
...
src/main/java/com/topjohnwu/magisk/utils/BootSigner.java
View file @
f37f3306
...
...
@@ -6,8 +6,6 @@ import com.topjohnwu.crypto.SignBoot;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarFile
;
public
class
BootSigner
{
...
...
@@ -15,30 +13,23 @@ public class BootSigner {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
>
0
&&
"-verify"
.
equals
(
args
[
0
]))
{
String
certPath
=
""
;
if
(
args
.
length
>=
3
&&
"-certificate"
.
equals
(
args
[
1
])
)
{
/* args[
2
] is the path to a public key certificate */
certPath
=
args
[
2
];
if
(
args
.
length
>=
2
)
{
/* args[
1
] is the path to a public key certificate */
certPath
=
args
[
1
];
}
/* args[1] is the path to a signed boot image */
boolean
signed
=
SignBoot
.
verifySignature
(
System
.
in
,
certPath
.
isEmpty
()
?
null
:
new
FileInputStream
(
certPath
));
System
.
exit
(
signed
?
0
:
1
);
}
else
if
(
args
.
length
>
0
&&
"-sign"
.
equals
(
args
[
0
]))
{
InputStream
keyIn
,
certIn
;
if
(
args
.
length
>=
3
)
{
keyIn
=
new
FileInputStream
(
args
[
1
]);
certIn
=
new
FileInputStream
(
args
[
2
]);
}
else
{
/* Use internal test keys */
JarFile
apk
=
new
JarFile
(
System
.
getProperty
(
"java.class.path"
));
JarEntry
keyEntry
=
apk
.
getJarEntry
(
"assets/"
+
Const
.
PRIVATE_KEY_NAME
);
JarEntry
sigEntry
=
apk
.
getJarEntry
(
"assets/"
+
Const
.
PUBLIC_KEY_NAME
);
InputStream
cert
=
null
;
InputStream
key
=
null
;
keyIn
=
apk
.
getInputStream
(
keyEntry
);
certIn
=
apk
.
getInputStream
(
sigEntry
);
if
(
args
.
length
>=
3
)
{
cert
=
new
FileInputStream
(
args
[
1
]);
key
=
new
FileInputStream
(
args
[
2
]);
}
boolean
success
=
SignBoot
.
doSignature
(
"/boot"
,
System
.
in
,
System
.
out
,
keyIn
,
certIn
);
boolean
success
=
SignBoot
.
doSignature
(
"/boot"
,
System
.
in
,
System
.
out
,
cert
,
key
);
System
.
exit
(
success
?
0
:
1
);
}
else
{
System
.
err
.
println
(
...
...
@@ -48,8 +39,8 @@ public class BootSigner {
"Actions:\n"
+
" -verify [x509.pem]\n"
+
" verify image, cert is optional\n"
+
" -sign [
pk8] [x509.pem
]\n"
+
" sign image,
key and cert are
optional\n"
" -sign [
x509.pem] [pk8
]\n"
+
" sign image,
cert and key pair is
optional\n"
);
}
}
...
...
src/main/java/com/topjohnwu/magisk/utils/Const.java
View file @
f37f3306
...
...
@@ -17,8 +17,6 @@ public class Const {
public
static
final
String
MAGISKHIDE_PROP
=
"persist.magisk.hide"
;
// APK content
public
static
final
String
PUBLIC_KEY_NAME
=
"public.certificate.x509.pem"
;
public
static
final
String
PRIVATE_KEY_NAME
=
"private.key.pk8"
;
public
static
final
String
UNINSTALLER
=
"magisk_uninstaller.sh"
;
public
static
final
String
UTIL_FUNCTIONS
=
"util_functions.sh"
;
public
static
final
String
ANDROID_MANIFEST
=
"AndroidManifest.xml"
;
...
...
src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
View file @
f37f3306
...
...
@@ -76,9 +76,6 @@ public class ZipUtils {
}
public
static
void
signZip
(
JarMap
input
,
OutputStream
output
,
boolean
minSign
)
throws
Exception
{
AssetManager
assets
=
MagiskManager
.
get
().
getAssets
();
SignAPK
.
signZip
(
assets
.
open
(
Const
.
PUBLIC_KEY_NAME
),
assets
.
open
(
Const
.
PRIVATE_KEY_NAME
),
input
,
output
,
minSign
);
SignAPK
.
signZip
(
null
,
null
,
input
,
output
,
minSign
);
}
}
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