summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Nindl <nine@wirdorange.org>2007-12-11 16:35:07 +0000
committerErwin Nindl <nine@wirdorange.org>2007-12-11 16:35:07 +0000
commitb6f796adf863d1800c03bc2519108a9ea6f532bf (patch)
tree5ce09d8e0f1270b1f9d50f935f90dc3b8d14d765
parentreplay protection works again (diff)
* added mpi operator
* kd iv generation fix
-rw-r--r--keyDerivation.cpp7
-rw-r--r--mpi.cpp7
-rw-r--r--mpi.h1
3 files changed, 14 insertions, 1 deletions
diff --git a/keyDerivation.cpp b/keyDerivation.cpp
index afe20f6..809a354 100644
--- a/keyDerivation.cpp
+++ b/keyDerivation.cpp
@@ -124,11 +124,16 @@ void KeyDerivation::generate(satp_prf_label label, seq_nr_t seq_nr, Buffer& key,
r = static_cast<long unsigned int>(seq_nr / ( 0x01 << ld_kdr_ ));
r = r.mul2exp(8);
- key_id = r + Mpi(static_cast<long unsigned int>(label));
+ key_id = r + static_cast<long unsigned int>(label);
Mpi salt = Mpi(salt_.getBuf(), salt_.getLength());
iv = key_id ^ salt;
+ std::cout << "KeyDerivation::generate: r_len: "<< r.getLen() << std::endl;
+ std::cout << "KeyDerivation::generate: key_id_len: "<< key_id.getLen() << std::endl;
+ std::cout << "KeyDerivation::generate: salt_len: "<< salt.getLen() << std::endl;
+ std::cout << "KeyDerivation::generate: iv_len: "<< iv.getLen() << std::endl;
+
err = gcry_cipher_reset( cipher_ );
if( err )
cLog.msg(Log::PRIO_ERR) << "KeyDerivation::generate: Failed to reset cipher: " << gpg_strerror( err );
diff --git a/mpi.cpp b/mpi.cpp
index 5e094ae..8d35bb8 100644
--- a/mpi.cpp
+++ b/mpi.cpp
@@ -74,6 +74,13 @@ Mpi Mpi::operator+(const Mpi &b) const
return res;
}
+Mpi Mpi::operator+(const long unsigned int &b) const
+{
+ Mpi res;
+ gcry_mpi_add_ui(res.val_, val_, b);
+ return res;
+}
+
Mpi Mpi::operator*(const unsigned long int n) const
{
Mpi res;
diff --git a/mpi.h b/mpi.h
index 1be758e..12079c5 100644
--- a/mpi.h
+++ b/mpi.h
@@ -48,6 +48,7 @@ public:
void operator=(const Mpi &src);
void operator=(long unsigned int);
Mpi operator+(const Mpi &b) const;
+ Mpi operator+(const long unsigned int &b) const;
Mpi operator^(const Mpi &b) const;
Mpi operator*(const unsigned long int n) const;