diff options
author | Jack Lloyd <[email protected]> | 2018-01-09 11:38:33 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-01-09 11:38:33 -0500 |
commit | 31ce2b9a5cd3013d5472fa2e606aba15a2620fcb (patch) | |
tree | 5271da7d8acb110864bb7dfcc592995c4656d69d /src/lib/asn1 | |
parent | bc36f04d9c536a608eaae68ce13cc84bef350f68 (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.cpp | 12 |
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) { |