2016-05-13 34 views
1

Ich habe vor kurzem eine andere Frage, in Bezug auf Python, Kolben mit einer Badsignature-Ausnahme für Sitzungen (https://stackoverflow.com/questions/37158432/python-flask-session-cookie-bad-signature-exception) gestellt, und ich habe mit diesem Problem jetzt für eine Weile gearbeitet, ein anderes Problem gesehen.Python3, hmac gibt falsche Ausgabe zurück ?! ARM71, 32bit

Beim Signieren einer clientseitigen Sitzung für meine Kolbenanwendung wird hmac verwendet, um die Signatur zu hashen. Auf meinem PC funktioniert das gut, aber wenn man dies auf das Embedded-Gerät für diese Anwendung überträgt, schlägt hmac gelegentlich fehl, den Schlüssel zu hashen (falsche Ausgabe), was die Sitzungsdaten ungültig macht.

Ich machte ein kleines Testprogramm, das die hmac.new() & .update() mehrfach (10000) ohne irgendwelche Fehler (auf dem Zielcomputer) laufen ließ. Aber wenn der Anruf innerhalb der Flaschen-Anwendung getätigt wird, tritt der Fehler in ungefähr 60% der Anrufe auf.

Der Anruf wird in der "derive_key" Methode der itsdangerous.py gemacht und es sieht wie folgt aus:

def derive_key(self): 
     """This method is called to derive the key. If you're unhappy with 
     the default key derivation choices you can override them here. 
     Keep in mind that the key derivation in itsdangerous is not intended 
     to be used as a security method to make a complex key out of a short 
     password. Instead you should use large random secret keys. 
     """ 
     salt = want_bytes(self.salt) 
     if self.key_derivation == 'concat': 
      return self.digest_method(salt + self.secret_key).digest() 
     elif self.key_derivation == 'django-concat': 
      return self.digest_method(salt + b'signer' + 
       self.secret_key).digest() 
     elif self.key_derivation == 'hmac': 
      mac = hmac.new(self.secret_key, digestmod=self.digest_method) 
      print("mac1:", binascii.hexlify(mac.digest())) #1 
      mac.update(salt) 
      print("mac2:", binascii.hexlify(mac.digest())) #2 
      return mac.digest() 
     elif self.key_derivation == 'none': 
      return self.secret_key 
     else: 
      raise TypeError('Unknown key derivation method') 

digestmod = hashlib.sha1

Mit dem secret_key = b'testing‘und Salz = b'cookie-session 'die erwartete Ausgabe ist:

mac1: b'6ab6fc891eefd3b78743ea28b1803811561a7c9b' 
mac2: b'd58bd52b4ced54374ea5baca0b6aa52b0e03af74' 

Aber oft unterscheiden sich diese Werte. Ich habe auch gesehen, dass die Ausgabe von Mac1 & Mac2 gleich ist! wie das Salz hat das Ergebnis nicht verändert.

Ich habe auch gefragt, diese Frage hier: https://github.com/pallets/flask/issues/1808

Diese Anwendung wird auf einem ARM7 läuft, 32bit. Alle Bibliotheken, die mit yocto installiert wurden.

UPDATE: Für jeden Aufruf derive_key() Ich drucke auch Salz und Schlüssel: Die Ausgabe für ein paar Anfragen ist die folgende: „OK“

...: OPEN THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: SAVES THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: OPEN THE SESSION  NOT OKAY!! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'\xc8D\xf0\x95\xc5R\x9f\xe3n\xc7\xa2 `7\xa9\xdb\xdd\xd8F\x85' 
...: mac2: b'\x156\xbf\xb6\x97}m\xe9[\xe0\xea\xd15\xb4\xff\x00\xf9\x14B\x0c' 
...: .-.-.-.-.-.-. 
...: SAVES THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: OPEN THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: SAVES THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: OPEN THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: SAVES THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: OPEN THE SESSION  NOT OKAY!! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'D\xdaR}\xa0\xf2\x9awpP\xa0\x018b\xfcfH}\xcau' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: SAVES THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: OPEN THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: SAVES THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: OPEN THE SESSION  NOT OKAY!! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'=\xcc\x01\xee"\x0ed\xde\xf4z\run\rMm\x98\xcb\x0e\xba' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: SAVES THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: OPEN THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 
...: SAVES THE SESSION  OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
...: mac2: b'\xd5\x8b\xd5+L\xedT7N\xa5\xba\xca\x0bj\xa5+\x0e\x03\xaft' 
...: .-.-.-.-.-.-. 

Ich fügte hinzu, die und "NICHT OKAY!" damit Sie leichter sehen können, welche Ausführungen fehlgeschlagen sind.

(ich sehe auch, dass es in diesem Beispiel, schlägt nicht mehr als 60% ist.)

In der Ausgabe oben, nur nicht die "Open Session" -Event. Also versuchte ich es noch einmal zu sehen, ob es nur dann, wenn die Sitzung zu speichern, aber es passiert für Save-Sitzung auch ..

...: SAVES THE SESSION  NOT OK! 
...: DERIVE KEY: 
...: Salt: b'cookie-session' 
...: Key: b'testing' 
...: mac1: b'\xc8D\xf0\x95\xc5R\x9f\xe3n\xc7\xa2 `7\xa9\xdb\xdd\xd8F\x85' 
...: mac2: b'\xc8D\xf0\x95\xc5R\x9f\xe3n\xc7\xa2 `7\xa9\xdb\xdd\xd8F\x85' 

ich endlich ein kleines Beispielprogramm gefunden, die den Fehler wiedergibt.

#!/usr/bin/env python 

async_mode = "eventlet" 

if async_mode is None: 
    try: 
     import eventlet 
     async_mode = 'eventlet' 
    except ImportError: 
     pass 

    if async_mode is None: 
     try: 
      from gevent import monkey 
      async_mode = 'gevent' 
     except ImportError: 
      pass 

    if async_mode is None: 
     async_mode = 'threading' 

    print('async_mode is ' + async_mode) 

if async_mode == 'eventlet': 
    import eventlet 
    eventlet.monkey_patch() 
elif async_mode == 'gevent': 
    from gevent import monkey 
    monkey.patch_all() 

import hmac 
import hashlib 
import time 
from threading import Thread 
thread = None 


def background_thread(): 
    time.sleep(0.5) 
    error_mac = "" 
    while True: 
     error_mac = "" 
     time.sleep(0.1) 
     counter = 0 
     for i in range(0, 40): 
      time.sleep(0.001) 
      mac = hmac.new(b'testing', digestmod=hashlib.sha1).digest() # == b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b': 

      if not mac == b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b': 
       counter = counter + 1 
       error_mac = mac 
     if error_mac: 
      print("Example of the wrong hmacs calculated:") 
      print(error_mac) 
      print("--------------------------------------") 
     print("{} - {}".format(time.time(), counter)) 

def index(): 
    global thread 
    if thread is None: 
     thread = Thread(target=background_thread) 
     thread.daemon = True 
     thread.start() 

    for i in range(0,40): 
     print(hmac.new(b'testing', digestmod=hashlib.sha1).digest()) 
    thread.join() 
    return "ok" 


if __name__ == '__main__': 
    index() 

Normalerweise, wenn ein Fehler des ersten 20-Hashes ist (durch den Haupt-Thread erstellt wird) auch der zweite Thread die falsche Hash erhalten. Wenn kein Fehler im Hauptthread auftritt und der zweite Thread nur timestamp und Nullen ausgibt, starten Sie das Programm neu.

Es async_mode ist auf "Threading" eingestellt alles funktioniert gut. Aber wenn er auf "gevent" oder "eventlet" gesetzt wird, tritt dieser Fehler auf.

Ausgang mit Fehlern:

b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
b'D\xb4V\r9$gy\xe1 \x13\xd8\xc4f\x93O\x9e\xfa\x02\xff' 
Example of the wrong hmacs calculated: 
b"\x19\xd2}YU\xfeyX\x87\xee\xf5\x96\x94\xc1'\xa3tP\xb3\x96" 
-------------------------------------- 
1463462121.3955774 - 40 
Example of the wrong hmacs calculated: 
b"\x19\xd2}YU\xfeyX\x87\xee\xf5\x96\x94\xc1'\xa3tP\xb3\x96" 
-------------------------------------- 
1463462121.6040413 - 40 
Example of the wrong hmacs calculated: 
b"\x19\xd2}YU\xfeyX\x87\xee\xf5\x96\x94\xc1'\xa3tP\xb3\x96" 
-------------------------------------- 
1463462121.8342147 - 40 
Example of the wrong hmacs calculated: 
b"\x19\xd2}YU\xfeyX\x87\xee\xf5\x96\x94\xc1'\xa3tP\xb3\x96" 

Ausgang ohne Fehler.

b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
b'j\xb6\xfc\x89\x1e\xef\xd3\xb7\x87C\xea(\xb1\x808\x11V\x1a|\x9b' 
1463462453.3856905 - 0 
1463462453.5910842 - 0 
1463462453.8242626 - 0 
1463462454.0677884 - 0 
1463462454.2900438 - 0 
1463462454.5460255 - 0 
1463462454.7883186 - 0 

(auf meiner Ubuntu-Maschine Dieses Beispiel funktioniert perfeclty Es ist nur auf dem ARM7-Gerät, das wir dieses Problem haben ..)

+0

Können Sie ein kürzeres * in sich abgeschlossenes * Beispiel erstellen. Sie haben eine * Methode * mit implizitem 'self', aber ich sehe nirgendwo eine Klassendefinition! –

+0

Ist es wirklich, dass der HMAC b0rken ist, oder dass Sie das Geheimnis oft initialisieren? –

+0

Wahrscheinlich ist Ihr Python b0rken, oder openssl ist b0rken. Verwendet es OpenSSL auf dieser Plattform? –

Antwort

0

Wenn ich die Argumente geändert alle Patch gevetn:

... 
elif async_mode == 'gevent': 
    from gevent import monkey 
    monkey.patch_all(ssl=False) 
... 

Es scheint zu funktionieren.