mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-09 23:27:24 -05:00
Compare commits
11 Commits
v0.3.2-bet
...
v0.3.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e321bdaa3 | ||
|
|
f191d28c98 | ||
|
|
afc3d299b6 | ||
|
|
0471d90b54 | ||
|
|
8f68967b6c | ||
|
|
91b950c13d | ||
|
|
581ff9f449 | ||
|
|
67c3cb9639 | ||
|
|
cebd2da89f | ||
|
|
73b6ef164f | ||
|
|
b2c7ac8c66 |
@@ -6,8 +6,8 @@
|
||||
<!-- version properties -->
|
||||
<property name="major" value="0"/>
|
||||
<property name="minor" value="3"/>
|
||||
<property name="patch" value="1"/>
|
||||
<property name="release" value=""/> <!-- Use dash (-) prefix (e.g. -beta1) -->
|
||||
<property name="patch" value="2"/>
|
||||
<property name="release" value=""/>
|
||||
<property name="filename" value="sdrtrunk_${major}.${minor}.${patch}${release}"/>
|
||||
|
||||
<!-- Build properties -->
|
||||
@@ -34,7 +34,7 @@
|
||||
<mkdir dir="${output.classes}"/>
|
||||
|
||||
<!-- Create version file -->
|
||||
<echo message="${major}.${minor}.${patch}${release}" file="${output.classes}/sdrtrunk-version"/>
|
||||
<echo message="${major}.${minor}.${patch}-${release}" file="${output.classes}/sdrtrunk-version"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="clean,init,compile-java-8,compile-java-9"
|
||||
|
||||
@@ -71,6 +71,40 @@ public class AuthenticateBroadcast extends UltravoxMessage
|
||||
setPayload(sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts the value using the XTEA block cipher algorithm. The byte array is sliced into 8-byte chunks and each
|
||||
* chunk is encrypted into a 16 hexadecimal character string. All encrypted chunks are concatenated and returned
|
||||
* as a single string. If the value byte array is not an even multiple of 8 characters, it will be padded with
|
||||
* zero valued bytes to make it an even multiple of eight.
|
||||
*
|
||||
* @param xtea instance of the XTEA algorithm with a loaded encryption key
|
||||
* @param value to encode
|
||||
* @return value encrypted into one or more multiples of 16 hexadecimal characters
|
||||
*/
|
||||
private static String encrypt(XTEA xtea, byte[] value)
|
||||
{
|
||||
if(value.length % 8 != 0 || value.length == 0)
|
||||
{
|
||||
int newLength = ((value.length / 8) + 1) * 8;
|
||||
value = Arrays.copyOf(value, newLength);
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(int x = 0; x < value.length; x += 8)
|
||||
{
|
||||
byte[] plaintext = Arrays.copyOfRange(value, x, x + 8);
|
||||
byte[] encrypted = xtea.encrypt(plaintext);
|
||||
|
||||
for(byte b: encrypted)
|
||||
{
|
||||
sb.append(String.format("%02x", b));
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts the value using the XTEA block cipher algorithm and returns the encrypted value as a 16 hex value
|
||||
*
|
||||
@@ -80,23 +114,6 @@ public class AuthenticateBroadcast extends UltravoxMessage
|
||||
*/
|
||||
private static String encrypt(XTEA xtea, String value)
|
||||
{
|
||||
byte[] valueBytes = value.getBytes();
|
||||
|
||||
if(valueBytes.length % 8 != 0 || valueBytes.length == 0)
|
||||
{
|
||||
int newLength = ((valueBytes.length / 8) + 1) * 8;
|
||||
valueBytes = Arrays.copyOf(valueBytes, newLength);
|
||||
}
|
||||
|
||||
byte[] encrypted = xtea.encrypt(valueBytes);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for(byte b: encrypted)
|
||||
{
|
||||
sb.append(String.format("%02x", b));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
return encrypt(xtea, value.getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class CRCLJ
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies 1 or 2 bit error positions that match the checksum error value.
|
||||
* Identifies 1 bit error positions that match the checksum error value.
|
||||
*/
|
||||
public static int[] findBitErrors( int checksumError )
|
||||
{
|
||||
@@ -180,24 +180,6 @@ public class CRCLJ
|
||||
}
|
||||
}
|
||||
|
||||
/* Two bit errors */
|
||||
for( int x = 0; x < 48; x++ )
|
||||
{
|
||||
for( int y = 0; y < 48; y++ )
|
||||
{
|
||||
if( x != y &&
|
||||
( CHECKSUMS[ x ] ^ CHECKSUMS[ y ] ) == checksumError )
|
||||
{
|
||||
int[] errors = new int[ 2 ];
|
||||
|
||||
errors[ 0 ] = x;
|
||||
errors[ 1 ] = y;
|
||||
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user