Skip to content

Commit

Permalink
Merge pull request #486 from lf-/jade/fix-u2f-equality
Browse files Browse the repository at this point in the history
Add missing U2F {ed25519,ecdsa}-sk public key equality methods
  • Loading branch information
tomaswolf committed Apr 27, 2024
2 parents 959da84 + 4e1e457 commit f8a0aec
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.sshd.common.config.keys.u2f;

import java.util.Objects;
import net.i2p.crypto.eddsa.EdDSAPublicKey;

public class SkED25519PublicKey implements SecurityKeyPublicKey<EdDSAPublicKey> {
Expand Down Expand Up @@ -74,4 +75,27 @@ public String toString() {
+ ", delegatePublicKey=" + getDelegatePublicKey()
+ "]";
}

@Override
public int hashCode() {
return Objects.hash(appName, noTouchRequired, delegatePublicKey);
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (getClass() != obj.getClass()) {
return false;
}

SkED25519PublicKey other = (SkED25519PublicKey) obj;
return Objects.equals(this.appName, other.appName)
&& this.noTouchRequired == other.noTouchRequired
&& Objects.equals(this.delegatePublicKey, other.delegatePublicKey);
}
}
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.sshd.common.config.keys.u2f;

import java.util.Objects;
import java.security.interfaces.ECPublicKey;

public class SkEcdsaPublicKey implements SecurityKeyPublicKey<ECPublicKey> {
Expand Down Expand Up @@ -74,4 +75,27 @@ public String toString() {
+ ", delegatePublicKey=" + getDelegatePublicKey()
+ "]";
}

@Override
public int hashCode() {
return Objects.hash(appName, noTouchRequired, delegatePublicKey);
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (getClass() != obj.getClass()) {
return false;
}

SkEcdsaPublicKey other = (SkEcdsaPublicKey) obj;
return Objects.equals(this.appName, other.appName)
&& this.noTouchRequired == other.noTouchRequired
&& Objects.equals(this.delegatePublicKey, other.delegatePublicKey);
}
}

0 comments on commit f8a0aec

Please sign in to comment.