@@ -106,7 +106,7 @@ BaseNEncoder::encode(const std::vector<uint8_t>& input) {
106
106
} else {
107
107
// No, the index is complete, lookup its digit and add it to the
108
108
// output. Start over for the next index.
109
- encoded_output.push_back (digit_set_[ digit_idx] );
109
+ encoded_output.push_back (bitsToDigit ( digit_idx) );
110
110
digit_idx = 0 ;
111
111
cnt = 0 ;
112
112
}
@@ -149,7 +149,7 @@ BaseNEncoder::encode(const std::vector<uint8_t>& input) {
149
149
void
150
150
BaseNEncoder::decode (const std::string& encoded_str, std::vector<uint8_t >& output) {
151
151
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
153
153
// string's digits, discarding whitespaces. We lookup the digit's binary value
154
154
// in the lookup table, keeping only binary value's right-most, bits_per_digit bits.
155
155
// 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
250
250
// The number of bits for the '==...' part is padchars * BitsPerChunk.
251
251
// So the total number of pad bits is the smallest multiple of 8
252
252
// 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
254
254
// lowest three bits, so has the effect of rounding the result down to the
255
255
// 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 ;
257
257
if (padbits > bits_per_digit_ * (pad_cnt + 1 )) {
258
258
isc_throw (isc::BadValue, " Invalid padding for "
259
259
<< algorithm_ << " : " << encoded_str);
0 commit comments