aboutsummaryrefslogtreecommitdiffstats
path: root/lib/decryption
diff options
context:
space:
mode:
authorptrkrysik <ptrkrysik@gmail.com>2014-12-15 09:38:00 +0100
committerptrkrysik <ptrkrysik@gmail.com>2014-12-15 09:38:00 +0100
commita1871f5cd1b2a9b202897bc30e77c53cd729d09c (patch)
tree158c8ac18da1dddd560b31a9f474319e45a6006e /lib/decryption
parenta31a481fd19e2964ed462c13eab4d09cceda2e66 (diff)
Correction in decryption block
Diffstat (limited to 'lib/decryption')
-rw-r--r--lib/decryption/a5_1_2.h13
-rw-r--r--lib/decryption/decryption_impl.cc4
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/decryption/a5_1_2.h b/lib/decryption/a5_1_2.h
index fb87498..75277df 100644
--- a/lib/decryption/a5_1_2.h
+++ b/lib/decryption/a5_1_2.h
@@ -364,13 +364,13 @@ void run(byte AtoBkeystream[], byte BtoAkeystream[]) {
}
}
-void runA51(unsigned char AtoBkeystream[]) {
+void runA51(byte AtoBkeystream[], byte BtoAkeystream[]) {
int i;
/* Zero out the output buffers. */
- for (i = 0; i < 114; i++)
+ for (i = 0; i < 114; i++){
AtoBkeystream[i] = 0;
-
+ }
/* Generate 114 bits of keystream for the
* A->B direction. Store it, MSB first. */
@@ -378,6 +378,13 @@ void runA51(unsigned char AtoBkeystream[]) {
clock(0, 0);
AtoBkeystream[i] = getbit();
}
+
+ /* Generate 114 bits of keystream for the
+ * B->A direction. Store it, MSB first. */
+ for (i = 0; i < 114; i++) {
+ clock(0, 0);
+ BtoAkeystream[i] = getbit();
+ }
}
diff --git a/lib/decryption/decryption_impl.cc b/lib/decryption/decryption_impl.cc
index 4347b62..60409c7 100644
--- a/lib/decryption/decryption_impl.cc
+++ b/lib/decryption/decryption_impl.cc
@@ -95,7 +95,7 @@ namespace gr {
uint32_t t3 = frame_number % 51;
uint32_t frame_number_mod = (t1 << 11) + (t3 << 5) + t2;
keysetup(&d_k_c[0], frame_number_mod);
- run(AtoBkeystream, BtoAkeystream);
+ runA51(AtoBkeystream, BtoAkeystream);
if(uplink_burst){
//process uplink burst
@@ -108,6 +108,7 @@ namespace gr {
for (int i = 0; i < 3; i++) {
decrypted_data[i] = burst_binary[i];
}
+ //encrypt first part of the burst
for (int i = 0; i < 57; i++) {
decrypted_data[i+3] = keystream[i] ^ burst_binary[i+3];
}
@@ -115,6 +116,7 @@ namespace gr {
for (int i = 60; i < 88; i++) {
decrypted_data[i] = burst_binary[i];
}
+ //encrypt second part of the burst
for (int i = 0; i < 57; i++) {
decrypted_data[i+88] = keystream[i+57] ^ burst_binary[i+88];
}