@Test public void normalizationTest() { byte[] b = new byte[3]; b = RemoteKey.normalize(b); Assert.assertEquals(32, b.length); b = new byte[40]; b = RemoteKey.normalize(b); Assert.assertEquals(32, b.length); b = new byte[]{1, 2, 3}; b = RemoteKey.normalize(b); Assert.assertEquals(1, b[29]); Assert.assertEquals(2, b[30]); Assert.assertEquals(3, b[31]); b = new byte[100]; b[50] = 4; b[99] = 3; b[98] = 2; b[97] = 1; b = RemoteKey.normalize(b); Assert.assertEquals(1, b[29]); Assert.assertEquals(2, b[30]); Assert.assertEquals(3, b[31]); Assert.assertFalse(Arrays.contains(toIntArray(b), 4)); }
public static byte[] normalize(byte[] sharedSecret) { if (sharedSecret.length < 32) { byte[] fixed = new byte[32]; int len = sharedSecret.length; System.arraycopy(sharedSecret, 0, fixed, 32 - len, len); sharedSecret = fixed; } else if (sharedSecret.length > 32) { byte[] fixed = new byte[32]; System.arraycopy(sharedSecret, sharedSecret.length - 32, fixed, 0, fixed.length); sharedSecret = fixed; } return sharedSecret; }
RemoteKey { public static byte[] normalize(byte[] sharedSecret) { if (sharedSecret.length < 32) { byte[] fixed = new byte[32]; int len = sharedSecret.length; System.arraycopy(sharedSecret, 0, fixed, 32 - len, len); sharedSecret = fixed; } else if (sharedSecret.length > 32) { byte[] fixed = new byte[32]; System.arraycopy(sharedSecret, sharedSecret.length - 32, fixed, 0, fixed.length); sharedSecret = fixed; } return sharedSecret; } }
RemoteKey { public static byte[] normalize(byte[] sharedSecret) { if (sharedSecret.length < 32) { byte[] fixed = new byte[32]; int len = sharedSecret.length; System.arraycopy(sharedSecret, 0, fixed, 32 - len, len); sharedSecret = fixed; } else if (sharedSecret.length > 32) { byte[] fixed = new byte[32]; System.arraycopy(sharedSecret, sharedSecret.length - 32, fixed, 0, fixed.length); sharedSecret = fixed; } return sharedSecret; } private  RemoteKey(byte[] sharedSecret); }
RemoteKey { public static byte[] normalize(byte[] sharedSecret) { if (sharedSecret.length < 32) { byte[] fixed = new byte[32]; int len = sharedSecret.length; System.arraycopy(sharedSecret, 0, fixed, 32 - len, len); sharedSecret = fixed; } else if (sharedSecret.length > 32) { byte[] fixed = new byte[32]; System.arraycopy(sharedSecret, sharedSecret.length - 32, fixed, 0, fixed.length); sharedSecret = fixed; } return sharedSecret; } private  RemoteKey(byte[] sharedSecret); byte[] getSharedSecret(); static RemoteKey generate(LocalKeys keys, String tempKey); static byte[] normalize(byte[] sharedSecret); }
RemoteKey { public static byte[] normalize(byte[] sharedSecret) { if (sharedSecret.length < 32) { byte[] fixed = new byte[32]; int len = sharedSecret.length; System.arraycopy(sharedSecret, 0, fixed, 32 - len, len); sharedSecret = fixed; } else if (sharedSecret.length > 32) { byte[] fixed = new byte[32]; System.arraycopy(sharedSecret, sharedSecret.length - 32, fixed, 0, fixed.length); sharedSecret = fixed; } return sharedSecret; } private  RemoteKey(byte[] sharedSecret); byte[] getSharedSecret(); static RemoteKey generate(LocalKeys keys, String tempKey); static byte[] normalize(byte[] sharedSecret);  }