aboutsummaryrefslogtreecommitdiff
path: root/rfc4251_gmp.C
diff options
context:
space:
mode:
authorTimo Weingärtner <timo@tiwe.de>2015-08-31 20:22:37 +0200
committerTimo Weingärtner <timo@tiwe.de>2015-08-31 20:22:37 +0200
commit8f675da301eafe79897f3ad67ff5450fcc397f78 (patch)
tree126388c8ff57830d8c3633827a5e4a2b94d7f5a2 /rfc4251_gmp.C
parent774ff2757de2a32c57046cbdc8425c6c22759035 (diff)
downloadssh-agent-filter-8f675da301eafe79897f3ad67ff5450fcc397f78.tar.gz
move rfc4251 types into their own namespace
Diffstat (limited to 'rfc4251_gmp.C')
-rw-r--r--rfc4251_gmp.C12
1 files changed, 8 insertions, 4 deletions
diff --git a/rfc4251_gmp.C b/rfc4251_gmp.C
index db46429..fe1f770 100644
--- a/rfc4251_gmp.C
+++ b/rfc4251_gmp.C
@@ -1,5 +1,5 @@
/*
- * 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
*
@@ -23,7 +23,9 @@
#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;
}
+
+}