summaryrefslogtreecommitdiff
path: root/keystore/java/android/security/AndroidKeyStore.java
AgeCommit message (Collapse)Author
2015-05-13Move Android Keystore impl to android.security.keystore.Alex Klyubin
This moves the non-public API classes backing Android Keystore from android.security to android.security.keystore, a package specially created for Android Keystore. Bug: 18088752 Change-Id: Ibf04d6a26c54d310b0501fc5e34f37b1176324ad
2015-05-13New AndroidKeyStore API in android.security.keystore.Alex Klyubin
This CL addresses the comments from API Council about Android KeyStore KeyPairGeneratorSpec, KeyGeneratorSpec and KeyStoreParameter: 1. These abstractions should not take or hold references to Context. 2. The Builders of these abstractions should take all mandatory parameters in their constructors rather than expose them as setters -- only optional paratemers should be exposed via setters. These comments cannot be addressed without deprecation in the already launched KeyPairGeneratorSpec and KeyStoreParameter. Instead of deprecating just the getContext methods and Builder constructors, this CL goes for the nuclear option of deprecating KeyPairGeneratorSpec and KeyStoreParameter as a whole and exposing all of the AndroidKeyStore API in the new package android.security.keystore. This enables this CL to correct all of the accrued design issues with KeyPairGeneratorSpec (e.g., naming of certificate-related methods) and KeyStoreParameter. This also makes the transition to API Level M more clear for existing users of the AndroidKeyStore API. These users will only have to deal with the new always-mandatory parameters (e.g., purposes) and sometimes-mandatory (e.g., digests, block modes, paddings) if they switch to the new API. Prior to this CL they would've had to deal with this if they invoked any of the new methods of KeyPairGeneratorSpec or KeyStoreParameter introduced in API Level M. This CL rips out all the new API introduced into KeyPairGeneratorSpec and KeyStoreParameter classes for Android M, thus reverting these classes to the API launched in L MR1. This is because the new API is now in android.security.keystore.KeyGenParameterSpec and KeyProtection respectively. Bug: 21039983 Change-Id: I59672b3c6ef7bc25c40aa85f1c47d9d8a05d627c
2015-05-13Ensure key algorithm name of HMAC keys is preserved.Alex Klyubin
When Android KeyStore loads an HMAC key, it needs to compose the JCA key algorithm name (e.g., HmacSHA256) based on the digests the key is authorized for. A key can be authorized for multiple digests. Thus, the approach is to use the first one for constructing the JCA key algorithm name. This CL ensures that when importing HMAC keys the first KM_TAG_DIGEST tag is set to the digest of the JCA key algorithm name. Bug: 18088752 Change-Id: I911ca7427b249ee823d06e988687af6146ebaff8
2015-05-12Flatten KeyStoreKeyProperties constants.Alex Klyubin
This moves constants/flags declared in inner classes of KeyStoreKeyProperties into KeyStoreKeyProperties, as requested by API Council. Bug: 21039983 Change-Id: I84a3c983e13644a027bed9f605ab8044220a352c
2015-05-08Document when encrypted AndroidKeyStore keys are wiped.Alex Klyubin
This also drops the boolean parameter from KeyGeneratorSpec.Builder.setEncryptionRequired to match the already launched KeyPairGeneratorSpec.Builder.setEncryptionRequired. Bug: 18088752 Change-Id: I91a3e8c77958971b1bda8329319f1a0d8043b669
2015-05-06Define String constants for AndroidKeyStore crypto.Alex Klyubin
This defines the String enum values based on JCA standard names for key algorithm, block mode, padding schemes, and digests. This should make it safer to interact with AndroidKeyStore code that uses JCA strings. This was requested by API Council. Bug: 18088752 Change-Id: I241d9225a13b85479d0a84e49d0a98cbc77e5817
2015-04-30Track Keymaster changes.Alex Klyubin
* MAC length is now specified as a parameters to the begin operation instead of as a parameter at key generation/import time. * KM_TAG_MAC_LENGTH is now in bits instead of in bytes. Change-Id: I752fe232d11d3ac39a575a48948215d84ded8fb9
2015-04-28Align AndroidKeyStore API with user auth API.Alex Klyubin
This simplifies the AndroidKeyStore API around user authentication: no more explicit control over which user authenticators are bound to which keys. User-authenticated keys with timeout are unlocked by whatever unlocks the secure lock screen (currently, password/PIN/pattern or fingerprint). User-authenticated keys that need authentication for every use are unlocked by fingerprint only. Bug: 20526234 Bug: 20642549 Change-Id: I1e5e6c988f32657d820797ad5696797477a9ebe9
2015-04-16Set Secure User ID from app level.Alex Klyubin
When AndroidKeyStore keys require used authentication, they need to be bound to a Keymaster's Secure User ID. This ID will be set by keystore soon. Until then, set it from the framework level (i.e., from apps which use AndroidKeyStore). NOTE: Accessing gatekeeper to obtain the Secure User ID will be blocked by SELinux policy. To test this code, disable SELinux enforcing mode. Bug: 18088752 Change-Id: I7a3315eb52f0fc978d14d5d0e9613f2f36c6c01e
2015-04-15am 763100e6: am 1cb119d3: am 71ba4e46: Merge "Unbreak obtaining symmetric ↵Shawn Willden
keys from AndroidKeyStore." * commit '763100e6442494a85cfcb7949c8021836071b1f6': Unbreak obtaining symmetric keys from AndroidKeyStore.
2015-04-14Unbreak obtaining symmetric keys from AndroidKeyStore.Alex Klyubin
This tracks 59f977c6988e21b3b8aa6c83428bd6ee1a98816d due to which AndroidKeyStore is unable to provide symmetric keys because it assumes that the digest field is not repeating. Bug: 18088752 Change-Id: Ie8ed01449280b7c759e81aeaf2066953b0abaf2a
2015-04-13resolved conflicts for merge of a978a3d6 to masterAlex Klyubin
Change-Id: Ifd7ca9e1dfa0d50a87f2bafef377fcaeb5d9f6d5
2015-04-13Use JCA names for block modes, paddings, and digests.Alex Klyubin
This replaces int-based enums from KeyStoreKeyConstraints with String values commonly used in JCA API. As part of under the hood refactoring: * KeyStoreKeyCharacteristics and KeyStoreKeyConstraints have been merged into KeyStoreKeyProperties. * KeymasterUtils methods operating on KeymasterArguments and KeymasterCharacteristics have been moved to their respective classes. Bug: 18088752 Change-Id: I9c8b984cb3c28184adb617e34d87f2837bd1d3a1
2015-04-09resolved conflicts for merge of b9a9d46c to masterAlex Klyubin
Change-Id: Ibec45f0f8f9618dd7bd1b34561dccbdd9599cdeb
2015-04-08Require IND-CPA by default for new AndroidKeyStore keys.Alex Klyubin
Bug: 18088752 Change-Id: I01e44b7155df4326b5c9d83dda57f889c1f23ec7
2015-04-07resolved conflicts for merge of 06adabdb to masterAlex Klyubin
Change-Id: Ifb09e2e6242f79cabe76e95eacc982f6cc7e1a6c
2015-04-07Make the new AndroidKeyStore API conformant.Alex Klyubin
This makes the new AndroidKeyStore API conform with the latest Keymaster API changes as well as the latest Android framework API design guidelines. Keymaster changes: * Multiple paddings, block modes, and digests can be set on a key. * "max uses per boot" and "min seconds between use" restrictions will not be exposed in the framework API. * Padding scheme ZERO will not be exposed. Changes due to Android framework design guidelines: * Sets of enum values have been replaced with bitsets represented as ints. * Integer has been replaced with int, with null being represented with a special value (e.g., -1 or 0) where possible. Bug: 18088752 Change-Id: Ib21739aa9b42d48895cb7a681e836a5c6d972ac6
2015-04-01Add fingerprint-specific AndroidKeyStore API.Alex Klyubin
Bug: 18088752 Change-Id: I333d3ffc820d28ae678e28dafc2e8a24cb7eb073
2015-04-01Use Keymaster-friendly validity dates.Alex Klyubin
Keymaster HAL currently requires that key validity start and end dates always be specified. The framework API does not. This CL expresses the framework API's "not specified" instants to Keymaster as instants in distant past or future. Bug: 18088752 Change-Id: Ia9d66d5e57bfca30628cdef6e0925a2781a3acfb
2015-03-31Hook in user authenticators and their exceptions.Alex Klyubin
Bug: 18088752 Change-Id: I2835dbe51d09587a3081597c6aaf536aa1427e24
2015-03-31Add unauthenticated AES ciphers backed by AndroidKeyStore.Alex Klyubin
This adds the following AES transformations: * AES/ECB/NoPadding * AES/ECB/PKCS7Padding * AES/CBC/NoPadding * AES/CBC/PKCS7Padding * AES/CTR/NoPadding Bug: 18088752 Change-Id: I3e4702e59868f8f2225c31b1c159d20008b9999d
2015-03-30Add HmacSHA256 backed by AndroidKeyStore.Alex Klyubin
This also adds the MAC length constraint on imported HMAC keys. HMAC doesn't work without this constraint at the moment. Bug: 18088752 Change-Id: I8613f58f5d2a84df00bcf6179d13e30619440330
2015-03-26Symmetric key import for AndroidKeyStore.Alex Klyubin
AES and HmacSHA256 symmetric keys can now be imported into AndroidKeyStore. These keys cannot yet be used. Bug: 18088752 Change-Id: Iad2fd49d15ac4c2d676abe1153f5b5f0b6ff496c
2013-04-29resolved conflicts for merge of 1f6e789b to jb-mr2-dev-plus-aospKenny Root
Change-Id: I06c05d637613215b6d83df3e29cd495f6a5a0176
2013-04-29Track change to JSSE providerKenny Root
Change-Id: I35e824e47ad758ab6408e91e2ba5dcda053a82f5
2013-04-18Rename API AndroidKey* -> Key*Kenny Root
Bug: 8657552 Change-Id: Id9102b7c2c2f6d27fba7645f0629750cfe1eb510
2013-04-15AndroidKeyStore: Add encrypted flagKenny Root
Add the encrypted flag for the KeyPairGenerator and the KeyStore so that applications can choose to allow entries when there is no lockscreen. (partial cherry pick from commit 2eeda7286f3c7cb79f7eb71ae6464cad213d12a3) Bug: 8122243 Change-Id: I5ecd9251ec79ec53a3b68c0fff8dfba10873e36e
2013-04-12AndroidKeyStore: Add encrypted flagKenny Root
Add the encrypted flag for the KeyPairGenerator and the KeyStore so that applications can choose to allow entries when there is no lockscreen. Bug: 8122243 Change-Id: Ia802afe965f2377ad3f282dab8c512388c705850
2013-03-20KeyStore: add API to uid versionsKenny Root
In previous commits, we added the ability to specify which UID we want to target on certain operations. This commit adds the ability to reach those binder calls from the KeyStore class. Also fix a problem where saw() was not reading all the values returned via the Binder call. This changes the semantics to return a null instead of failing silently when it's not possible to search. Change-Id: I32098dc0eb42e09ace89f6b7455766842a72e9f4
2013-01-22Track libcore changes for OpenSSLKeyKenny Root
Change-Id: I39f60c34daa9ccc633efb02988ea238a84e6bbf1
2012-08-31Add some NullPointerExceptions to AndroidKeyStoreKenny Root
Existing KeyStore implementations throw NullPointerExceptions beacuse the KeyStoreSpi doesn't check these arguments for null. Add in checks so we don't accidentally check some bogus values. Also switch a RuntimeException to a KeyStoreException Change-Id: I18f4d4474d607cb2057ea8069b901e0992275e78
2012-08-22Add ability to replace chain for PrivateKeyEntryKenny Root
For the AndroidKeyStore API, allow entries to have their certificate chain replaced without destroying the underlying PrivateKey. Since entries are backed by unexportable private keys, requiring them to be supplied again doesn't make sense and is impossible. Change-Id: I629ce2a625315c8d8020a082892650ac5eba22ae
2012-08-22Add KeyPairGenerator for Android keystoreKenny Root
This allows end-users to generate keys in the keystore without the private part of the key ever needing to leave the device. The generation process also generates a self-signed certificate. Change-Id: I114ffb8e0cbe3b1edaae7e69e8aa578cb835efc9
2012-08-20Add AndroidKeyStore provider for KeyStore APIKenny Root
This introduces a public API for the Android keystore that is accessible via java.security.KeyStore API. This allows programs to store PrivateKeyEntry and TrustedCertificateEntry items visible only to themselves. Future work should include: * Implement KeyStore.CallbackHandlerProtection parameter to allow the caller to request that the keystore daemon unlock itself via the system password input dialog. * Implement SecretKeyEntry once that support is in keystore daemon Change-Id: I382ffdf742d3f9f7647c5f5a429244a340b6bb0a