summaryrefslogtreecommitdiff
path: root/mpi.cpp
diff options
context:
space:
mode:
authorErwin Nindl <nine@wirdorange.org>2007-12-11 17:47:29 +0000
committerErwin Nindl <nine@wirdorange.org>2007-12-11 17:47:29 +0000
commitf7307935fb087f8c327c8d8f09f8837925e70c34 (patch)
treea6fb23076c80ee1590d9937bf6dbbd169fab7f13 /mpi.cpp
parentkd iv generation fix again (diff)
set iv to fixed length of 16byte in kd
Diffstat (limited to 'mpi.cpp')
-rw-r--r--mpi.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/mpi.cpp b/mpi.cpp
index b8a4b6c..6a94f3e 100644
--- a/mpi.cpp
+++ b/mpi.cpp
@@ -127,14 +127,17 @@ void Mpi::clearHighBit(u_int32_t n)
gcry_mpi_clear_highbit( val_, n );
}
-Buffer Mpi::getBuf() const
+Buffer Mpi::getBuf(u_int32_t min_len) const
{
u_int32_t len = 0, written = 0;
len = gcry_mpi_get_nbits( val_ );
Buffer res(static_cast<u_int32_t>(len/8)+1);
- gcry_mpi_print( GCRYMPI_FMT_STD, res, len, &written, val_ );
+ if(res.getLength() < min_len)
+ res.resizeBack(min_len);
+
+ gcry_mpi_print( GCRYMPI_FMT_STD, res, res.getLength(), &written, val_ );
return res;
}