summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajesh Nyamagoud <nyamagoud@google.com>2024-04-17 04:04:48 +0000
committerRajesh Nyamagoud <nyamagoud@google.com>2024-04-19 14:48:23 +0000
commitcf61178da34b6dbc50ba2e9f794bfb9f378854ab (patch)
treea0e3d99a3f7e86dc15209da85ce3073f32865e57
parentfabe530c1fc4609dd76a387a21ea23ccacac3d52 (diff)
downloadcts-cf61178da34b6dbc50ba2e9f794bfb9f378854ab.tar.gz
Keystore: Fix made to use the copy of the input parameter passed to
checkEntropy helper method. checkEntropy method internally modifies the parameter passed to it so while performing entropy check for verifiedBootHash and verifiedBootkey, copy of verifiedBootkey and VerifiedBootHash values are used. Bug: 335081121 Test: atest android.keystore.cts.KeyAttestationTest Change-Id: I9921b788652bc754093fb951c679005f26f53ec5
-rw-r--r--tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
index f27b44579eb..6903e949696 100644
--- a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
@@ -1701,9 +1701,10 @@ public class KeyAttestationTest {
}
}
- private void checkEntropy(byte[] verifiedBootKey) {
- assertTrue("Failed Shannon entropy check", checkShannonEntropy(verifiedBootKey));
- assertTrue("Failed BiEntropy check", checkTresBiEntropy(verifiedBootKey));
+ private void checkEntropy(byte[] entropyData) {
+ byte[] entropyDataCopy = Arrays.copyOf(entropyData, entropyData.length);
+ assertTrue("Failed Shannon entropy check", checkShannonEntropy(entropyDataCopy));
+ assertTrue("Failed BiEntropy check", checkTresBiEntropy(entropyDataCopy));
}
private boolean checkShannonEntropy(byte[] verifiedBootKey) {
@@ -1719,6 +1720,9 @@ public class KeyAttestationTest {
return entropy;
}
+ /**
+ * Note: This method modifies the input parameter while performing bit entropy check.
+ */
private boolean checkTresBiEntropy(byte[] verifiedBootKey) {
double weightingFactor = 0;
double weightedEntropy = 0;
@@ -1736,6 +1740,9 @@ public class KeyAttestationTest {
return tresBiEntropy > 0.9;
}
+ /**
+ * Note: This method modifies the input parameter - bitString.
+ */
private void deriveBitString(byte[] bitString, int activeLength) {
int length = activeLength / 8;
if (activeLength % 8 != 0) {