platform_build/target/product/security
Daniel Zhang b46b840e18 Add instructions to generate java keystore
copied from commit message packages/inputmethods/LatinIME c884b6631f5d13637167f6bc66bbb81e6a00bd8f

Change-Id: Ie3d48041004930ca5e62c442778eb915fb99d257
Signed-off-by: Daniel Zhang <danielzhang130@gmail.com>
Test: none
2024-05-27 01:30:15 +00:00
..
Android.bp Fix licenses and license texts. 2022-01-24 16:19:41 -08:00
Android.mk Remove verity.mk, verity_key, PRODUCT_VERITY_SIGNING_KEY 2022-08-11 08:12:58 +00:00
bluetooth.pk8 Copy com_google_android_bluetooth_services certs for sepolicy 2022-03-30 12:53:40 -07:00
bluetooth.x509.pem Copy com_google_android_bluetooth_services certs for sepolicy 2022-03-30 12:53:40 -07:00
BUILD.bazel Make android_certificate_directory public 2023-04-04 14:09:27 -07:00
cts_uicc_2021.pk8 Create a new certificate for 2021 CTS UICCs. 2021-04-14 14:11:49 -07:00
cts_uicc_2021.x509.pem Create a new certificate for 2021 CTS UICCs. 2021-04-14 14:11:49 -07:00
fsverity-release.x509.der Add fsverity release cert 2020-04-17 10:27:42 -07:00
media.pk8
media.x509.pem
networkstack.pk8 Add test keys for networkstack 2019-02-13 00:57:41 +09:00
networkstack.x509.pem Add test keys for networkstack 2019-02-13 00:57:41 +09:00
nfc.pk8 Copy com_android_nfc certs for sepolicy rule 2024-01-19 10:23:14 -08:00
nfc.x509.pem Copy com_android_nfc certs for sepolicy rule 2024-01-19 10:23:14 -08:00
platform.pk8
platform.x509.pem
README Add instructions to generate java keystore 2024-05-27 01:30:15 +00:00
sdk_sandbox.pk8 Cherry pick sdk_sandbox dev keys. 2022-03-16 15:39:41 +01:00
sdk_sandbox.x509.pem Cherry pick sdk_sandbox dev keys. 2022-03-16 15:39:41 +01:00
shared.pk8
shared.x509.pem
testkey.pk8
testkey.x509.pem

For detailed information on key types and image signing, please see:

https://source.android.com/devices/tech/ota/sign_builds.html

The test keys in this directory are used in development only and should
NEVER be used to sign packages in publicly released images (as that would
open a major security hole).

key generation
--------------

The following commands were used to generate the test key pairs:

  development/tools/make_key testkey       '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
  development/tools/make_key platform      '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
  development/tools/make_key shared        '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
  development/tools/make_key media         '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
  development/tools/make_key cts_uicc_2021 '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'

signing using the openssl commandline (for boot/system images)
--------------------------------------------------------------

1. convert pk8 format key to pem format
   % openssl pkcs8 -inform DER -nocrypt -in testkey.pk8 -out testkey.pem

2. create a signature using the pem format key
   % openssl dgst -binary -sha1 -sign testkey.pem FILE > FILE.sig

extracting public keys for embedding
------------------------------------

dumpkey.jar is a Java tool that takes an x.509 certificate in PEM format as
input and prints a C structure to standard output:

    $ java -jar out/host/linux-x86/framework/dumpkey.jar build/make/target/product/security/testkey.x509.pem
    {64,0xc926ad21,{1795090719,2141396315,950055447,2581568430,4268923165,1920809988,546586521,3498997798,1776797858,3740060814,1805317999,1429410244,129622599,1422441418,1783893377,1222374759,2563319927,323993566,28517732,609753416,1826472888,215237850,4261642700,4049082591,3228462402,774857746,154822455,2497198897,2758199418,3019015328,2794777644,87251430,2534927978,120774784,571297800,3695899472,2479925187,3811625450,3401832990,2394869647,3267246207,950095497,555058928,414729973,1136544882,3044590084,465547824,4058146728,2731796054,1689838846,3890756939,1048029507,895090649,247140249,178744550,3547885223,3165179243,109881576,3944604415,1044303212,3772373029,2985150306,3737520932,3599964420},{3437017481,3784475129,2800224972,3086222688,251333580,2131931323,512774938,325948880,2657486437,2102694287,3820568226,792812816,1026422502,2053275343,2800889200,3113586810,165549746,4273519969,4065247892,1902789247,772932719,3941848426,3652744109,216871947,3164400649,1942378755,3996765851,1055777370,964047799,629391717,2232744317,3910558992,191868569,2758883837,3682816752,2997714732,2702529250,3570700455,3776873832,3924067546,3555689545,2758825434,1323144535,61311905,1997411085,376844204,213777604,4077323584,9135381,1625809335,2804742137,2952293945,1117190829,4237312782,1825108855,3013147971,1111251351,2568837572,1684324211,2520978805,367251975,810756730,2353784344,1175080310}}

This is called by build/make/core/Makefile to incorporate the OTA signing keys
into the recovery image.

converting to java keystore for Android Studio
----------------------------------------------

Suppose we want to convert shared.pk8 and shared.x509.pem to shared.keystore.

 $ openssl pkcs8 -inform DER -nocrypt                      \
   -in build/make/target/product/security/shared.pk8       \
   -out shared.pem
 $ openssl pkcs12 -export                                  \
   -in build/make/target/product/security/shared.x509.pem  \
   -inkey shared.pem -out shared.p12                       \
   -password pass:android -name AndroidDebugKey
 $ keytool -importkeystore -deststorepass android          \
   -destkeystore shared.keystore -srckeystore shared.p12   \
   -srcstoretype PKCS12 -srcstorepass android

The keystore can be used in build.gradle as follows.

signingConfigs {
    shared {
        storeFile file("shared.keystore")
        storePassword "android"
        keyPassword "android"
        keyAlias "AndroidDebugKey"
    }
}