summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard/crypto
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-11-20 11:44:34 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-11-20 12:44:54 +0100
commit8b0123042f54d843301fbef458b249fcf12466d2 (patch)
treeb3e7bd9f143568666d21014eafe544affb0a89b7 /app/src/main/java/com/wireguard/crypto
parent16890a659e6d7877b86e870fe4f0ef9cc19aee5b (diff)
Implement statistics
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/crypto')
-rw-r--r--app/src/main/java/com/wireguard/crypto/Key.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/src/main/java/com/wireguard/crypto/Key.java b/app/src/main/java/com/wireguard/crypto/Key.java
index f743ddd2..6648a5f3 100644
--- a/app/src/main/java/com/wireguard/crypto/Key.java
+++ b/app/src/main/java/com/wireguard/crypto/Key.java
@@ -7,6 +7,7 @@ package com.wireguard.crypto;
import com.wireguard.crypto.KeyFormatException.Type;
+import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.Arrays;
@@ -247,6 +248,24 @@ public final class Key {
return new String(output);
}
+ @Override
+ public int hashCode() {
+ int ret = 0;
+ for (int i = 0; i < key.length / 4; ++i)
+ ret ^= (key[i * 4 + 0] >> 0) + (key[i * 4 + 1] >> 8) + (key[i * 4 + 2] >> 16) + (key[i * 4 + 3] >> 24);
+ return ret;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == this)
+ return true;
+ if (obj == null || obj.getClass() != getClass())
+ return false;
+ final Key other = (Key) obj;
+ return MessageDigest.isEqual(key, other.key);
+ }
+
/**
* The supported formats for encoding a WireGuard key.
*/