def test_simple_dh(self): (exp,pub1) = pbp.dh1_handler() (pub2,secret) = pbp.dh2_handler(pub1) self.assertEquals(pbp.dh3_handler(pub2,exp), secret)
def test_simple_dh(self): (exp, pub1) = pbp.dh1_handler() (pub2, secret) = pbp.dh2_handler(pub1) self.assertEquals(pbp.dh3_handler(pub2, exp), secret)
else: params = dh2_handler(binascii.unhexlify(opts.dh_param)) if params: print "[pbp] shared secret", b85encode(params[1]) print "[pbp] public component", b85encode(params[0]) clearmem(params[0]) clearmem(params[1]) # finish ECDH elif opts.action=='d3': ensure_dhparam_specified(opts) ensure_dhexp_specified(opts) if PITCHFORK and opts.PITCHFORK: pitchfork.init() sec = pitchfork.end_ecdh(opts.dh_param, opts.dh_exp) else: sec = dh3_handler(binascii.unhexlify(opts.dh_param), binascii.unhexlify(opts.dh_exp)) if sec: print "[pbp] shared secret", b85encode(sec) clearmem(sec) # start MPECDH elif opts.action=='ds': ensure_self_specified(opts) ensure_dhpeers_specified(opts) ensure_name_specified(opts) sec = mpecdh_start_handler(opts.name, opts.dh_peers, opts.self, opts.infile, opts.outfile, opts.basedir) if sec: print >>sys.stderr, "[pbp] pushed shared secret, hash", b85encode(nacl.crypto_generichash(sec, outlen=6)) clearmem(sec) sec = None # finish MPECDH
else: params = dh2_handler(binascii.unhexlify(opts.dh_param)) if params: print "shared secret", b85encode(params[1]) print "public component", b85encode(params[0]) clearmem(params[0]) clearmem(params[1]) # finish ECDH elif opts.action=='d3': ensure_dhparam_specified(opts) ensure_dhexp_specified(opts) if PITCHFORK: pitchfork.init() sec = pitchfork.end_ecdh(opts.dh_param, opts.dh_exp) else: sec = dh3_handler(binascii.unhexlify(opts.dh_param), binascii.unhexlify(opts.dh_exp)) if sec: print "shared secret", b85encode(sec) clearmem(sec) # start MPECDH elif opts.action=='ds': ensure_self_specified(opts) ensure_dhpeers_specified(opts) ensure_name_specified(opts) sec = mpecdh_start_handler(opts.name, opts.dh_peers, opts.self, opts.infile, opts.outfile, opts.basedir) if sec: print >>sys.stderr, "pushed shared secret, hash", b85encode(nacl.crypto_generichash(sec, outlen=6)) clearmem(sec) sec = None # finish MPECDH