Skip to content
Snippets Groups Projects
  1. Dec 18, 2020
  2. Dec 15, 2020
  3. Dec 11, 2020
    • Shawn Willden's avatar
      Revert "Revert "Keystore 2.0 SPI: Move keymint spec to security ..." · f5a002c2
      Shawn Willden authored
      Revert "Revert "Keystore 2.0: Move keymint spec to security name..."
      
      Revert "Revert "Keystore 2.0: Move keymint spec to security name..."
      
      Revert^2 "Remove references to keymint1"
      
      34536a352803a08776cc4f373d93a94e1fcbf98e
      
      Bug: 175345910
      Bug: 171429297
      Change-Id: I694e677e4e20419440f12cb7981f0c0c4ca29e08
      f5a002c2
    • Orion Hodson's avatar
      Revert "Keystore 2.0 SPI: Move keymint spec to security namespace." · 6acd9c63
      Orion Hodson authored
      Revert "Keystore 2.0: Move keymint spec to security namespace."
      
      Revert "Keystore 2.0: Move keymint spec to security namespace."
      
      Revert "Move keymint to android.hardware.security."
      
      Revert "Configure CF to start KeyMint service by default."
      
      Revert "Move keymint to android.hardware.security."
      
      Revert "Move keymint to android.hardware.security."
      
      Revert submission 1522123-move_keymint
      
      Reason for revert: Build breakage
      Bug: 175345910
      Bug: 171429297
      Reverted Changes:
      Ief0e9884a:Keystore 2.0: Move keymint spec to security namesp...
      Idb54e8846:Keystore 2.0: Move keymint spec to security namesp...
      I9f70db0e4:Remove references to keymint1
      I2b4ce3349:Keystore 2.0 SPI: Move keymint spec to security na...
      I2498073aa:Move keymint to android.hardware.security.
      I098711e7d:Move keymint to android.hardware.security.
      I3ec8d70fe:Configure CF to start KeyMint service by default.
      Icbb373c50:Move keymint to android.hardware.security.
      I86bccf40e:Move keymint to android.hardware.security.
      
      Change-Id: Icd279f358db2387bf2bf232b0548762fab51e67d
      6acd9c63
  4. Dec 09, 2020
  5. Nov 24, 2020
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: Fix installation of legacy Keystore provider · 9fb56071
      Janis Danisevskis authored
      Priviously we installed the legacy keystore SPI by the name
      KeyStore.AndroidKeyStore and set an alias to
      KeyStore.AndroidKeyStoreLegacy. This conflicted with with the Keystore
      provider which also registers as KeyStore.AndroidKeyStore.
      This patch registers the old provider only by the name
      KeyStore.AndroidKeyStore.
      
      Test: CtsLibcoreTestCases:libcore.java.security.ProviderTest#test_Provider_Properties
            Also, the device boots.
      Change-Id: I38a248a996839f397bdcae30fd1b03a883209df2
      9fb56071
  6. Nov 18, 2020
  7. Nov 14, 2020
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: Install legacy Keystore provider as AndroidKeyStoreLegacy · 4392c697
      Janis Danisevskis authored
      With this patch we install the old Keystore provider as
      AndroidKeyStoreLegacy when the Keystore 2.0 provider is installed as
      AndroidKeyStore. This allows system components to keep using the old
      keystore while we can run CTS tests against the new provider.
      
      The tests are still mostly failing at this point. Installing the new SPI
      can be enabled by setting the property
      ro.android.security.keystore2.enable=true
      
      Bug: 159476414
      Test: This enables running CTS tests against Keystore 2.0.
      Change-Id: I9731d9783ccf8f2705a5ca7335e00c8f4c8debba
      4392c697
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: Evolve the generator SPI. · 940e0516
      Janis Danisevskis authored
      We delegate the generation of self signed certificates to the KeyMint
      backend. Also we use the KeyParamter AIDL type instead of
      KeymasterArguments to construct parameter lists.
      
      Bug: 159476414
      Test: None
      Change-Id: I441a4d4df4ef04e3da8aeaff3274c609d549c979
      940e0516
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: Evolve Factory SPI · e6495d77
      Janis Danisevskis authored
      We no longer need to get the key characteristics from the Keystore
      daemon to construct the KeyInfo for a key. Also we have to extract the
      key info from the KeyParameter AIDL type rather than from the hand
      written KeymasterArguments.
      
      This patch also exposes the correct security level for a key through
      KeyInfo.
      
      Bug: 159476414
      Test: None
      Change-Id: I86a85e481e19fdadfed38a42aeac4ffe5f8b83fa
      e6495d77
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: AndroidKeyStoreProvider loads keys from Keystore 2.0 · 38ab78f0
      Janis Danisevskis authored
      This patch adjusts the AndroidKeyStoreProvider to register all services
      with the correct packages names. And the utility functions load key
      using the correct Keystore 2.0 methods.
      
      Bug: 159476414
      Test: None
      Change-Id: I9268fd66d28e89e188e85991bcf90c7f19809232
      38ab78f0
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: Evolve the Crypto SPI. · 4545933d
      Janis Danisevskis authored
      This patch evolves the Crypto SPI to use the new Keystore 2.0 shim.
      The main changes are:
       * The SPI uses the AIDL defined KeyParameter instead of
         KeymasterArguments.
       * Operations are created directly from the KeystoreSecurityLevel that
         is part of the AndroidKeyStoreKey object.
      
      Also this patch deletes the DeletatingX509Certificate class. This is no
      longer needed, because public key operations are no longer performed by
      Keystore 2.0. We can delegate public certificate operations simply by
      wrapping such certificates into public keys that are understood by other
      providers, such as BouncyCastle.
      
      Bug: 159476414
      Test: None
      Change-Id: Ice874a8121d80bf788da059b4e8420c7dd799d81
      4545933d
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: KeyParameter utilities. · 4be5005c
      Janis Danisevskis authored
      The wire type for key parameters is now generated from AIDL rather than
      the hand written parcelable KeymasterArguments. So we need some of the
      utilities for creating key parameters that the latter provided.
      We also nicked some utility function from KeymasterUtils.
      
      Bug: 159476414
      Test: None
      Change-Id: I12c674b6a00dd3abbed4972d80ceb766a73881e8
      4be5005c
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: Update the chunked streamer. · 4ba9a09b
      Janis Danisevskis authored
      This patch makes the chunked streamer observe the simplified
      Keystore 2.0 operation interface. Keystore is now required to consume
      all supplied data or reject data outright if too much (more than 32KiB)
      is supplied in a single transaction. This allows for a simplified
      streamer logic and a simplified interface. We also no longer send
      entropy to Keystore. This will be handled by the Keystore 2.0 daemon.
      
      Test: None
      Bug: 159476414
      Change-Id: Ie75d10fd5d5ac0da60e23e35467d0a7873230dea
      4ba9a09b
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: KeyStoreCryptoOperationUtils · 27ee56c0
      Janis Danisevskis authored
      Keystore 2.0 does no longer report an error code if an operation
      requires user authorization. Instead this is indicated by sending us
      an operation challenge. In that case we have to check if the
      authorization can possibly succeed. We changed the utility class by
      adding a predicate function that checks exactly that, and we handle
      other errors separately instead of having one exception handling path
      that does all.
      
      Test: None
      Bug: 159476414
      Change-Id: I9a373cf8f0a0b181df54c26fe314d71b6835bb97
      27ee56c0
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: KeyStoreKeys adopt Keystore 2.0 · e5795a90
      Janis Danisevskis authored
      KeyStoreKeys can now be constructed from key entry metadata and key
      descriptors as defined by the new Keystore AIDL spec.
      AndroidKeystorePublicKey can now create the private key proxy.
      KeyStoreKeys also cache the key characteristic, which should drastically
      reduce the frequency by which the SPI has to call into the Keystore 2.0
      daemon.
      
      Test: None
      Bug: 159476414
      Change-Id: Ia0a7841582621897760be49d39dd5442b70b3aa0
      e5795a90
    • Janis Danisevskis's avatar
      Keystore 2.0: Shim around the basic functionality of Keystore 2.0 · ebd964a0
      Janis Danisevskis authored
      This patch adds a shim around the Keystore 2.0 AIDL spec. The new shim
      is modularized like the AIDL spec into the base Keystore module
      Keystore2, the security level specific interface KeystoreSecurityLevel,
      and the operation specific interface KeystoreOperation.
      
      Other system maintenance specific interfaces have yet to be added.
      
      Bug: 159476414
      Bug: 171305684
      Test: None
      Change-Id: I070f73739e4b37ce10568939ac666e40b14a52a8
      ebd964a0
  8. Nov 13, 2020
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: Duplicate Keystore SPI to android.security.keystore2 package · f88d3a4b
      Janis Danisevskis authored
      This patch copies the relevant portion of the Keystore SPI to the new
      package name android.security.keystore2. The purpose of this is to
      illustrate the evolution from the existing Keystore SPI to the
      Keystore 2.0 SPI while keeping the existing Keystore SPI intact.
      Reviewers are advised to check the equivalence of this code to the
      corresponding files in
          android/security/keystore (<-- no 2 here).
      Subsequent patches can them be reviewed as evolution towards the new SPI
      rather than completely new code.
      
      Test: None. When the evolution is complete, Keystore CTS tests can be
      used to check for regressions.
      Bug: 159476414
      
      Change-Id: I21a01a679e789868ce820b5f73221e616a456a61
      f88d3a4b
  9. Nov 12, 2020
  10. Nov 11, 2020
    • Janis Danisevskis's avatar
      Keystore 2.0 SPI: Update KeyInfo and KeyGenParameterSpec · c5bdd77f
      Janis Danisevskis authored
      This patch adds set/getSecurityLevel to KeyInfo and KeyGenParameterSpec
      and it deprecates the superseded function isInSecureHardware.
      
      It also deprecates the system API set/getUid and replaces it with the
      more generic set/getNamespace.
      
      Test: None
      Change-Id: Id2f54596510954862b5077a935f3daf07211f29c
      c5bdd77f
  11. Nov 05, 2020
    • Janis Danisevskis's avatar
      Keystore 2.0: KeyProperties SignaturePadding is now public but hidden · 62c1d286
      Janis Danisevskis authored
      In anticipation of the new Keystore 2.0 SPI we made this nested class
      public (like its siblings) so that the new SPI which resides in a
      different package may access it. It is hidden though because it does not
      constitute public API surface.
      
      Test: None
      Bug: 171305684
      Change-Id: I1dbe3d02c03f97f843813c26c16aaef7152ca478
      62c1d286
    • Janis Danisevskis's avatar
      Keystore SPI: Add SecurityLevelEnum to KeyProperties · d2c944bc
      Janis Danisevskis authored
      This patch adds the SecurityLevelEnum to KeyProperties. This enum can be
      used by the public API surface to express levels of enforcements of key
      properties. And to select a designated residence for a newly generated
      or imported key.
      
      The values UNKNOWN and UNKNOWN_SECURE are used to convey to older target
      APIs API levels that have not been defined when they where published.
      
      Test: None
      Change-Id: I88681f21b8a8ea9a383d32ba99f3ab7d7c8909c3
      d2c944bc
  12. Nov 04, 2020
    • Mathew Inwood's avatar
      Add maxTargetSdk restriction to unused APIs. · 5d123b67
      Mathew Inwood authored
      These are APIs that have @UnsupportedAppUsage but for which we don't
      have any evidence of them currently being used, so should be safe to
      remove from the unsupported list.
      
      Bug: 170729553
      Test: Treehugger
      Merged-In: I626caf7c1fe46c5ab1f39c2895b42a34319f771a
      Change-Id: I54e5ecd11e76ca1de3c5893e3a98b0108e735413
      5d123b67
  13. Oct 27, 2020
    • Janis Danisevskis's avatar
      Keystore SPI: Deprecate encryption flag. · 26c878fb
      Janis Danisevskis authored
      The encryption-required flag is only available in already deprecated
      API KeyPairGeneratorSpec and KeyStoreParameter will be ignored from
      Android S. Keys are and have been encrypted by default for a long time
      and if additional binding to the LSKF is desired it can be requested
      by KeyGenParameterSpec.Builder#setUserAuthenticationRequired(boolean).
      
      Test: None
      Change-Id: I5bd4acb4bba276decd1930ae2e96a55f95627e10
      26c878fb
    • Janis Danisevskis's avatar
      Keystore 2.0: Deprecate Credential prefixes. · 25284387
      Janis Danisevskis authored
      Keystore 2.0 will no longer support free form blobs. Certificates and
      certificate chains will have types fields associated with an alias.
      Other free form blobs will need to be migrated to a different key value
      store.
      
      Bug: 171305684
      Test: None
      Change-Id: I93270f0086329229dc36c2b14c88f229351e6560
      25284387
  14. Oct 23, 2020
  15. Oct 19, 2020
    • Anton Hansson's avatar
      Remove @TestApi from @SystemApi symbols · dd7d52f9
      Anton Hansson authored
      I ran these commands:
          cd frameworks/base
          grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
              's/\@SystemApi[\s\n]+(\@\w+[\s\n]+)?\@TestApi/\@SystemApi\1/gs'
          grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
              's/\@TestApi[\s\n]+(\@\w+[\s\n]+)?\@SystemApi/\1\@SystemApi/gs'
      
      Bug: 171179806
      Test: m checkapi
      Change-Id: I772790b783b0a8730b8bf680c9e569a886b8d789
      Merged-In: I772790b783b0a8730b8bf680c9e569a886b8d789
      dd7d52f9
  16. Aug 20, 2020
    • Max Bires's avatar
      Adding TEST_MAPPING to frameworks/base/keystore · fa76c662
      Max Bires authored
      This file maps to about 4 minutes and 15 seconds of tests within
      Keystore to be added to presubmit.
      
      Fixes: 158797959
      Test: atest --test-mapping
      Change-Id: Ib40cc5106277ca25e08f6922a840924bd6ce4cf3
      fa76c662
  17. Jul 15, 2020
    • Rubin Xu's avatar
      [DO NOT MERGE] Rollup changes from R related to CertInstaller and KeyChain · ac51bf8a
      Rubin Xu authored
      This change includes the following commits that are related to
      CertInstaller and KeyChain:
      
      7a5c8fe4afd KeyChain: Unify manual and programmatic key installation flows
      a894225c7da Added functionality to select type of certificate to be installed from the Settings app
      a9131939a35 Add KeyChain.KEY_ALIAS_SELECTION_DENIED constant.
      485be505f19 Fix KeyChain.KEY_ALIAS_SELECTION_DENIED
      
      Bug: 161347472
      Test: builds & manual testing
      Change-Id: I560bade479b41a5b88f81ea6dfdecba689c2f4ad
      ac51bf8a
  18. Jun 17, 2020
    • Janis Danisevskis's avatar
      Preserve interrupted state across waiting for future · edcacd53
      Janis Danisevskis authored
      A normal synchronous binder call would not be influenced by an
      interrupted thread. With the move to asynchronous keystore IPC we wait
      on a future which can throw an interrupted exception. The Java crypto
      API does not expect the implementation to throw interrupted exceptions
      though. So to preserve the expected behavior we wrap the Future.get()
      calls in a loop that handles the interrupted exception and sets the
      interrupted state after the get completed successfully.
      
      Bug: 147398412
      Bug: 155254932
      Test: atest android.keystore.cts.CipherTest#testEncryptsAndDecryptsInterrupted
      Change-Id: I066180e8028cc426fa1b3739fa007faa17c8c012
      Merged-In: I066180e8028cc426fa1b3739fa007faa17c8c012
      edcacd53
  19. May 20, 2020
    • Eran Messeri's avatar
      Update KeyChain.createInstallIntent documentation · cdcbb66b
      Eran Messeri authored
      Update the KeyChain.createInstallIntent method documentation to reflect
      the change where CA certificates can no longer be installed using
      this intent.
      
      Bug: 156941631
      Test: m docs
      Change-Id: I3cf2c677c4c772698c8df5f25224dd67d12b5606
      cdcbb66b
  20. May 19, 2020
    • Janis Danisevskis's avatar
      Preserve interrupted state across waiting for future · 3230a488
      Janis Danisevskis authored
      A normal synchronous binder call would not be influenced by an
      interrupted thread. With the move to asynchronous keystore IPC we wait
      on a future which can throw an interrupted exception. The Java crypto
      API does not expect the implementation to throw interrupted exceptions
      though. So to preserve the expected behavior we wrap the Future.get()
      calls in a loop that handles the interrupted exception and sets the
      interrupted state after the get completed successfully.
      
      Bug: 147398412
      Bug: 155254932
      Test: atest android.keystore.cts.CipherTest#testEncryptsAndDecryptsInterrupted
      Change-Id: I066180e8028cc426fa1b3739fa007faa17c8c012
      (cherry picked from commit 022c8ef7)
      3230a488
  21. May 15, 2020
    • Dorin Drimus's avatar
      Attest device base properties · 9d5b804e
      Dorin Drimus authored
      Add API to allow inclusion of device base properties to the
      attestation certificate generated with a Key in Keystore.
      
      Test: atest KeyAttestationTest
      Bug: 152945378
      
      Change-Id: Iaf282709f800501aa4c988ebf51cf3238583f9b6
      9d5b804e
  22. May 13, 2020
    • Daulet Zhanguzin's avatar
      Remove DERInteger usages · d3d06cee
      Daulet Zhanguzin authored
      Not really used in AndroidKeyStore
      
      Test: Treehugger
      Bug: 154796679
      Change-Id: Id21b256b3221fd4353401c81e538a46b2f7c6246
      d3d06cee
  23. Apr 27, 2020
    • Max Bires's avatar
      Fixing default timeout constant · 919a9d6d
      Max Bires authored
      The getKeyInfo check was not updated to use the new integer representing
      an auth per operation key.
      
      Bug: 152618140
      Test: atest AuthBoundKeyTest
      Change-Id: Ifa6d37ac878ba267761ed7ae32c544cd4b662d25
      919a9d6d
  24. Mar 19, 2020
    • Rubin Xu's avatar
      RESTRICT AUTOMERGE · 576c4d81
      Rubin Xu authored
      Update keyguard locked state from TrustManagerService
      
      TrustManagerService holds the ground truth about whether a user is
      locked or not, so update keystore using the information there,
      instead of doing it from KeyguardStateMonitor. This fixes the issue
      of work profile locked state not being correctly pushed to keystore.
      
      Note: since this change is likely to be backported as a security
      patch, I'm refraining from doing major refactoring right now.
      
      Bug: 141329041
      Bug: 144430870
      Test: manually with KeyPairSampleApp
      Change-Id: I3472ece73d573a775345ebcceeeb2cc460374c9b
      (cherry picked from commit f9418dbb)
      576c4d81
  25. Mar 17, 2020
    • Max Bires's avatar
      Fixing how SIDs are added to keys during generation time · 1cfd95ec
      Max Bires authored
      SIDs were not being properly applied to key parameters under the new
      authentication rework. Now that biometric/credential unlocks are valid
      for either auth-per-op or timeout auth bound keys, the SIDs need to be
      tacked on appropriately in each authentication flow.
      
      Bug: 148425329
      Test: CtsVerifier
      Change-Id: I73733b00d2da5ac78db6d77c53de144f4473bb54
      1cfd95ec
Loading