diff options
author | Samuel Holland <samuel@sholland.org> | 2017-08-13 07:24:03 -0500 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2017-08-13 07:24:03 -0500 |
commit | 5e55d196be092f4a4dcb212cf09d7a1bdab70e00 (patch) | |
tree | eb765a1b961fefdaa7ddc3cfae9cb83a09e0c031 /app/src/main/java/com/wireguard/crypto | |
parent | c72d30a1af8114ef506a137e3e7274ac33d82bd1 (diff) |
Major renaming and refactoring in activity and service
Apparently "configuration" is the proper term, not "profile".
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/Curve25519.java | 1 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/crypto/KeyEncoding.java | 14 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/crypto/Keypair.java | 6 |
3 files changed, 11 insertions, 10 deletions
diff --git a/app/src/main/java/com/wireguard/crypto/Curve25519.java b/app/src/main/java/com/wireguard/crypto/Curve25519.java index 17f1b3d7..fdc89635 100644 --- a/app/src/main/java/com/wireguard/crypto/Curve25519.java +++ b/app/src/main/java/com/wireguard/crypto/Curve25519.java @@ -38,6 +38,7 @@ import java.util.Arrays; * * References: http://cr.yp.to/ecdh.html, RFC 7748 */ +@SuppressWarnings("ALL") public final class Curve25519 { // Numbers modulo 2^255 - 19 are broken up into ten 26-bit words. diff --git a/app/src/main/java/com/wireguard/crypto/KeyEncoding.java b/app/src/main/java/com/wireguard/crypto/KeyEncoding.java index 070a1a99..f83fd0b1 100644 --- a/app/src/main/java/com/wireguard/crypto/KeyEncoding.java +++ b/app/src/main/java/com/wireguard/crypto/KeyEncoding.java @@ -28,10 +28,10 @@ public class KeyEncoding { } private static void encodeBase64(final byte[] src, final int src_offset, - char[] dest, final int dest_offset) { + final char[] dest, final int dest_offset) { final byte[] input = { - (byte) ((src[0 + src_offset] >>> 2) & 63), - (byte) ((src[0 + src_offset] << 4 | ((src[1 + src_offset] & 0xff) >>> 4)) & 63), + (byte) ((src[src_offset] >>> 2) & 63), + (byte) ((src[src_offset] << 4 | ((src[1 + src_offset] & 0xff) >>> 4)) & 63), (byte) ((src[1 + src_offset] << 2 | ((src[2 + src_offset] & 0xff) >>> 6)) & 63), (byte) ((src[2 + src_offset]) & 63), }; @@ -54,12 +54,12 @@ public class KeyEncoding { final int val = decodeBase64(input, i * 4); if (val < 0) throw new IllegalArgumentException(KEY_LENGTH_BASE64_EXCEPTION_MESSAGE); - key[i * 3 + 0] = (byte) ((val >>> 16) & 0xff); + key[i * 3] = (byte) ((val >>> 16) & 0xff); key[i * 3 + 1] = (byte) ((val >>> 8) & 0xff); key[i * 3 + 2] = (byte) (val & 0xff); } final char[] endSegment = { - input[i * 4 + 0], + input[i * 4], input[i * 4 + 1], input[i * 4 + 2], 'A', @@ -67,7 +67,7 @@ public class KeyEncoding { final int val = decodeBase64(endSegment, 0); if (val < 0 || (val & 0xff) != 0) throw new IllegalArgumentException(KEY_LENGTH_BASE64_EXCEPTION_MESSAGE); - key[i * 3 + 0] = (byte) ((val >>> 16) & 0xff); + key[i * 3] = (byte) ((val >>> 16) & 0xff); key[i * 3 + 1] = (byte) ((val >>> 8) & 0xff); return key; } @@ -80,7 +80,7 @@ public class KeyEncoding { for (i = 0; i < KEY_LENGTH / 3; ++i) encodeBase64(key, i * 3, output, i * 4); final byte[] endSegment = { - key[i * 3 + 0], + key[i * 3], key[i * 3 + 1], 0, }; diff --git a/app/src/main/java/com/wireguard/crypto/Keypair.java b/app/src/main/java/com/wireguard/crypto/Keypair.java index bd6fd90f..e0d35d64 100644 --- a/app/src/main/java/com/wireguard/crypto/Keypair.java +++ b/app/src/main/java/com/wireguard/crypto/Keypair.java @@ -17,7 +17,7 @@ public class Keypair { return privateKey; } - private static byte[] generatePublicKey(byte[] privateKey) { + private static byte[] generatePublicKey(final byte[] privateKey) { final byte[] publicKey = new byte[KeyEncoding.KEY_LENGTH]; Curve25519.eval(publicKey, 0, privateKey, null); return publicKey; @@ -30,12 +30,12 @@ public class Keypair { this(generatePrivateKey()); } - private Keypair(byte[] privateKey) { + private Keypair(final byte[] privateKey) { this.privateKey = privateKey; publicKey = generatePublicKey(privateKey); } - public Keypair(String privateKey) { + public Keypair(final String privateKey) { this(KeyEncoding.keyFromBase64(privateKey)); } |