File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66from jose .constants import ALGORITHMS
77from jose .exceptions import JWKError
88from jose .utils import base64url_decode , base64url_encode
9- from jose .utils import constant_time_string_compare
109from jose .backends .base import Key
1110
1211try :
@@ -135,7 +134,7 @@ def sign(self, msg):
135134 return hmac .new (self .prepared_key , msg , self .hash_alg ).digest ()
136135
137136 def verify (self , msg , sig ):
138- return constant_time_string_compare (sig , self .sign (msg ))
137+ return hmac . compare_digest (sig , self .sign (msg ))
139138
140139 def to_dict (self ):
141140 return {
Original file line number Diff line number Diff line change @@ -108,27 +108,3 @@ def timedelta_total_seconds(delta):
108108 delta (timedelta): A timedelta to convert to seconds.
109109 """
110110 return delta .days * 24 * 60 * 60 + delta .seconds
111-
112-
113- def constant_time_string_compare (a , b ):
114- """Helper for comparing string in constant time, independent
115- of the python version being used.
116-
117- Args:
118- a (str): A string to compare
119- b (str): A string to compare
120- """
121-
122- try :
123- return hmac .compare_digest (a , b )
124- except AttributeError :
125-
126- if len (a ) != len (b ):
127- return False
128-
129- result = 0
130-
131- for x , y in zip (a , b ):
132- result |= ord (x ) ^ ord (y )
133-
134- return result == 0
You can’t perform that action at this time.
0 commit comments