-
-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3753ee5
commit 6a9f5f8
Showing
14 changed files
with
214 additions
and
185 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
221 changes: 116 additions & 105 deletions
221
app/src/main/java/es/chiteroman/playintegrityfix/CustomKeyStoreSpi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,116 @@ | ||
package es.chiteroman.playintegrityfix; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.security.Key; | ||
import java.security.KeyStoreException; | ||
import java.security.KeyStoreSpi; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.UnrecoverableKeyException; | ||
import java.security.cert.Certificate; | ||
import java.security.cert.CertificateException; | ||
import java.util.Date; | ||
import java.util.Enumeration; | ||
import java.util.Locale; | ||
|
||
public final class CustomKeyStoreSpi extends KeyStoreSpi { | ||
public static volatile KeyStoreSpi keyStoreSpi = null; | ||
|
||
@Override | ||
public Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException { | ||
return keyStoreSpi.engineGetKey(alias, password); | ||
} | ||
|
||
@Override | ||
public Certificate[] engineGetCertificateChain(String alias) { | ||
for (StackTraceElement stackTraceElement : Thread.currentThread().getStackTrace()) { | ||
if (stackTraceElement.getClassName().toLowerCase(Locale.US).contains("droidguard")) { | ||
EntryPoint.LOG("DroidGuard call certificate chain! Throw exception."); | ||
throw new UnsupportedOperationException(); | ||
} | ||
} | ||
return keyStoreSpi.engineGetCertificateChain(alias); | ||
} | ||
|
||
@Override | ||
public Certificate engineGetCertificate(String alias) { | ||
return keyStoreSpi.engineGetCertificate(alias); | ||
} | ||
|
||
@Override | ||
public Date engineGetCreationDate(String alias) { | ||
return keyStoreSpi.engineGetCreationDate(alias); | ||
} | ||
|
||
@Override | ||
public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException { | ||
keyStoreSpi.engineSetKeyEntry(alias, key, password, chain); | ||
} | ||
|
||
@Override | ||
public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException { | ||
keyStoreSpi.engineSetKeyEntry(alias, key, chain); | ||
} | ||
|
||
@Override | ||
public void engineSetCertificateEntry(String alias, Certificate cert) throws KeyStoreException { | ||
keyStoreSpi.engineSetCertificateEntry(alias, cert); | ||
} | ||
|
||
@Override | ||
public void engineDeleteEntry(String alias) throws KeyStoreException { | ||
keyStoreSpi.engineDeleteEntry(alias); | ||
} | ||
|
||
@Override | ||
public Enumeration<String> engineAliases() { | ||
return keyStoreSpi.engineAliases(); | ||
} | ||
|
||
@Override | ||
public boolean engineContainsAlias(String alias) { | ||
return keyStoreSpi.engineContainsAlias(alias); | ||
} | ||
|
||
@Override | ||
public int engineSize() { | ||
return keyStoreSpi.engineSize(); | ||
} | ||
|
||
@Override | ||
public boolean engineIsKeyEntry(String alias) { | ||
return keyStoreSpi.engineIsKeyEntry(alias); | ||
} | ||
|
||
@Override | ||
public boolean engineIsCertificateEntry(String alias) { | ||
return keyStoreSpi.engineIsCertificateEntry(alias); | ||
} | ||
|
||
@Override | ||
public String engineGetCertificateAlias(Certificate cert) { | ||
return keyStoreSpi.engineGetCertificateAlias(cert); | ||
} | ||
|
||
@Override | ||
public void engineStore(OutputStream stream, char[] password) throws CertificateException, IOException, NoSuchAlgorithmException { | ||
keyStoreSpi.engineStore(stream, password); | ||
} | ||
|
||
@Override | ||
public void engineLoad(InputStream stream, char[] password) throws CertificateException, IOException, NoSuchAlgorithmException { | ||
keyStoreSpi.engineLoad(stream, password); | ||
} | ||
} | ||
package es.chiteroman.playintegrityfix; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.security.Key; | ||
import java.security.KeyStoreException; | ||
import java.security.KeyStoreSpi; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.UnrecoverableKeyException; | ||
import java.security.cert.Certificate; | ||
import java.security.cert.CertificateException; | ||
import java.security.cert.X509Certificate; | ||
import java.util.Date; | ||
import java.util.Enumeration; | ||
|
||
public final class CustomKeyStoreSpi extends KeyStoreSpi { | ||
public static KeyStoreSpi keyStoreSpi = null; | ||
private static final String EAT_OID = "1.3.6.1.4.1.11129.2.1.25"; | ||
private static final String ASN1_OID = "1.3.6.1.4.1.11129.2.1.17"; | ||
private static final String KNOX_OID = "1.3.6.1.4.1.236.11.3.23.7"; | ||
|
||
@Override | ||
public Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException { | ||
return keyStoreSpi.engineGetKey(alias, password); | ||
} | ||
|
||
@Override | ||
public Certificate[] engineGetCertificateChain(String alias) { | ||
Certificate[] certificates = keyStoreSpi.engineGetCertificateChain(alias); | ||
// This shouldn't happen... | ||
if (certificates == null) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
// Is certificate chain ? | ||
if (certificates.length > 1) { | ||
if (certificates[0] instanceof X509Certificate x509Certificate) { | ||
if (x509Certificate.getExtensionValue(EAT_OID) != null || x509Certificate.getExtensionValue(ASN1_OID) != null || x509Certificate.getExtensionValue(KNOX_OID) != null) { | ||
EntryPoint.LOG("Certificate chain with dangerous extensions. Throw exception!"); | ||
throw new UnsupportedOperationException(); | ||
} | ||
} | ||
} | ||
return certificates; | ||
} | ||
|
||
@Override | ||
public Certificate engineGetCertificate(String alias) { | ||
return keyStoreSpi.engineGetCertificate(alias); | ||
} | ||
|
||
@Override | ||
public Date engineGetCreationDate(String alias) { | ||
return keyStoreSpi.engineGetCreationDate(alias); | ||
} | ||
|
||
@Override | ||
public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException { | ||
keyStoreSpi.engineSetKeyEntry(alias, key, password, chain); | ||
} | ||
|
||
@Override | ||
public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException { | ||
keyStoreSpi.engineSetKeyEntry(alias, key, chain); | ||
} | ||
|
||
@Override | ||
public void engineSetCertificateEntry(String alias, Certificate cert) throws KeyStoreException { | ||
keyStoreSpi.engineSetCertificateEntry(alias, cert); | ||
} | ||
|
||
@Override | ||
public void engineDeleteEntry(String alias) throws KeyStoreException { | ||
keyStoreSpi.engineDeleteEntry(alias); | ||
} | ||
|
||
@Override | ||
public Enumeration<String> engineAliases() { | ||
return keyStoreSpi.engineAliases(); | ||
} | ||
|
||
@Override | ||
public boolean engineContainsAlias(String alias) { | ||
return keyStoreSpi.engineContainsAlias(alias); | ||
} | ||
|
||
@Override | ||
public int engineSize() { | ||
return keyStoreSpi.engineSize(); | ||
} | ||
|
||
@Override | ||
public boolean engineIsKeyEntry(String alias) { | ||
return keyStoreSpi.engineIsKeyEntry(alias); | ||
} | ||
|
||
@Override | ||
public boolean engineIsCertificateEntry(String alias) { | ||
return keyStoreSpi.engineIsCertificateEntry(alias); | ||
} | ||
|
||
@Override | ||
public String engineGetCertificateAlias(Certificate cert) { | ||
return keyStoreSpi.engineGetCertificateAlias(cert); | ||
} | ||
|
||
@Override | ||
public void engineStore(OutputStream stream, char[] password) throws CertificateException, IOException, NoSuchAlgorithmException { | ||
keyStoreSpi.engineStore(stream, password); | ||
} | ||
|
||
@Override | ||
public void engineLoad(InputStream stream, char[] password) throws CertificateException, IOException, NoSuchAlgorithmException { | ||
keyStoreSpi.engineLoad(stream, password); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.