Skip to content
Snippets Groups Projects
Commit e36fe6bf authored by Janis Danisevskis's avatar Janis Danisevskis
Browse files

Keystore 2.0 SPI: Fix contract between equals and hashCode 2

This fixes the contract between equals and hashCode in
AndroidKeystorePublicKey. The previous fix made only a reference
comparisson between certificate blobs. In this patch java.util.Arrays is
used to compare and compute the hash of the array.

Bug: 196118021
Test: See following CL.
Change-Id: I2b8b7e740fb377de39fd21f763e15cb00024b2fc
parent 6297dd27
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ import android.system.keystore2.KeyDescriptor;
import android.system.keystore2.KeyMetadata;
import java.security.PublicKey;
import java.util.Objects;
import java.util.Arrays;
/**
* {@link PublicKey} backed by Android Keystore.
......@@ -62,8 +62,8 @@ public abstract class AndroidKeyStorePublicKey extends AndroidKeyStoreKey implem
int result = 1;
result = prime * result + super.hashCode();
result = prime * result + ((mCertificate == null) ? 0 : mCertificate.hashCode());
result = prime * result + ((mCertificateChain == null) ? 0 : mCertificateChain.hashCode());
result = prime * result + Arrays.hashCode(mCertificate);
result = prime * result + Arrays.hashCode(mCertificateChain);
return result;
}
......@@ -83,7 +83,7 @@ public abstract class AndroidKeyStorePublicKey extends AndroidKeyStoreKey implem
*/
final AndroidKeyStorePublicKey other = (AndroidKeyStorePublicKey) obj;
return Objects.equals(mCertificate, other.mCertificate) && Objects.equals(mCertificateChain,
return Arrays.equals(mCertificate, other.mCertificate) && Arrays.equals(mCertificateChain,
other.mCertificateChain);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment