import appropriate modules for constant_time_compare to work

This commit is contained in:
Micah Lee 2014-08-20 21:29:45 +00:00
parent bda5bc3450
commit 2ac25e2995
2 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os, sys, subprocess, time, hashlib, platform, json, locale, socket, argparse, Queue, inspect, base64, mimetypes import os, sys, subprocess, time, hashlib, platform, json, locale, socket, argparse, Queue, inspect, base64, mimetypes, hmac
from random import randint from random import randint
from functools import wraps from functools import wraps
from itertools import izip
from stem.control import Controller from stem.control import Controller
from stem import SocketError from stem import SocketError
@ -14,6 +15,7 @@ def constant_time_compare(val1, val2):
_builtin_constant_time_compare = getattr(hmac, 'compare_digest', None) _builtin_constant_time_compare = getattr(hmac, 'compare_digest', None)
if _builtin_constant_time_compare is not None: if _builtin_constant_time_compare is not None:
return _builtin_constant_time_compare(val1, val2) return _builtin_constant_time_compare(val1, val2)
len_eq = len(val1) == len(val2) len_eq = len(val1) == len(val2)
if len_eq: if len_eq:
result = 0 result = 0

View File

@ -1,6 +1,7 @@
from __future__ import division from __future__ import division
import os, sys, subprocess, time, hashlib, platform, json, locale, socket, argparse, Queue, inspect, base64, random, functools, logging, ctypes import os, sys, subprocess, time, hashlib, platform, json, locale, socket, argparse, Queue, inspect, base64, random, functools, logging, ctypes, hmac
import stem, stem.control, flask, itsdangerous from itertools import izip
import stem, stem.control, flask
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
import onionshare, onionshare_gui import onionshare, onionshare_gui