diff --git a/grc/decryption/gsm_decryption.xml b/grc/decryption/gsm_decryption.xml
index ae91408..4f3de22 100644
--- a/grc/decryption/gsm_decryption.xml
+++ b/grc/decryption/gsm_decryption.xml
@@ -3,15 +3,25 @@
Decryption
gsm_decryption
import grgsm
- grgsm.decryption($k_c)
+ grgsm.decryption($k_c, $a5_version)
Kc session key
k_c
- [0,0,0,0,0,0,0,0]
+ [0,0,0,0,0,0,0,0]
int_vector
+
+ A5 version
+ a5_version
+ 1
+ int
+
+
+ $a5_version > 0
+ $a5_version < 5
+
bursts
message
@@ -20,5 +30,5 @@
bursts
message
-
+
diff --git a/include/grgsm/decryption/decryption.h b/include/grgsm/decryption/decryption.h
index be0f7cd..51328b1 100644
--- a/include/grgsm/decryption/decryption.h
+++ b/include/grgsm/decryption/decryption.h
@@ -1,14 +1,14 @@
/* -*- c++ -*- */
-/*
+/*
* @file
* @author Piotr Krysik
* @section LICENSE
- *
+ *
* Gr-gsm is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
- *
+ *
* Gr-gsm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -18,7 +18,7 @@
* along with gr-gsm; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
- *
+ *
*/
@@ -50,8 +50,9 @@ namespace gr {
* class. gsm::decryption::make is the public interface for
* creating new instances.
*/
- static sptr make(const std::vector & k_c);
+ static sptr make(const std::vector & k_c, unsigned int a5_version);
virtual void set_k_c(const std::vector & k_c) = 0;
+ virtual void set_a5_version(unsigned int a5_version) = 0;
};
} // namespace gsm
diff --git a/lib/decryption/decryption_impl.cc b/lib/decryption/decryption_impl.cc
index 836d9d2..9e6112b 100644
--- a/lib/decryption/decryption_impl.cc
+++ b/lib/decryption/decryption_impl.cc
@@ -25,6 +25,7 @@
#include
#include
#include
+#include
#include "decryption_impl.h"
extern "C" {
@@ -37,21 +38,24 @@ namespace gr {
namespace gsm {
decryption::sptr
- decryption::make(const std::vector & k_c)
+ decryption::make(const std::vector & k_c, unsigned int a5_version)
{
return gnuradio::get_initial_sptr
- (new decryption_impl(k_c));
+ (new decryption_impl(k_c, a5_version));
}
/*
* The private constructor
*/
- decryption_impl::decryption_impl(const std::vector & k_c)
+ decryption_impl::decryption_impl(const std::vector & k_c, unsigned int a5_version)
: gr::block("decryption",
gr::io_signature::make(0, 0, 0),
- gr::io_signature::make(0, 0, 0))
+ gr::io_signature::make(0, 0, 0)),
+ d_k_c_valid(false)
{
set_k_c(k_c);
+ set_a5_version(a5_version);
+ validate_k_c();
// std::cout << "Be careful with decryption block - it wasn't tested yet!" << std::endl;
message_port_register_in(pmt::mp("bursts"));
@@ -68,29 +72,50 @@ namespace gr {
void decryption_impl::set_k_c(const std::vector & k_c)
{
- if (k_c.size() == 8)
+ d_k_c = k_c;
+ }
+
+ void decryption_impl::set_a5_version(unsigned int a5_version)
+ {
+ d_a5_version = 1;
+ if (a5_version >= 1 && a5_version <= 4)
{
- for (int i=0; i<8; i++)
- {
- d_k_c[i] = k_c[i];
- }
+ d_a5_version = a5_version;
+ }
+ }
+
+ void decryption_impl::validate_k_c()
+ {
+ if (d_k_c.size() == 0)
+ {
+ d_k_c_valid = false;
+ return;
+ }
+ else if ((d_a5_version < 4 && d_k_c.size() != 8) || (d_a5_version == 4 && d_k_c.size() != 16))
+ {
+ d_k_c_valid = false;
+ return;
}
else
{
- for (int i=0; i<8; i++)
+ for (int i=0; i d_k_c;
- uint8_t d_k_c[8];
+ std::vector d_k_c;
+ bool d_k_c_valid;
+ uint8_t d_a5_version;
void decrypt(pmt::pmt_t msg);
+ void validate_k_c();
public:
- decryption_impl(const std::vector & k_c);
+ decryption_impl(const std::vector & k_c, unsigned int a5_version);
~decryption_impl();
virtual void set_k_c(const std::vector & k_c);
+ virtual void set_a5_version(unsigned int a5_version);
};
} // namespace gsm
} // namespace gr