summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-05-02 10:30:36 -0500
committerSamuel Holland <samuel@sholland.org>2018-05-02 10:31:25 -0500
commit3e8d4575015dea12ec1edf87ffa5b9362ae0bb3e (patch)
tree0d9e66c64c80a98843f27dfb2ba7200d43662855
parentaa92c4a9d5d4ac16b0aef34827b445f73b2f92ca (diff)
KeyEncoding: Address lints/warnings and match line length
Signed-off-by: Samuel Holland <samuel@sholland.org>
-rw-r--r--app/src/main/java/com/wireguard/crypto/KeyEncoding.java21
1 files changed, 12 insertions, 9 deletions
diff --git a/app/src/main/java/com/wireguard/crypto/KeyEncoding.java b/app/src/main/java/com/wireguard/crypto/KeyEncoding.java
index 82e8904c..0c42acb0 100644
--- a/app/src/main/java/com/wireguard/crypto/KeyEncoding.java
+++ b/app/src/main/java/com/wireguard/crypto/KeyEncoding.java
@@ -91,17 +91,18 @@ public final class KeyEncoding {
if (input.length != KEY_LENGTH_HEX)
throw new IllegalArgumentException(KEY_LENGTH_HEX_EXCEPTION_MESSAGE);
- int c, c_acc = 0, c_alpha0, c_alpha, c_num0, c_num, c_val, state = 0;
+ int c_acc = 0;
+ int state = 0;
for (int i = 0; i < KEY_LENGTH_HEX; ++i) {
- c = input[i];
- c_num = c ^ 48;
- c_num0 = (c_num - 10) >> 8;
- c_alpha = (c & ~32) - 55;
- c_alpha0 = ((c_alpha - 10) ^ (c_alpha - 16)) >> 8;
+ final int c = input[i];
+ final int c_num = c ^ 48;
+ final int c_num0 = (c_num - 10) >> 8;
+ final int c_alpha = (c & ~32) - 55;
+ final int c_alpha0 = ((c_alpha - 10) ^ (c_alpha - 16)) >> 8;
if ((c_num0 | c_alpha0) == 0)
throw new IllegalArgumentException(KEY_LENGTH_HEX_EXCEPTION_MESSAGE);
- c_val = (c_num0 & c_num) | (c_alpha0 & c_alpha);
+ final int c_val = (c_num0 & c_num) | (c_alpha0 & c_alpha);
if (state == 0)
c_acc = c_val * 16;
else
@@ -133,8 +134,10 @@ public final class KeyEncoding {
if (key.length != KEY_LENGTH)
throw new IllegalArgumentException(KEY_LENGTH_EXCEPTION_MESSAGE);
for (int i = 0; i < KEY_LENGTH; ++i) {
- output[i * 2] = (char) (87 + (key[i] >> 4 & 0xf) + ((((key[i] >> 4 & 0xf) - 10) >> 8) & ~38));
- output[i * 2 + 1] = (char) (87 + (key[i] & 0xf) + ((((key[i] & 0xf) - 10) >> 8) & ~38));
+ output[i * 2] = (char) (87 + (key[i] >> 4 & 0xf)
+ + ((((key[i] >> 4 & 0xf) - 10) >> 8) & ~38));
+ output[i * 2 + 1] = (char) (87 + (key[i] & 0xf)
+ + ((((key[i] & 0xf) - 10) >> 8) & ~38));
}
return new String(output);
}