@@ -106,7 +106,7 @@ BaseNEncoder::encode(const std::vector<uint8_t>& input) {
106106 } else {
107107 // No, the index is complete, lookup its digit and add it to the
108108 // output. Start over for the next index.
109- encoded_output.push_back (digit_set_[ digit_idx] );
109+ encoded_output.push_back (bitsToDigit ( digit_idx) );
110110 digit_idx = 0 ;
111111 cnt = 0 ;
112112 }
@@ -149,7 +149,7 @@ BaseNEncoder::encode(const std::vector<uint8_t>& input) {
149149void
150150BaseNEncoder::decode (const std::string& encoded_str, std::vector<uint8_t >& output) {
151151
152- // Mechanics are the essentially the same as encode(). We iterate over the encoded
152+ // Mechanics are essentially the same as encode(). We iterate over the encoded
153153 // string's digits, discarding whitespaces. We lookup the digit's binary value
154154 // in the lookup table, keeping only binary value's right-most, bits_per_digit bits.
155155 // The remaining bits are then shifted out from the left of binary value into the
@@ -250,10 +250,10 @@ BaseNEncoder::decode(const std::string& encoded_str, std::vector<uint8_t>& outpu
250250 // The number of bits for the '==...' part is padchars * BitsPerChunk.
251251 // So the total number of pad bits is the smallest multiple of 8
252252 // that is >= padchars * BitsPerChunk.
253- // (Below, note the common idiom of the bitwise AND with ~7 . It clears the
253+ // (Below, note the common idiom of the bitwise AND with ~0x7 . It clears the
254254 // lowest three bits, so has the effect of rounding the result down to the
255255 // nearest multiple of 8)
256- const size_t padbits = ((pad_cnt * bits_per_digit_) + 0x07 ) & ~0x07 ;
256+ const size_t padbits = ((pad_cnt * bits_per_digit_) + 7 ) & ~0x7 ;
257257 if (padbits > bits_per_digit_ * (pad_cnt + 1 )) {
258258 isc_throw (isc::BadValue, " Invalid padding for "
259259 << algorithm_ << " : " << encoded_str);
0 commit comments