def smsetup(sm): # this is Oakley group 5, actually. sm.DH = DH.construct((241031242692103258855207602219756607485695054850245994265416941958108831682612228890093858261341614673227141477904012196503648957050582631942730706805009223062734745341073406696246014589361659774041027169249453200378729434170325843778659198143763193776859869524088940195577346119843545301547043747207749969763750084308926339295559968882457872412993810129130294592999947926365264059284647209730384947211681434464714438488520940127459844288859336526896320919633919, 2)) sm.DH.gen_key(RandomPool.get_bytes) sm.DH.groupid = 3 sm.localHIT = sm.HI.HIT127() sm.trace = 1
def setUp(self): self.SM = StateMachine(state=E0,HI=testHI) self.SM.setFQDN('1234') self.SM.localHIT = self.SM.HI.HIT127() self.SM.remoteHIT = '\xde\xad\xbe\xef\xde\xad\xbe\xef' '\xde\xad\xbe\xef\xde\xad\xbe\xef' self.SM.DH = DH.construct((0x00f488fd584e49dbcd20b49de49107366b336c380d451d0f7c88b31c7c5b2d8ef6f3c923c043f0a55b188d8ebb558cb85d38d334fd7c175743a31d186cde33212cb52aff3ce1b1294018118d7c84a70a72d686c40319c807297aca950cd9969fabd00a509b0246d3083d66a45d419f9c7cbd894b221926baaba25ec355e92f78c7, 2, 0x5a84f4b9704f010705aaf17cb14b718ad484c253bae508685583276d22e4a089bcb4e35067386250a1462a529073820f3effdc5edc39107198429fbc482c79ab07df798bc23c7517740974c542aec2b1666b59f48d06684e855e32d2e761dc8c482be9aba1bc65cbf84c6b42a11eda1a511f402c17407a31ecfeead7b48054ff, 0x15ae0584d67460bcec34efe7c32bf298a62adad0f53a00db896239e3f8949845064dcef1ad434f24237cac1ae1ea137ab6ad0234e7c742390f8d4c9f6cd8994154ba9c9b9bde38670952b5ab776c137dca1f0bdea0e951b996403fb5452b074987c6272c5099ffb97c8c87abf3f61ba346d122472e45d05f4072d8437da13bb))
def __init__(self, host, queue, interfaces, hit='', fqdn=''): #print 'New StateMachine:', fqdn, repr(hit), repr(self), self.canpiggyback HIPState.StateMachine.__init__(self, state=HIPState.E0, HI=host.hi) ## # this is MODP group 5, actually. ## self.DH = DH.construct((241031242692103258855207602219756607485695054850245994265416941958108831682612228890093858261341614673227141477904012196503648957050582631942730706805009223062734745341073406696246014589361659774041027169249453200378729434170325843778659198143763193776859869524088940195577346119843545301547043747207749969763750084308926339295559968882457872412993810129130294592999947926365264059284647209730384947211681434464714438488520940127459844288859336526896320919633919, ## 2)) self.DH = DH.construct(( 0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF, 2)) self.DH.groupid = 3 self.localHIT = self.HI.HIT127() #self.localHIT = self.HI.HIT64(unhexlify('9e800000000000000000000000000000')) self.DH.gen_key(RandomPool.get_bytes) self.setFQDN(fqdn) self.remoteHIT = hit self.OutQueue = queue self.piggyback = 0 self.LSIcallback = host.LSIcallback self.lifetime = 9000 #seconds self.rekey = 6000 #seconds self.lastused = time.time() self.lastkeyed = time.time() self.rekeying = 0 self.trace = 1 self.interfaces = interfaces self.setLocalIPs(self.interfaces) self.useIPv6 = 0 def cb(host, m): k = Future(m.DH.gen_key(RandomPool.get_bytes)) if host.useIPv6: m.useIPv6 = host.useIPv6 m.localESP.remoteIPv6addr = m.remoteHI.HITv6link() m.localESP.localIPv6addr = host.hi.HITv6link() m.remoteESP.remoteIPv6addr = m.localESP.remoteIPv6addr m.remoteESP.localIPv6addr = m.localESP.localIPv6addr self.E3callback = curryl(cb, host) self.callbacks[HIPState.E3] = self.E3callback