Commit graph

10 commits

Author SHA1 Message Date
James Willcox
d215da817a Add getLastAuthTime() to IKeystoreAuthorization
This returns the time (from CLOCK_MONOTONIC_RAW) that the specified user
last authenticated using the given authenticator.

Bug: 303839446
Test: atest keystore2_client_tests
Change-Id: Idd4c477365ffa556b7985d1d926dfa554680ff28
2023-10-31 20:30:50 +00:00
Tri Vo
4e6dbef7f7 Add keystore2_client_tests to VTS
Bug: 194359114
Test: keystore2_client_tests
Change-Id: I74f29e8c42fd6fdca07a7999dfc2e5345ad45c09
2023-10-23 14:50:30 -04:00
Rajesh Nyamagoud
10f02e705a Re-structured keystore test-utils module.
- Created separate build file.
- Moved ffi-utils from keystore2-client-tests to test-utils.
- Updated calling apis.

Test: atest keystore2_client_tests; atest keystore2_test_utils_test;
atest keystore2_test
Bug: 194359114

Change-Id: Ia2404218b7d13a9ae43b3fc4e481899576d24e63
2023-08-29 17:03:35 +00:00
Rajesh Nyamagoud
a42dee61ce Added tests to attest keys with attestation id.
- Generate an RSA/EC attested keys with attestation of the device's
  identifiers. Test should succeed in generatating a attested key with
  attestation of device identifier. Test might fail on devices which
  doesn't support device id attestation with error response code
  `CANNOT_ATTEST_IDS or INVALID_TAG`.

- Try to generate an attested key with attestation of invalid device's
  identifiers. Test should fail with error response `CANNOT_ATTEST_IDS`

- Test to make sure `CANNOT_ATTEST_IDS` error code is returned while
  trying to generate a key on a device which doesn't support
  `FEATURE_DEVICE_ID_ATTESTATION`.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: Ib57c58d3ea89279eb69db342c3343b8d99ddc639
2023-06-20 19:07:27 +00:00
Rajesh Nyamagoud
28abde6189 Adding tests to verify EVP_PKEY_from_keystore2 API [Keystore2-engine].
1. Generate RSA key and grant it to a user. In user context load the
   key using `EVP_PKEY_from_keystore` and perform sign and verify
   opeearions.
   [keystore2_perofrm_crypto_op_using_keystore2_engine_rsa_key_success]

2. Generate EC key and grant it to a user. In user context load the
   key using `EVP_PKEY_from_keystore` and perform sign and verify
   operations.
   [keystore2_perofrm_crypto_op_using_keystore2_engine_ec_key_success]

3. Generate RSA key and grant it to a user. Re-encode the certificate
   as PEM and update the certificate using `updateSubcomponents`.
   In user context load the key using `EVP_PKEY_from_keystore` and
   perform sign and verify operations.

Bug: 201343811
Test: atest keystore2_client_tests
Change-Id: I7dafd598f4198e11103cd11695b2f67636f24755
2023-05-23 19:28:24 +00:00
Rajesh Nyamagoud
c946cc419c Tests to verify importWrappedKey functionality.
- Build ASN.1 DER-encoded wrapped key material `SecureKeyWrapper`.
  Import the wrapped key material. Test should create DER-encoded
  wrapped key material and import the secure key successfully.
  Imported key should be used perform crypto operation successfully.

- Build ASN.1 DER-encoded wrapped key material `SecureKeyWrapper` with
  invalid AAD. Try to import the wrapped key material. Test should
  create DER-encoded wrapped key material. Test should fail to import
  the secure key with error code `VERIFICATION_FAILED`.

- Import wrapped AES key and use it for crypto operations. Test should
  import wrapped key and  user it for performing crypto operations
  successfully.

- Import a key wihtout WRAP_KEY purpose and try to use it as wrapping
  key while importing wrapped key. Test should fail to import wrapped
  key with an error code `INCOMPATIBLE_PURPOSE`.

- Try to import wrapped key using non-existing wrapping key in Android
  keystore. Test should fail to import wrapped key with an error code
  `KEY_NOT_FOUND`.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: Ic9ed03b6f945bd41c4873f97a84c1658c284e918
2023-01-04 22:42:18 +00:00
Rajesh Nyamagoud
b8402b6d91 Tests to verify importKey with Asymmetric and symmetric keys.
- Test to import a RSA key and validate imported key parameters.
  Perform an operation using imported key. Test should be able to
  import the key and complete the operation successfully.

- Test to import a RSA key without specifying key size and public
  expenent. Determine key-size and public exponent from key material.
  Validate imported key parameters. Perform an operation using imported
  key. Test should be able to import the key and complete the operation
  successfully.

- Test to import a RSA key with incorrect key-size as import key
  parameter. Test should fail to import a key with an error code
  `IMPORT_PARAMETER_MISMATCH`.

- Test to import a RSA key with incorrect public exponent as import key
  parameter. Test should fail to import a key with an error code
  `IMPORT_PARAMETER_MISMATCH`.

- Test to import a RSA key with multiple pursposes [SIGN and ATTEST_KEY]
  as import key parameters. Test should fail to import a key with an
  error code `INCOMPATIBLE_PURPOSE`.

- Test to import a EC key without specifying curve. Determine ec-curve
  from key material. Validate imported key parameters. Perform an
  operation using imported key. Test should be able to import the key
  and complete the operation successfully.

- Test to import a EC key with incorrect ec-curve as import key
  parameter. Test should fail to import a key with an error code
  `IMPORT_PARAMETER_MISMATCH`.

- Test to import a AES, 3DES and HMAC keys. Validate imported keys
  parameters. Perform operations using imported keys. Test should
  be able to import the key and complete the operation successfully.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: Ib90c05b93929b8b0e1d4cb9542f5b8493a116c39
2022-10-28 01:33:16 +00:00
Rajesh Nyamagoud
4d48337ffd Added tests using attest keys for signing RSA and EC keys.
- Generate EC/RSA attestation keys and use it for signing RSA and EC
  keys. Test should be able to use the attest keys for signing the
  generated keys successfully.

- Generate EC-CURVE_25519 attestation key and use it for signing RSA
  key. Test should be able to generate RSA key with EC-CURVE_25519 key
  as attestation key.

- Generate an asymmetric key which doesn't possess ATTEST_KEY purpose.
  Use this key for attesting asymmetric key. It should fail to generate
  key with incompatible purpose error.

- Generate a symmetric key. Try to use this symmetric key as attestation
  key while generating asymmetric key. It should fail to generate a key
  with system error.

- Try to generate symmetric key with valid attestation key,
  attstation-challenge and attestation-app-id. Test should generate a
  key without attestation record.

- Try to generate RSA/EC attestation keys with multiple purpose. Test
  should fail to generate keys with incompatible purpose error code.

- Generate an attestation key and try to use it for signing a key
  without providing attestation challenge. Test should fail with missing
  attestation challenge error.

Note: These tests are executed on devices where
`android.hardware.keystore.app_attest_key` feature is enabled, otherwise
tests are skipped.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: I4228dc5fe5e207995472c3425d5f2696ef95249f
2022-10-20 16:09:02 +00:00
Bob Badour
ae667ea93c [LSC] Add LOCAL_LICENSE_KINDS to system/security
Added SPDX-license-identifier-Apache-2.0 to:
  keystore2/tests/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I816f5ba7db5e359b97f1bd0222ca43eebacfc4d1
2022-05-19 09:15:17 -07:00
Rajesh Nyamagoud
b881d5189c Adding test to create BACKEND_BUSY error
Creates multiple child procs and creates opearations in it and
parent proc waits for all child procs operations status, expects
one or more opearations to fail with backeend busy error.

Bug: 194359114
Test: atest keystore2_client_test
Change-Id: I52f95a7cfd031d80c88bfc2ca478a26572f40150
2022-05-13 22:30:16 +00:00