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

Commit b2c9d5c9 authored by Ryan Prichard's avatar Ryan Prichard
Browse files

Fix nonce uniqueness tests

std::unique consolidates the unique nonces at the start of the `nonces`
vector, but it doesn't modify nonces.size(), so these tests weren't
actually verifying that the nonces were unique. Add a vector::erase
call to shrink the vector.

After upgrading libc++, std::unique is [[nodiscard]] and this bug is
a compiler error.

Bug: 175635923
Test: treehugger
Test: m VtsAidlSharedSecretTargetTest VtsHalKeymasterV4_0TargetTest
Change-Id: I7fd8c40a3920bf3a8988c8065503c78ba36dc742
parent 680fd806
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ TEST_P(HmacKeySharingTest, ComputeSharedHmac) {
    auto nonces = copyNonces(params);
    EXPECT_EQ(allKeymasters().size(), nonces.size());
    std::sort(nonces.begin(), nonces.end());
    std::unique(nonces.begin(), nonces.end());
    nonces.erase(std::unique(nonces.begin(), nonces.end()), nonces.end());
    EXPECT_EQ(allKeymasters().size(), nonces.size());

    auto responses = computeSharedHmac(allKeymasters(), params);
+1 −1
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ TEST_F(SharedSecretAidlTest, ComputeSharedSecret) {
    auto nonces = copyNonces(params);
    EXPECT_EQ(sharedSecrets.size(), nonces.size());
    std::sort(nonces.begin(), nonces.end());
    std::unique(nonces.begin(), nonces.end());
    nonces.erase(std::unique(nonces.begin(), nonces.end()), nonces.end());
    EXPECT_EQ(sharedSecrets.size(), nonces.size());

    auto responses = computeAllSharedSecrets(params);