[tor-bugs] #9988 [BridgeDB]: Refactor BridgeDB's use of `sha` module to use `hashlib` instead.

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Feb 4 16:15:44 UTC 2014


#9988: Refactor BridgeDB's use of `sha` module to use `hashlib` instead.
--------------------------+----------------------
     Reporter:  isis      |      Owner:  isis
         Type:  defect    |     Status:  closed
     Priority:  trivial   |  Milestone:
    Component:  BridgeDB  |    Version:
   Resolution:  fixed     |   Keywords:  bridgedb
Actual Points:            |  Parent ID:
       Points:            |
--------------------------+----------------------
Changes (by isis):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 Voodoo. I applied ovnicraft's patch right about when sysrqb made the last
 comment.

 As sysrqb pointed out, the `hashlib.new()` constructor is meant for non-
 default OpenSSL digest algorithms, and it's slower that the specialised
 constructors.

 There is also the tiny problem that in `bridgedb.Storage`, where
 `hashlib.new()` was being called, it wasn't being given a string
 specifying an algorithm name as argument; it was being given email
 addresses and IP addresses. Which causes it to throw a bunch of
 exceptions, but these don't show up in any of the current unittests yet
 because the `Storage` module isn't well tested. But that is technically my
 fault, the sed line I gave assumed that `sha.sha1()` was being called
 everywhere, I totally missed that `sha.new()` was being called in the
 `Storage` module.

 My commit 124db8690726a1867df9f1f9fee601b7479fc6cb in branch
 [https://gitweb.torproject.org/user/isis/bridgedb.git/shortlog/refs/heads/fix/9988
 -rm-hashlibnew fix/9988-rm-hashlibnew] fixes this, and I merged it to
 develop for the release of 0.1.1 (due to the urgent redeploy for #10796).

 Thanks ovnicraft! I credited you as the author in the commit, hope that
 was okay to do.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/9988#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list