Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af4545a5 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-5bf29450-4eb0-4d71-a15a-d8858bf184d3-for-git_oc-release-412012...

release-request-5bf29450-4eb0-4d71-a15a-d8858bf184d3-for-git_oc-release-4120128 snap-temp-L37600000076154351

Change-Id: I2604a26fdb33209aed2bf87ffe65b2ab8f002c53
parents df6da6be c4f859d1
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
    capabilities_called_count_ = 0;
    location_called_count_ = 0;
    info_called_count_ = 0;
    notify_count_ = 0;

    gnss_hal_ = ::testing::VtsHalHidlTargetTestBase::getService<IGnss>();
    ASSERT_NE(gnss_hal_, nullptr);
@@ -93,12 +94,15 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
    if (gnss_hal_ != nullptr) {
      gnss_hal_->cleanup();
    }
    if (notify_count_ > 0) {
        ALOGW("%d unprocessed callbacks discarded", notify_count_);
    }
  }

  /* Used as a mechanism to inform the test that a callback has occurred */
  inline void notify() {
    std::unique_lock<std::mutex> lock(mtx_);
    count++;
    notify_count_++;
    cv_.notify_one();
  }

@@ -108,11 +112,11 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {

    std::cv_status status = std::cv_status::no_timeout;
    auto now = std::chrono::system_clock::now();
    while (count == 0) {
    while (notify_count_ == 0) {
        status = cv_.wait_until(lock, now + std::chrono::seconds(timeoutSeconds));
        if (status == std::cv_status::timeout) return status;
    }
    count--;
    notify_count_--;
    return status;
  }

@@ -188,7 +192,7 @@ class GnssHalTest : public ::testing::VtsHalHidlTargetTestBase {
 private:
  std::mutex mtx_;
  std::condition_variable cv_;
  int count;
  int notify_count_;
};

/*
+25 −17
Original line number Diff line number Diff line
@@ -374,7 +374,7 @@ class KeymasterHidlTest : public ::testing::VtsHalHidlTargetTestBase {
  public:
    void TearDown() override {
        if (key_blob_.size()) {
            EXPECT_EQ(ErrorCode::OK, DeleteKey());
            CheckedDeleteKey();
        }
        AbortIfNeeded();
    }
@@ -505,6 +505,13 @@ class KeymasterHidlTest : public ::testing::VtsHalHidlTargetTestBase {
        return error;
    }

    void CheckedDeleteKey(HidlBuf* key_blob, bool keep_key_blob = false) {
        auto rc = DeleteKey(key_blob, keep_key_blob);
        EXPECT_TRUE(rc == ErrorCode::OK || rc == ErrorCode::UNIMPLEMENTED);
    }

    void CheckedDeleteKey() { CheckedDeleteKey(&key_blob_); }

    ErrorCode GetCharacteristics(const HidlBuf& key_blob, const HidlBuf& client_id,
                                 const HidlBuf& app_data, KeyCharacteristics* key_characteristics) {
        ErrorCode error;
@@ -718,7 +725,7 @@ class KeymasterHidlTest : public ::testing::VtsHalHidlTargetTestBase {
                            KeyFormat::RAW, key));
        string signature = MacMessage(message, digest, expected_mac.size() * 8);
        EXPECT_EQ(expected_mac, signature) << "Test vector didn't match for digest " << (int)digest;
        DeleteKey();
        CheckedDeleteKey();
    }

    void CheckAesCtrTestVector(const string& key, const string& nonce, const string& message,
@@ -1063,7 +1070,7 @@ TEST_F(NewKeyGenerationTest, Rsa) {
        EXPECT_TRUE(crypto_params.Contains(TAG_KEY_SIZE, key_size));
        EXPECT_TRUE(crypto_params.Contains(TAG_RSA_PUBLIC_EXPONENT, 3));

        EXPECT_EQ(ErrorCode::OK, DeleteKey(&key_blob));
        CheckedDeleteKey(&key_blob);
    }
}

@@ -1108,7 +1115,7 @@ TEST_F(NewKeyGenerationTest, Ecdsa) {
        EXPECT_TRUE(crypto_params.Contains(TAG_ALGORITHM, Algorithm::EC));
        EXPECT_TRUE(crypto_params.Contains(TAG_KEY_SIZE, key_size));

        EXPECT_EQ(ErrorCode::OK, DeleteKey(&key_blob));
        CheckedDeleteKey(&key_blob);
    }
}

@@ -1157,7 +1164,7 @@ TEST_F(NewKeyGenerationTest, EcdsaAllValidSizes) {
        EXPECT_EQ(ErrorCode::OK,
                  GenerateKey(AuthorizationSetBuilder().EcdsaSigningKey(size).Digest(Digest::NONE)))
            << "Failed to generate size: " << size;
        DeleteKey();
        CheckedDeleteKey();
    }
}

@@ -1173,7 +1180,7 @@ TEST_F(NewKeyGenerationTest, EcdsaAllValidCurves) {
            ErrorCode::OK,
            GenerateKey(AuthorizationSetBuilder().EcdsaSigningKey(curve).Digest(Digest::SHA_2_512)))
            << "Failed to generate key on curve: " << curve;
        DeleteKey();
        CheckedDeleteKey();
    }
}

@@ -1223,7 +1230,7 @@ TEST_F(NewKeyGenerationTest, Hmac) {
            EXPECT_TRUE(softwareEnforced.Contains(TAG_KEY_SIZE, key_size));
        }

        EXPECT_EQ(ErrorCode::OK, DeleteKey(&key_blob));
        CheckedDeleteKey(&key_blob);
    }
}

@@ -1251,7 +1258,7 @@ TEST_F(NewKeyGenerationTest, HmacCheckKeySizes) {
                                                     .HmacKey(key_size)
                                                     .Digest(Digest::SHA_2_256)
                                                     .Authorization(TAG_MIN_MAC_LENGTH, 256)));
            DeleteKey();
            CheckedDeleteKey();
        }
    }
}
@@ -1283,7 +1290,7 @@ TEST_F(NewKeyGenerationTest, HmacCheckMinMacLengths) {
                                      .HmacKey(128)
                                      .Digest(Digest::SHA_2_256)
                                      .Authorization(TAG_MIN_MAC_LENGTH, min_mac_length)));
            DeleteKey();
            CheckedDeleteKey();
        }
    }
}
@@ -1673,7 +1680,7 @@ TEST_F(SigningOperationsTest, EcdsaAllSizesAndHashes) {
            string message(1024, 'a');
            if (digest == Digest::NONE) message.resize(key_size / 8);
            SignMessage(message, AuthorizationSetBuilder().Digest(digest));
            DeleteKey();
            CheckedDeleteKey();
        }
    }
}
@@ -1694,7 +1701,7 @@ TEST_F(SigningOperationsTest, EcdsaAllCurves) {

        string message(1024, 'a');
        SignMessage(message, AuthorizationSetBuilder().Digest(Digest::SHA_2_256));
        DeleteKey();
        CheckedDeleteKey();
    }
}

@@ -1755,7 +1762,7 @@ TEST_F(SigningOperationsTest, HmacAllDigests) {
        string signature = MacMessage(message, digest, 160);
        EXPECT_EQ(160U / 8U, signature.size())
            << "Failed to sign with HMAC key with digest " << digest;
        DeleteKey();
        CheckedDeleteKey();
    }
}

@@ -2142,7 +2149,8 @@ TEST_F(VerificationOperationsTest, EcdsaAllDigestsAndCurves) {
                << curve << ' ' << digest;
        }

        ASSERT_EQ(ErrorCode::OK, DeleteKey());
        auto rc = DeleteKey();
        ASSERT_TRUE(rc == ErrorCode::OK || rc == ErrorCode::UNIMPLEMENTED);
    }
}

@@ -2188,8 +2196,8 @@ TEST_F(VerificationOperationsTest, HmacSigningKeyCannotVerify) {
    VerifyMessage(verification_key, message, signature,
                  AuthorizationSetBuilder().Digest(Digest::SHA1));

    EXPECT_EQ(ErrorCode::OK, DeleteKey(&signing_key));
    EXPECT_EQ(ErrorCode::OK, DeleteKey(&verification_key));
    CheckedDeleteKey(&signing_key);
    CheckedDeleteKey(&verification_key);
}

typedef KeymasterHidlTest ExportKeyTest;
@@ -3437,14 +3445,14 @@ TEST_F(EncryptionOperationsTest, AesGcmCorruptKey) {
    string key = make_string(key_bytes);
    ASSERT_EQ(ErrorCode::OK, ImportKey(import_params, KeyFormat::RAW, key));
    string plaintext = DecryptMessage(ciphertext, params);
    EXPECT_EQ(ErrorCode::OK, DeleteKey());
    CheckedDeleteKey();

    // Corrupt key and attempt to decrypt
    key[0] = 0;
    ASSERT_EQ(ErrorCode::OK, ImportKey(import_params, KeyFormat::RAW, key));
    EXPECT_EQ(ErrorCode::OK, Begin(KeyPurpose::DECRYPT, params));
    EXPECT_EQ(ErrorCode::VERIFICATION_FAILED, Finish(ciphertext, &plaintext));
    EXPECT_EQ(ErrorCode::OK, DeleteKey());
    CheckedDeleteKey();
}

/*