aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/asn1
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-01-09 11:38:33 -0500
committerJack Lloyd <[email protected]>2018-01-09 11:38:33 -0500
commit31ce2b9a5cd3013d5472fa2e606aba15a2620fcb (patch)
tree5271da7d8acb110864bb7dfcc592995c4656d69d /src/lib/asn1
parentbc36f04d9c536a608eaae68ce13cc84bef350f68 (diff)
Fix a bug in asn1print - zero integers were not printed
Diffstat (limited to 'src/lib/asn1')
-rw-r--r--src/lib/asn1/asn1_print.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/lib/asn1/asn1_print.cpp b/src/lib/asn1/asn1_print.cpp
index cdec367c9..425072e37 100644
--- a/src/lib/asn1/asn1_print.cpp
+++ b/src/lib/asn1/asn1_print.cpp
@@ -164,15 +164,11 @@ void ASN1_Formatter::decode(std::ostream& output,
data.decode(number, ENUMERATED, class_tag);
}
- const std::vector<uint8_t> rep = BigInt::encode(number, BigInt::Hexadecimal);
+ std::vector<uint8_t> rep = BigInt::encode(number, BigInt::Binary);
+ if(rep.empty()) // if zero
+ rep.resize(1);
- std::string str;
- for(size_t i = 0; i != rep.size(); ++i)
- {
- str += static_cast<char>(rep[i]);
- }
-
- output << format(type_tag, class_tag, level, length, str);
+ output << format(type_tag, class_tag, level, length, hex_encode(rep));
}
else if(type_tag == BOOLEAN)
{