Beispiel #1
0
 def test_3mpecdh(self):
     publickey.Identity('alice', basedir=self.pbp_path, create=True)
     publickey.Identity('bob', basedir=self.pbp_path, create=True)
     publickey.Identity('carol', basedir=self.pbp_path, create=True)
     pbp.mpecdh_start_handler('1st',
                              3,
                              'alice',
                              '/dev/null',
                              self.tmp_dir + '/step1',
                              basedir=self.pbp_path)
     pbp.mpecdh_start_handler('1st',
                              3,
                              'bob',
                              self.tmp_dir + '/step1',
                              self.tmp_dir + '/step2',
                              basedir=self.pbp_path)
     s1 = pbp.mpecdh_start_handler('1st',
                                   3,
                                   'carol',
                                   self.tmp_dir + '/step2',
                                   self.tmp_dir + '/step3',
                                   basedir=self.pbp_path)
     s2 = pbp.mpecdh_end_handler('1st',
                                 'alice',
                                 self.tmp_dir + '/step3',
                                 self.tmp_dir + '/step4',
                                 basedir=self.pbp_path)
     s3 = pbp.mpecdh_end_handler('1st',
                                 'bob',
                                 self.tmp_dir + '/step4',
                                 self.tmp_dir + '/step5',
                                 basedir=self.pbp_path)
     self.assertEquals(s1, s2)
     self.assertEquals(s2, s3)
Beispiel #2
0
 def test_3mpecdh(self):
     publickey.Identity('alice', basedir=self.pbp_path, create=True)
     publickey.Identity('bob', basedir=self.pbp_path, create=True)
     publickey.Identity('carol', basedir=self.pbp_path, create=True)
     pbp.mpecdh_start_handler('1st', 3, 'alice', '/dev/null', self.tmp_dir+ '/step1', basedir=self.pbp_path)
     pbp.mpecdh_start_handler('1st', 3, 'bob', self.tmp_dir+'/step1', self.tmp_dir+'/step2', basedir=self.pbp_path)
     s1=pbp.mpecdh_start_handler('1st', 3, 'carol', self.tmp_dir+'/step2', self.tmp_dir+'/step3', basedir=self.pbp_path)
     s2=pbp.mpecdh_end_handler('1st', 'alice', self.tmp_dir+'/step3', self.tmp_dir+'/step4', basedir=self.pbp_path)
     s3=pbp.mpecdh_end_handler('1st', 'bob', self.tmp_dir+'/step4', self.tmp_dir+'/step5', basedir=self.pbp_path)
     self.assertEquals(s1,s2)
     self.assertEquals(s2,s3)
Beispiel #3
0
    # 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
    elif opts.action=='de':
        ensure_self_specified(opts)
        ensure_name_specified(opts)
        sec = mpecdh_end_handler(opts.name, 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

    elif opts.action=='R':
        ensure_size_good(opts)
        if PITCHFORK and opts.PITCHFORK:
            pitchfork.init()
            pitchfork.rng(int(opts.size), opts.outfile)
        else:
            random_stream_handler(opts.outfile, opts.size)

    elif opts.action=='h':
        hsum = hash_handler(opts.infile, k=load_key(opts.key), outlen=int(opts.size or '16'))
Beispiel #4
0
    # start ECDH
    elif opts.action=='ds':
        ensure_self_specified(opts)
        ensure_dhparam_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 ECDH
    elif opts.action=='de':
        ensure_self_specified(opts)
        ensure_name_specified(opts)
        sec = mpecdh_end_handler(opts.name, 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

    elif opts.action=='R':
        ensure_size_good(opts)
        random_stream_handler(opts.outfile, opts.size)

def ensure_self_specified(opts):
    # asserts that self is specified
    if not opts.self:
        die("Error: need to specify your own key using the --self param")

def ensure_name_specified(opts):