• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/hardware/interfaces


Commit MetaInfo

修订版a34e152b563c395cc42216f9294491ef93b6c591 (tree)
时间2019-02-01 01:19:50
作者Branden Archer <brarcher@goog...>
Commiterandroid-build-merger

Log Message

Add VTS for Wifi Keystore HAL's getPublicKey()
am: 9e45561f00

Change-Id: I9325b8a63726b37a1b9bf2494471c0a900a6124c

更改概述

差异

--- a/wifi/keystore/1.0/vts/functional/VtsHalWifiKeystoreV1_0TargetTest.cpp
+++ b/wifi/keystore/1.0/vts/functional/VtsHalWifiKeystoreV1_0TargetTest.cpp
@@ -312,4 +312,67 @@ TEST_F(WifiKeystoreHalTest, GetBlob) {
312312 EXPECT_EQ(result, true);
313313 }
314314
315+/**
316+ * Test for the Wifi Keystore HAL's getPublicKey() call.
317+ */
318+TEST_F(WifiKeystoreHalTest, GetPublicKey) {
319+ IKeystore::KeystoreStatusCode statusCode;
320+
321+ auto callback = [&statusCode](IKeystore::KeystoreStatusCode status,
322+ const ::android::hardware::hidl_vec<uint8_t>& /*value*/) {
323+ statusCode = status;
324+ return;
325+ };
326+
327+ // Attempting to export a non-existent key should fail.
328+
329+ statusCode = IKeystore::KeystoreStatusCode::SUCCESS;
330+ keystore->getPublicKey(nullptr, callback);
331+ EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
332+
333+ statusCode = IKeystore::KeystoreStatusCode::SUCCESS;
334+ keystore->getPublicKey("", callback);
335+ EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
336+
337+ statusCode = IKeystore::KeystoreStatusCode::SUCCESS;
338+ keystore->getPublicKey(kTestKeyName, callback);
339+ EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
340+
341+ // The HAL is expecting the key to belong to the process' user.
342+ // If the key belongs to another user's space (e.g. wifi) it should
343+ // not be accessible and should fail.
344+
345+ bool result = generateKey(kTestKeyName, KeyPurpose::SIGNING, AID_WIFI);
346+ EXPECT_EQ(result, true);
347+
348+ keystore->getPublicKey(kTestKeyName, callback);
349+ EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
350+
351+ result = deleteKey(kTestKeyName, AID_WIFI);
352+ EXPECT_EQ(result, true);
353+
354+ // Accessing the key belonging to the process' uid should succeed.
355+
356+ result = generateKey(kTestKeyName, KeyPurpose::SIGNING, UID_SELF);
357+ EXPECT_EQ(result, true);
358+
359+ keystore->getPublicKey(kTestKeyName, callback);
360+ EXPECT_EQ(IKeystore::KeystoreStatusCode::SUCCESS, statusCode);
361+
362+ result = deleteKey(kTestKeyName, UID_SELF);
363+ EXPECT_EQ(result, true);
364+
365+ // A TYPE_GENERIC key (instead of a TYPE_KEYMASTER_10 key)
366+ // should also fail.
367+
368+ result = insert(kTestKeyName, UID_SELF);
369+ EXPECT_EQ(result, true);
370+
371+ keystore->getPublicKey(kTestKeyName, callback);
372+ EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
373+
374+ result = deleteKey(kTestKeyName, UID_SELF);
375+ EXPECT_EQ(result, true);
376+}
377+
315378 } // namespace