Table of Contents

[hemmerling] Google Android 13/14 - App Development IV

Related pages:

1 Key Generation

1.1 Key Generation with MIT App Inventor

Instructions

Equivalent "Keytool" Call

keytool -genkeypair -v -keystore hemmerling.keystore -alias androidkey -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=hemmerling@gmx.net, O=AppInventor for Android, C=US" -storepass android -keypass android

Result

Keystore type: PKCS12
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: androidkey
Creation date: 27.04.2025
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=hemmerling@gmx.net, O=AppInventor for Android, C=US
Issuer: CN=hemmerling@gmx.net, O=AppInventor for Android, C=US
Serial number: 33680388
Valid from: Sun Apr 27 07:12:57 CEST 2025 until: Thu Sep 12 07:12:57 CEST 2052
Certificate fingerprints:
         SHA1: 
         SHA256: 
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 3

Extensions:

#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 
0010: 
]
]



*******************************************
*******************************************

1.2 Key Generation with Android Studio

Instructions

Equivalent "Keytool" Call

keytool -genkeypair -v -keystore hemmerling.keystore -alias androidkey -keyalg RSA -keysize 2048 -validity 9125 -dname "CN=Rolf Hemmerling, OU=http://hemmerling.com O=Dipl.-Ing.(FH) Hemmerling, C=DE" -storepass android -keypass android

Result

Keystore type: PKCS12
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: androidkey
Creation date: 27.04.2025
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: C=DE, ST=NRW, L=Bielefeld, O=Dipl.-Ing.(FH) Hemmerling, OU=http://hemmerling.com, CN=Rolf Hemmerling
Issuer: C=DE, ST=NRW, L=Bielefeld, O=Dipl.-Ing.(FH) Hemmerling, OU=http://hemmerling.com, CN=Rolf Hemmerling
Serial number: 1
Valid from: Sun Apr 27 08:23:52 CEST 2025 until: Thu Apr 21 08:23:52 CEST 2050
Certificate fingerprints:
         SHA1: 
         SHA256: 
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 1


*******************************************
*******************************************

1.3 Key Generation with Keytool

Instructions

keytool -genkeypair -v -keystore hemmerling.keystore -alias androidkey -keyalg RSA -keysize 2048 -validity 9125 -dname "CN=Rolf Hemmerling, OU=http://hemmerling.com O=Dipl.-Ing.(FH) Hemmerling, C=DE" -storepass android -keypass android

Result

Some other Examples of Keytool Commands ( COMMAND.COM & Powershell Batch File )

@del hemmerling.keystore
keytool -genkeypair -v -keystore hemmerling.keystore -alias androidkey -keyalg RSA -keysize 2048 -validity 9125 -dname "CN=Rolf Hemmerling, OU=http://hemmerling.com O=Dipl.-Ing.(FH) Hemmerling, C=DE" -storepass android -keypass android
keytool -list -v -keystore hemmerling.keystore -storepass android
pause
keytool -storepasswd -keystore hemmerling.keystore -storepass android -new android2
pause
keytool -storepasswd -keystore hemmerling.keystore -storepass android2 -new android
@echo *********
@echo Attention: -keypasswd commands not supported if -storetype is PKCS12
@echo *********
pause
keytool -keypasswd -keystore hemmerling.keystore -storepass android -alias android -keypass android -new android2

2 PEPK - Play Encrypt Private Key

Download

Instructions

java -jar pepk.jar --keystore=hemmerling_as.keystore --alias=androidkey  --keystore-pass android --key-pass android --output=hemmerling_as.zip --rsa-aes-encryption --encryption-key-path=encryption_public_key.pem

3 apksigner

File Location

Documentation

3 Upload to Google Developer Console

Google Play Developer Console

"Use existing app signing key from Java keystore" - Failure

"Use existing app signing key from another repository" - Failure

Error message “The encryption key used has expired. Use a newly generated encryption key”

Resources

Keytool

Keytool Help Screens

Documentation

Locations in Filesystem

Resources

PEPK

PEPK Help Screen

USAGE:
       java -jar pepk.jar
         --keystore <release_keystore>
         --alias <key_alias>
         --output=<output_file>
         (--rsa-aes-encryption --encryption-key-path=</path/to/encryption_public_key.pem> | --encryptionkey=<encryption_key_hex>)
         [--signing-keystore <keystore> [--signing-key-alias=<alias>]]
         [--include-cert]

pepk (Play Encrypt Private Key) is a tool for exporting private keys from a
Java Keystore and encrypting them for transfer to Google Play as part of
enrolling in App Signing by Google Play.


        REQUIRED FLAGS

--keystore            Path to the keystore containing the private key to export.

--alias               Alias of the private key in the keystore.

--output              File in which to output the encrypted private key.

        OPTIONAL FLAGS

--keystore-pass       Password for the keystore. If not set, will be prompted on
                      the command line.

--key-pass            Password for the key inside the keystore. If not set, the
                      same password as the keystore will be used, or if none was
                      set, it will be prompted on the command line.

--signing-keystore    Path to the keystore containing the private key that will
                      be used for signing the exported encrypted private key.

--signing-key-alias   Alias of the private key used for signing in the
                      signing Keystore. Must be specified if --signing-keystore
                      flag is set.

--rsa-aes-encryption  Use RSA AES Key Wrap encryption for encrypting the
                      private key.

--encryption-key-path Path to the PEM-encoded public key to be used for
                      encrypting the private key. Must be specified if
                      --rsa-aes-encryption is set.

--encryptionkey       Public key to encrypt the private key with. This will be
                      the hex encoded bytes of the public key. The public key
                      is a 4-byte identity followed by a 64-byte P256 point.
                      Must be specified if --rsa-aes-encryption is not set.

--include-cert        Include the public certificate to be exported along with
                      the encrypted private key.

        OTHER OPTIONS

--help                Show this usage page and exit.

--license             Show the license for the tool and exit.

Documentation


When this document changes ! Site Navigation ( My Business ! My Topics ! Imprint / Contact ! Privacy Policy ! Keyword Index ! ! Google+ Publisher "hemmerling" )