How to convert public and private keys to keystore

Step 1: Generate Keystore package keyTools; import java.io.FileOutputStream; import java.math.BigInteger; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.KeyStore; import java.security.Provider; import java.security.Provider.Service; import java.security.Security; import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.util.Date; import java.util.Iterator; import java.util.Set; import org.bouncycastle.jce.X509Principal; import org.bouncycastle.x509.X509V3CertificateGenerator; public class PKCS12KeyStoreExample {<!– –> public static void genP12() {<!– –> try {<!– –> // Generate key pair KeyPairGenerator […]

Practical analysis of dump and strace commands causing watchdog problems caused by keystore deadlock

1. Problem description Recently, a system stuck problem occurred. It is speculated that a watchdog appears in system_server. Looking at the watchdog file, it is PackageManager stuck in the KeyStore.clearUid() interface: —– pid 1091 at 2023-10-26 09:40:10 —– Cmd line: system_server ABI: ‘arm64’ “PackageManager” sysTid=1352 #00 pc 000000000006e1c4 /system/lib64/libc.so (__ioctl + 4) #01 pc 00000000000290d0 […]

Android KeyStore key import

Source code reference: https://android.googlesource.com/platform/cts/ + /master/tests/tests/keystore/src/android/keystore/cts/ImportWrappedKeyTest.java Auxiliary source code reference: https://android.googlesource.com/platform/frameworks/base/ + /master/core/java/android/security/keymaster/KeymasterDefs.java https://android.googlesource.com/platform/hardware/interfaces/ + /refs/heads/main/security/keymint/aidl/aidl_api/android.hardware.security.keymint/1/android/hardware/security/keymint/ The source code test is as follows: import android.security.keystore.KeyGenParameterSpec; import android.security.keystore.KeyProperties; import android.security.keystore.SecureKeyImportUnavailableException; import android.security.keystore.WrappedKeyEntry; import android.util.Log; import org.bouncycastle.asn1.ASN1Encoding; import org.bouncycastle.asn1.DEREncodableVector; import org.bouncycastle.asn1.DERInteger; import org.bouncycastle.asn1.DERNull; import org.bouncycastle.asn1.DEROctetString; import org.bouncycastle.asn1.DERSequence; import org.bouncycastle.asn1.DERSet; import org.bouncycastle.asn1.DERTaggedObject; import org.bouncycastle.util.Arrays; import org.bouncycastle.util.encoders.Hex; import java.security.Key; […]

[AES symmetric encryption KeyStore uses EhCache]

AES symmetric encryption and KeyStore data storage and reading, EhCache storage information AES symmetric encryption and decryption KEYSTORE store read information KEYSTORE stores and reads key information related import EhCache uses AES symmetric encryption and decryption /** * AES symmetric encryption, decryption test */ public static void aesTest() {<!– –> String plainText = “TCBJ-SECRET-KEY-ENCODE-DECODE-TEST”; try […]

[Java executable commands] (11) Java keystore and certificate management tool keytool: play with keystore and certificate management, and deeply analyze the application and skills of keytool tools~

keytool for Java executable commands 1 concept 2 Advantages and disadvantages 3 use 3.1 Syntax format 3.2 Generate a certificate request: keytool -certreq 3.3 Export certificate: keytool -exportcert 3.4 Generate a key pair: keytool -genkeypair 3.5 Import certificate or certificate chain: keytool -importcert 3.6 List the entries in the keystore: keytool -list 4 Application scenarios […]

Use of Android KeyStore

During our App development process, some sensitive and secure data may need to be encrypted, such as the storage of login tokens. We often use some encryption algorithms to encrypt these sensitive data and then save them, and then decrypt them when they need to be taken out. At this point, there will be a […]

[Solved] Android compilation and packaging error Invalid keystore format

Problem description Running an old open source project, the following error occurs when compiling. java.io.IOException: Invalid keystore format Execution failed for task ‘:app:transformDexWithInstantRunDependenciesApkForDebug’. > com.android.build.api.transform.TransformException: com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store “C:\Users\ado\.android\debug.keystore”: Invalide keystore format Solution According to the error message, there is a problem with the signature format of debug. We only […]