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

Commit f3da868d authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Keystore 2.0 SPI: Fix contract between equals and hashCode" am: efc03680

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1794807

Change-Id: Id19fa4dc6ca62339315652f98a6d66f12dbff51c
parents 461ea8ce efc03680
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -102,11 +102,9 @@ public class AndroidKeyStoreKey implements Key {
        final int prime = 31;
        int result = 1;

        result = prime * result + ((mDescriptor == null) ? 0 : mDescriptor.hashCode());
        result = prime * result + getClass().hashCode();
        result = prime * result + (int) (mKeyId >>> 32);
        result = prime * result + (int) (mKeyId & 0xffffffff);
        result = prime * result + ((mAuthorizations == null) ? 0 : mAuthorizations.hashCode());
        result = prime * result + ((mAlgorithm == null) ? 0 : mAlgorithm.hashCode());
        return result;
    }

@@ -122,10 +120,6 @@ public class AndroidKeyStoreKey implements Key {
            return false;
        }
        AndroidKeyStoreKey other = (AndroidKeyStoreKey) obj;
        if (mKeyId != other.mKeyId) {
            return false;
        }

        return true;
        return mKeyId == other.mKeyId;
    }
}
+10 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.system.keystore2.KeyDescriptor;
import android.system.keystore2.KeyMetadata;

import java.security.PublicKey;
import java.util.Objects;

/**
 * {@link PublicKey} backed by Android Keystore.
@@ -75,9 +76,14 @@ public abstract class AndroidKeyStorePublicKey extends AndroidKeyStoreKey implem
        if (!super.equals(obj)) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        return true;

        /*
         * getClass().equals(ojb.getClass()) is implied by the call to super.equals() above. This
         * means we can cast obj to AndroidKeyStorePublicKey here.
         */
        final AndroidKeyStorePublicKey other = (AndroidKeyStorePublicKey) obj;

        return Objects.equals(mCertificate, other.mCertificate) && Objects.equals(mCertificateChain,
                other.mCertificateChain);
    }
}