Commit Graph

96 Commits

Author SHA1 Message Date
Chad Brubaker
5bbf04803f Allow uid to be passed for more operations
This expands get, getmtime, exportKey, getKeyCharacteristcs and begin to
accept a uid to run as. This is only for system to use keys owned by
Wifi and VPN, and not something that can be used to do operations as
another arbitrary application.

Bug: 23978113
Change-Id: I06aa089859edc934a5415e3b184b917d6d171ae2
2015-09-10 15:34:11 -07:00
Alex Klyubin
a95550f801 Add KM_MIN_MAC_LENGTH tag to HMAC and AES-GCM keys.
This makes Android Keystore add the KM_MIN_MAC_LENGTH tag to generated
and imported HMAC and AES-GCM keys. This tag specifies the minimum
length of the MAC/authentication tag authorized to be used for the
key.

For HMAC keys the minimum MAC length is set to the length of the
digest associated with the key (HMAC keys are authorized for exactly
one digest). For AES keys the minimum authetication tag length is set
to 96 bit. This is the minimum supported by Android Keystore's AES-GCM
implementation.

Bug: 22337277
Change-Id: Ic6e47cf084734d1592788dc58088889f7fff74eb
2015-07-16 16:52:51 -07:00
Alex Klyubin
c781405f43 Merge "Use standard copyright banner in android/security/keymaster." into mnc-dev 2015-06-25 15:07:28 +00:00
Alex Klyubin
8effa36ca6 Use standard copyright banner in android/security/keymaster.
Bug: 18088752
Change-Id: I22eec18130cc46222d50481164069e7714154979
2015-06-24 16:06:55 -07:00
Alex Klyubin
3e7a9e4ec6 Track rename of INT and LONG Keymaster tag types.
Bug: 22008538
Change-Id: Id0091e59738c828a96305edbfc4f3958e712278b
2015-06-24 15:46:45 -07:00
Alex Klyubin
ae6cb7aad5 Keymaster INT, LONG and DATE tag values are unsigned.
This CL ensures that Android Keystore framework code complies with
signedness of keymaster tags. In particular:
* INT tags are unsigned 32-bit numbers, and
* LONG and DATE tags are unsigned 64-bit numbers.

The ensure compliance, KeymasterArguments and KeyCharacteristics
classes through which Android Keystore interacts with Keymaster tags
have been modified as follows:
* ENUM and INT tags which used to be conflated are now added/queried
  via separate methods, because ENUM can remain represented as an int
  data type whereas INT is now represented as a long data type with
  permitted range being [0; 2^32).
* Methods for adding/quering LONG tags have been switched from the long
  data type to the BigInteger data type and now ensure that the value
  is in the permitted [0; 2^63).
* Methods for adding/querying DATE tags now ensure the Date value is
  in the permitted range [0; 2^63) ms since Unix epoch.
* Methods for adding tags throw an IllegalArgumentException if the tag
  type is unsuitable for the method. This is to ensure that tags with
  invalid values cannot be added through similar methods (e.g., INT tag
  added via an ENUM tag addition method invoked with a negative value).

Bug: 22008538
Change-Id: I6eefd5cbb561cc52d27de952691af4d9d5e1af1e
2015-06-23 20:04:28 -07:00
Alex Klyubin
d6c7799b9a Keymaster key validity dates are optional.
This CL makes Android Keystore framework code add
KM_TAG_ACTIVE_DATETIME, KM_TAG_ORIGINATION_EXPIRE_DATETIME, and
KM_TAG_USAGE_EXPIRE_DATETIME tags to the authorizations set only
if the corresponding time instants were specified through the
framework-level API. This is fine because these tags are optional as
it turns out.

Bug: 18088752
Change-Id: I6a5ae4cadb441e61576231815e6bec6e9248bc72
2015-06-23 12:06:27 -07:00
Shawn Willden
91526c1430 Add new error codes for rate-limit and max-use failures.
Bug: 21607106
Change-Id: Ia0527341f98726bf74c2bfddd9b9a82974fab954
2015-06-19 09:07:13 -06:00
Alex Klyubin
42abb74834 Reflect removal of KM_TAG_AEAD_TAG from keymaster.
This reflects the changes in da89dde9787dfbd8c053119ab52d9e671106b18e
in system/keymaster.

Bug: 19919114
Change-Id: I9cdfc7ce63099c4de29029b1fc112369c4a68eba
2015-06-18 18:43:45 -07:00
Alex Klyubin
00af27b7d9 Expose AES GCM backed by Android Keystore.
Bug: 18088752
Bug: 21786749
Change-Id: Ica90491037d2920f7635195894ba18882fc4406d
2015-06-17 09:24:06 -07:00
Chad Brubaker
8a07701f38 Add optional additional entropy to finish
If provided the extra entropy will be added to the device before calling
finish. If entropy is provided and the device does not support supplying
additional entropy then finish will fail with KM_ERROR_UNIMPLEMENTED.

(cherry-picked from commit 9ce30624a4)

Change-Id: If26be118bf382604f6f8e96e833b76e6f9e94d58
2015-06-04 10:06:00 -07:00
Alex Klyubin
85f4b7b38c Merge "Fix block mode numbering (CTR got added as 4 rather than 3)" into mnc-dev 2015-06-03 17:25:38 +00:00
Alex Klyubin
4699e43dc6 Fix block mode numbering (CTR got added as 4 rather than 3)
Change-Id: I8c886c67ba081255ef18eb0f99ca1e6003fabb33
2015-06-03 09:36:51 -07:00
Alex Klyubin
5c56f74527 Merge "Remove KM_TAG_CHUNK_LENGTH and add KM_TAG_AEAD_TAG" into mnc-dev 2015-06-03 16:35:21 +00:00
Alex Klyubin
0fe70813e0 Remove KM_TAG_CHUNK_LENGTH and add KM_TAG_AEAD_TAG
Change-Id: I384f3d2fee2f68279c6518d9ac0a79e29bed0e52
2015-06-02 14:38:35 -07:00
Chad Brubaker
966486e134 Track changes to the keystore binder API
Output parameters are gone from begin, instead they will returned in the
OperationResult and begin, update, and finish may return output
parameters.

Change-Id: I072afeb6c65f6c512b40603824c25686ac44e7c8
2015-06-01 15:16:06 -07:00
Chad Brubaker
e35d49f0d2 Cleanup Keystore API
Rename confusingly named methods, add userID arguments to all methods
that operate on user state and delete methods that have been replaced by
the onUser* methods.

Some of the old methods have been kept in KeyStore.java in order to ease
the transition of various system packages to the new methods.

(cherry-picked from commit d8aacca3a1)

Change-Id: Ic271689d62c36d255c5adee26c7abc2e7ed24df5
2015-05-19 13:45:00 -07:00
Chad Brubaker
83ce095c84 Add keystore onUserAdded/Removed methods
(cherry-picked from commit 31c2897105)

Change-Id: I73fe9344ec5660e58425d5c85d14381820533d57
2015-05-13 10:57:42 -07:00
Chad Brubaker
a91a850419 Cleanup keystore password changing and unlocking
Add KeyStore.onUserPasswordChanged for the lockscreen to call when
the user changes their password. Keystore will then handle the logic of
deleting keys. Instead of calling Keystore.password_uid for both
unlocking and password changes the behavior has been split into
Keystore.unlock and onUserPasswordChanged.

Change-Id: I324914c00195d762cbaa8c63084e41fa796b7df8
2015-05-08 11:11:43 -07:00
Alex Klyubin
6358b881f2 Handle KM_ERROR_CALLER_NONCE_PROHIBITED.
This converts KM_ERROR_CALLER_NONCE_PROHIBITED into
InvalidAlgorithmParameterSpec, as expected by the contract of JCA
Cipher.

Bug: 18088752
Change-Id: I6a01e2d7118c478b27a0d7a5a14a127de8913755
2015-04-30 13:57:44 -07:00
Shawn Willden
dbc00eb0aa Add missing error codes from keymaster_defs.h.
Bug: 20127433
Change-Id: I32eab62459003c526d3cf9ef108be7b2fd709960
2015-04-29 23:13:20 -06:00
Alex Klyubin
708fc94045 Add KeyPermanentlyInvalidatedException.
This enables users of AndroidKeyStore crypto to differentiate between
the key being unusable until the user is authenticated
(UserNotAuthenticatedException) and the key being permanently unusable
(KeyPermanentlyInvalidatedException). The latter is the case when the
secure lock screen has been disabled or reset, and, for keys that
require user authentication for every use, when a new fingerprint is
enrolled or all fingerprints are unenrolled.

NOTE: The KeyPermanentlyInvalidatedException subsumes/replaces the
NewFingerprintEnrolledException which has thus been removed. There
is no way to find out whether a key was permenently invalidated
specifically because a new fingerprint was added.

Bug: 20642549
Bug: 20526234
Change-Id: I0206cd99eef5c605c9c4d6afc5eea02eb3b1fe6b
2015-04-29 12:44:10 -07:00
Alex Klyubin
1eda77ae21 Align AndroidKeyStore API with user auth API.
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-28 17:39:30 -07:00
Alex Klyubin
fbf4599a8e Document that WebView doesn't honor "uses cleartext traffic" flag.
Bug: 19215516
Change-Id: I5dbbaa03f3cae007c0b9b68fcf8cc8f250c16a62
2015-04-21 14:50:39 -07:00
Chad Brubaker
733ad46ad2 am 1ba95855: am a9d74000: am e5e49a17: Merge "Support KM_LONG_REP"
* commit '1ba9585506521a2bb722ef692dc7152291306898':
  Support KM_LONG_REP
2015-04-16 22:42:38 +00:00
Alex Klyubin
35075a0765 Merge "Document usesCleartextTraffic app-level attribute." 2015-04-16 22:28:06 +00:00
Chad Brubaker
e5e49a175c Merge "Support KM_LONG_REP" 2015-04-16 21:56:13 +00:00
Chad Brubaker
b543b39354 Support KM_LONG_REP
Change-Id: I37814bcb03dc8918e27226ec43230fa4218723d0
2015-04-16 14:39:51 -07:00
Alex Klyubin
aa0d7f60b6 am b1aa7d0b: am 51884f0e: am 499126c4: Merge "Add Keymaster KM_ORIGIN_UNKNOWN constant."
* commit 'b1aa7d0bc821614d943075c0d786cc3f5eeb8c73':
  Add Keymaster KM_ORIGIN_UNKNOWN constant.
2015-04-16 20:31:46 +00:00
Alex Klyubin
499126c433 Merge "Add Keymaster KM_ORIGIN_UNKNOWN constant." 2015-04-16 19:50:12 +00:00
Alex Klyubin
8ce568e756 am f39aa3d0: am a2607ee4: am b9a78c79: Merge "Add IV-related Keymaster error codes."
* commit 'f39aa3d0898b845ced3128f1778fd04171e4b9a6':
  Add IV-related Keymaster error codes.
2015-04-16 17:20:37 +00:00
Alex Klyubin
37d81d035c Add IV-related Keymaster error codes.
Bug: 18088752
Change-Id: I08daede713f945ad7dd0b21cc41ee12c15d94bad
2015-04-15 17:18:19 -07:00
Alex Klyubin
e35cefbf23 Document usesCleartextTraffic app-level attribute.
This updates the documentation of the application element of
AndroidManifest.xml to mention the new android:usesCleartextTraffic
attribute.

This also updates the Javadoc of
android.security.NetworkSecurityPolicy and ApplicationInfo to match.

Bug: 19215516
Change-Id: I5c221b56addae8988b4db51994d18ae379d0fbe3
2015-04-15 14:37:05 -07:00
Alex Klyubin
45d27836bd Add Keymaster KM_ORIGIN_UNKNOWN constant.
This tracks d359b044830b292f492f8a8df5471f869e358399 from
hardware/libhardware.

Bug: 18088752
Change-Id: I9a7bd8bdee51c18ae0427eff4efe036213d2b175
2015-04-14 10:52:34 -07:00
Alex Klyubin
fbf1472d61 resolved conflicts for merge of a978a3d6 to master
Change-Id: Ifd7ca9e1dfa0d50a87f2bafef377fcaeb5d9f6d5
2015-04-13 10:54:53 -07:00
Alex Klyubin
d1af38a478 Merge "Use JCA names for block modes, paddings, and digests." 2015-04-13 17:01:30 +00:00
Alex Klyubin
5927c9f1b1 Use JCA names for block modes, paddings, and digests.
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-13 09:59:04 -07:00
Shawn Willden
46bcfb64fb am c88e1396: am 99f4ac14: am 97fce66f: Merge "Make several key crypto parameters repeatable"
* commit 'c88e1396db12e430dde63afc3d44c1f37a7fce79':
  Make several key crypto parameters repeatable
2015-04-10 22:12:53 +00:00
Alex Klyubin
75f6f31db4 am d31d4771: am c5f9683c: am a270264c: Merge "Track more changes to keymaster_defs.h"
* commit 'd31d4771d90277eb246814b6a6f981e0842eb614':
  Track more changes to keymaster_defs.h
2015-04-10 18:29:53 +00:00
Chad Brubaker
59f977c698 Make several key crypto parameters repeatable
Bug: 19509156
Change-Id: Ic584d8a6bf5601f9754563b67b3cc6b3ca6b5ff9
2015-04-10 12:20:04 -06:00
Alex Klyubin
55f7c2770f Track more changes to keymaster_defs.h
KeyStoreTest needed to be adjusted because OCB is no longer supported.

Bug: 18088752
Change-Id: I7594daaa5e97423d34726b07cc79e3ee28418d95
2015-04-10 08:58:38 -07:00
Alex Klyubin
8d33804b01 am 037dfb94: am 5f8c17b9: am ba2836e6: Merge "Track recent keymaster_defs.h changes."
* commit '037dfb9423a0988398b67520546dae5673aa54bb':
  Track recent keymaster_defs.h changes.
2015-04-10 04:34:13 +00:00
Alex Klyubin
862e6c7814 Track recent keymaster_defs.h changes.
Bug: 18088752
Change-Id: If47bb7cc7a385941db9f12d478676594e9bc9d86
2015-04-09 16:58:58 -07:00
Alex Klyubin
1620a65d32 resolved conflicts for merge of 06adabdb to master
Change-Id: Ifb09e2e6242f79cabe76e95eacc982f6cc7e1a6c
2015-04-07 11:39:51 -07:00
Alex Klyubin
c46e9e7da4 Make the new AndroidKeyStore API conformant.
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-07 09:18:00 -07:00
Alex Klyubin
55d53ac837 am 36865896: am b48ebf48: am 562c6a71: Merge "UNSUPPORTED_TAG_LENGTH -> UNSUPPORTED_MAC_LENGTH"
* commit '36865896072ee78cae1e987f29340d35a1526f44':
  UNSUPPORTED_TAG_LENGTH -> UNSUPPORTED_MAC_LENGTH
2015-04-01 02:20:55 +00:00
Alex Klyubin
c0eb55ccc7 UNSUPPORTED_TAG_LENGTH -> UNSUPPORTED_MAC_LENGTH
This is to follow naming from keymaster_defs.h

Bug: 18088752
Change-Id: If2bc91dde54f1cefcd4325d1f62d0e0b77fc5d59
2015-03-31 17:16:31 -07:00
Chad Brubaker
7744a25673 am 543189eb: am 826d6357: am 5491ea9e: Merge "Include operation handle in OperationResult"
* commit '543189eb711c7aeefab9566b74b62c34d35115f5':
  Include operation handle in OperationResult
2015-03-31 18:16:31 +00:00
Chad Brubaker
5491ea9e5b Merge "Include operation handle in OperationResult" 2015-03-31 17:49:16 +00:00
Chad Brubaker
021a1e090a am 7081a168: am 5341d83c: am f603e286: Merge "Add authorization binder methods"
* commit '7081a16859cdcf32f565379a8179ddc7b50b3c1d':
  Add authorization binder methods
2015-03-30 20:33:55 +00:00