[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-bugs] #18280 [Tor]: base32 encoding API doesn't work for a source length that is not a multiple of 5 or 8



#18280: base32 encoding API doesn't work for a source length that is not a multiple
of 5 or 8
-------------------------+--------------------------------
     Reporter:  dgoulet  |      Owner:
         Type:  defect   |     Status:  new
     Priority:  Medium   |  Milestone:  Tor: 0.2.9.x-final
    Component:  Tor      |    Version:
     Severity:  Normal   |   Keywords:
Actual Points:           |  Parent ID:  #18278
       Points:  small    |    Sponsor:  SponsorR
-------------------------+--------------------------------
 Assuming `base32_encode()` here (but same issue goes for the decode
 function), it has a hard requirement of:
 {{{
 Limitation: Requires that srclen*8 is a multiple of 5.
 }}}

 Now, this has some drawbacks because `srclen` is the length in _bytes_ of
 what we want to encode. So assuming I want to encode 32 bytes, well I
 can't because `32 * 8 == 256` which is shy of 4 bits to be a multiple of 8
 (260).

 But how fun, since I can only pass bytes to that function, how can I tell
 it to use a srclen of 260 bits (32.5 bytes)? It seems to me we need a
 function call that takes bits instead of bytes? Or give a positive float
 as `srclen` (sounds crazy)?

 Or make `base32_encode()` more smart by using `floor((srclen * 8) / 5)` as
 the destination bytes length which will result in the right amount of bit
 (260 in this case). So that means, the caller must be smart and set the
 appropriate number of bytes + the extra bits. So to encode 32 bytes + 4
 bit, the caller would have to pass a srclen of 33 and expect that 260 bit
 will be written and not 264.

 (Setting parent ID to the proposal 224 key handling since it's a blocker
 to generate correctly the onion address).

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/18280>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs