aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-19 21:49:04 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-01-19 21:49:04 +0000
commita350f7b510fa99d09c5733bf6d86fb4c8775598f (patch)
tree0b01341f20022526982c740c92d3a3b7b6815d47
parent7b6d5ebea10628bc216843a142026b21f5df54f3 (diff)
parent95bc5c281fd6c6572e761073c8b8f332b7345eaf (diff)
downloadwycheproof-android14-tests-release.tar.gz
Snap for 11334283 from 95bc5c281fd6c6572e761073c8b8f332b7345eaf to android14-tests-releaseandroid14-tests-release
Change-Id: I249dc848b74fbd174fc6e711f986426371c8418b
-rw-r--r--keystore-cts/java/com/google/security/wycheproof/testcases/EcdhTest.java35
1 files changed, 24 insertions, 11 deletions
diff --git a/keystore-cts/java/com/google/security/wycheproof/testcases/EcdhTest.java b/keystore-cts/java/com/google/security/wycheproof/testcases/EcdhTest.java
index f57ad29..573561c 100644
--- a/keystore-cts/java/com/google/security/wycheproof/testcases/EcdhTest.java
+++ b/keystore-cts/java/com/google/security/wycheproof/testcases/EcdhTest.java
@@ -44,6 +44,7 @@ import org.junit.After;
import org.junit.Test;
import org.junit.Ignore;
import android.content.Context;
+import android.security.KeyStoreException;
import android.security.keystore.KeyProtection;
import android.security.keystore.KeyProperties;
import android.security.keystore.KeyGenParameterSpec;
@@ -810,19 +811,31 @@ public static final EcPublicKeyTestVector EC_VALID_PUBLIC_KEY =
ECPrivateKeySpec spec1 = new ECPrivateKeySpec(p1, spec);
ECPrivateKeySpec spec2 = new ECPrivateKeySpec(order.subtract(p1), spec);
PrivateKey priv1 = kf.generatePrivate(spec1);
+ PrivateKey priv2 = kf.generatePrivate(spec2);
// This Public key is not pair of priv1, but it is required to create KeyPair to import into
- // AndroidKeyStore, So using dummy public key.
+ // AndroidKeyStore, So using dummy public key.
PublicKey pub1 = kf.generatePublic(EC_VALID_PUBLIC_KEY.getX509EncodedKeySpec());
- ka.init(getKeystorePrivateKey(pub1, priv1, isStrongBox));
- ka.doPhase(pub, true);
- byte[] shared1 = ka.generateSecret();
- PrivateKey priv2 = kf.generatePrivate(spec2);
- ka.init(getKeystorePrivateKey(pub1, priv2, isStrongBox));
- ka.doPhase(pub, true);
- byte[] shared2 = ka.generateSecret();
- // The private keys p1 and p2 are equivalent, since only the x-coordinate of the
- // shared point is used to generate the shared secret.
- assertEquals(TestUtil.bytesToHex(shared1), TestUtil.bytesToHex(shared2));
+ try {
+ ka.init(getKeystorePrivateKey(pub1, priv1, isStrongBox));
+ ka.doPhase(pub, true);
+ byte[] shared1 = ka.generateSecret();
+ ka.init(getKeystorePrivateKey(pub1, priv2, isStrongBox));
+ ka.doPhase(pub, true);
+ byte[] shared2 = ka.generateSecret();
+ // The private keys p1 and p2 are equivalent, since only the x-coordinate of the
+ // shared point is used to generate the shared secret.
+ assertEquals(TestUtil.bytesToHex(shared1), TestUtil.bytesToHex(shared2));
+ } catch (InvalidKeyException e) {
+ if (i <= 15 && e.getCause() instanceof KeyStoreException &&
+ ((KeyStoreException)e.getCause()).getNumericErrorCode() ==
+ KeyStoreException.ERROR_KEYMINT_FAILURE) {
+ // Known rejected on some vendor implementations for certain i values.
+ // Keymint Applet error code is INVALID_OPERATION (-76).
+ continue;
+ } else {
+ throw e;
+ }
+ }
}
}