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>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user