diff options
-rw-r--r-- | keyDerivation.cpp | 7 | ||||
-rw-r--r-- | mpi.cpp | 7 | ||||
-rw-r--r-- | mpi.h | 1 |
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 ); @@ -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; @@ -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; |