diff options
author | Kenny Root <kroot@google.com> | 2012-03-23 16:17:28 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2012-03-26 13:26:05 -0700 |
commit | 8ae65e71996ce871cda97cc9114cb5211cb273bf (patch) | |
tree | 216139e04beb9d3b2423b6005db5d8bc513eb581 /tests/keymaster | |
parent | eb8fb508148d809166a30783a14e186fda0e31c9 (diff) | |
download | hardware_libhardware-8ae65e71996ce871cda97cc9114cb5211cb273bf.zip hardware_libhardware-8ae65e71996ce871cda97cc9114cb5211cb273bf.tar.gz hardware_libhardware-8ae65e71996ce871cda97cc9114cb5211cb273bf.tar.bz2 |
Add delete_all to keymaster API
In order to aid keymasters erase their memory efficiently, introduce new
delete_all API to tell keymasters to forget everything. This will be
triggered when keystore itself is told to reset.
Change-Id: I730375f1f32cd1ea0bf1fa38d5b1bec2f81ba492
Diffstat (limited to 'tests/keymaster')
-rw-r--r-- | tests/keymaster/keymaster_test.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/keymaster/keymaster_test.cpp b/tests/keymaster/keymaster_test.cpp index 98e9407..f4cfcd2 100644 --- a/tests/keymaster/keymaster_test.cpp +++ b/tests/keymaster/keymaster_test.cpp @@ -751,4 +751,43 @@ TEST_F(KeymasterTest, VerifyData_RSA_NullSignature_Failure) { << "Should fail on null signature"; } +TEST_F(KeymasterTest, EraseAll_Success) { + uint8_t *key1_blob, *key2_blob; + size_t key1_blob_length, key2_blob_length; + + // Only test this if the device says it supports delete_all + if (sDevice->delete_all == NULL) { + return; + } + + ASSERT_EQ(0, + sDevice->import_keypair(sDevice, TEST_SIGN_KEY_1, sizeof(TEST_SIGN_KEY_1), + &key1_blob, &key1_blob_length)) + << "Should successfully import an RSA key"; + UniqueKey key1(&sDevice, key1_blob, key1_blob_length); + + ASSERT_EQ(0, + sDevice->import_keypair(sDevice, TEST_KEY_1, sizeof(TEST_KEY_1), + &key2_blob, &key2_blob_length)) + << "Should successfully import an RSA key"; + UniqueKey key2(&sDevice, key2_blob, key2_blob_length); + + EXPECT_EQ(0, sDevice->delete_all(sDevice)) + << "Should erase all keys"; + + key1.reset(); + + uint8_t* x509_data; + size_t x509_data_length; + ASSERT_EQ(-1, + sDevice->get_keypair_public(sDevice, key1_blob, key1_blob_length, + &x509_data, &x509_data_length)) + << "Should be able to retrieve RSA public key 1 successfully"; + + ASSERT_EQ(-1, + sDevice->get_keypair_public(sDevice, key2_blob, key2_blob_length, + &x509_data, &x509_data_length)) + << "Should be able to retrieve RSA public key 2 successfully"; +} + } |