diff options
author | Timo Weingärtner <timo@tiwe.de> | 2015-09-06 18:33:04 +0200 |
---|---|---|
committer | Timo Weingärtner <timo@tiwe.de> | 2015-09-06 18:33:04 +0200 |
commit | a11402917796dd21b59c537d3f10c05d3bcefd55 (patch) | |
tree | 7a04962ac6f463d42a62ec9d3e18f6d8dae66634 /rfc4251_gmp.C | |
parent | 602a625ff53118e9052326e5038055aa1d750e23 (diff) | |
parent | c9dfa57b7a06c5b0770e11d210e02ace54518644 (diff) | |
download | ssh-agent-filter-a11402917796dd21b59c537d3f10c05d3bcefd55.tar.gz |
Merge tag '0.4.1' into debian
0.4.1
Diffstat (limited to 'rfc4251_gmp.C')
-rw-r--r-- | rfc4251_gmp.C | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/rfc4251_gmp.C b/rfc4251_gmp.C index d3a664e..b4c369b 100644 --- a/rfc4251_gmp.C +++ b/rfc4251_gmp.C @@ -1,9 +1,9 @@ /* - * rfc4251_gmp.C -- implements mpint/gmp conversions for rfc4251string + * rfc4251_gmp.C -- implements mpint/gmp conversions for rfc4251::string * * these functions need linking against libgmp * - * Copyright (C) 2013 Timo Weingärtner <timo@tiwe.de> + * Copyright (C) 2013,2015 Timo Weingärtner <timo@tiwe.de> * * This file is part of ssh-agent-filter. * @@ -21,9 +21,11 @@ * along with ssh-agent-filter. If not, see <http://www.gnu.org/licenses/>. */ -#include "rfc4251.h" +#include "rfc4251.H" -rfc4251string::rfc4251string (mpz_srcptr x) { +namespace rfc4251 { + +string::string (mpz_srcptr x) { if (mpz_sgn(x) == 0) return; @@ -32,7 +34,7 @@ rfc4251string::rfc4251string (mpz_srcptr x) { size_t bytes{(bits + 7) / 8}; size_t extrabyte{(bits % 8) == 0}; // need extra byte if MSB is 1 to keep it non-negative if (bytes + extrabyte > std::numeric_limits<uint32_t>::max()) - throw std::length_error{"32-bit limit for rfc4251string exceeded"}; + throw std::length_error{"32-bit limit for rfc4251::string exceeded"}; value.resize(bytes + extrabyte); value[0] = 0; mpz_export(value.data() + extrabyte, nullptr, 1, 1, 1, 0, x); @@ -49,7 +51,7 @@ rfc4251string::rfc4251string (mpz_srcptr x) { } } -rfc4251string::operator mpz_class () const { +string::operator mpz_class () const { mpz_class ret; mpz_import(ret.get_mpz_t(), value.size(), 1, 1, 1, 0, value.data()); if (mpz_sizeinbase(ret.get_mpz_t(), 2) == value.size() * 8) { // negative @@ -59,3 +61,5 @@ rfc4251string::operator mpz_class () const { } return ret; } + +} |