Example #1
0
 def keyid(self):
     res = nacl.crypto_generichash(''.join((self.created.isoformat(),
                                             self.valid.isoformat(),
                                             self.mp,
                                             self.sp,
                                             self.cp
                                             )))[:16]
     return ' '.join(split_by_n(binascii.b2a_hex(res).decode("ascii"), 4))
Example #2
0
def load_dh_keychain(infile):
    if not infile or infile == '-':
        fd = sys.stdin
    else:
        fd = open(infile,'r')
    keychain = list(split_by_n(fd.read(), nacl.crypto_scalarmult_curve25519_BYTES))
    if fd != sys.stdin: fd.close()
    return keychain
Example #3
0
 def keyid(self):
     res = nacl.crypto_generichash(''.join((self.created.isoformat(),
                                             self.valid.isoformat(),
                                             self.mp,
                                             self.sp,
                                             self.cp
                                             )))[:16]
     return ' '.join(split_by_n(binascii.b2a_hex(res).decode("ascii"), 4))
Example #4
0
 def accept(self):
     if self.hash in self.tree.common:
         print ' '.join(split_by_n(binascii.hexlify(self.hash),4)),
         line = None
         while line == None:
             try:
                 line = sys.stdin.read()
             except exceptions.IOError:
                 continue
             break
         if not line.strip():
             self.save(self.tree.saved)
             return True
Example #5
0
File: merkle.py Project: stef/pbp
 def accept(self):
     if self.hash in self.tree.common:
         print ' '.join(split_by_n(binascii.hexlify(self.hash), 4)),
         line = None
         while line == None:
             try:
                 line = sys.stdin.read()
             except exceptions.IOError:
                 continue
             break
         if not line.strip():
             self.save(self.tree.saved)
             return True
Example #6
0
            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'))
        if hsum:
            print ' '.join(split_by_n(binascii.hexlify(hsum),4))

def load_key(key):
    # asserts that self is specified
    if not key:
        return None
    if os.path.exists(key):
        with open(key,'r') as fd:
            key = fd.read()
    return key

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")
Example #7
0
File: main.py Project: TLINDEN/pbp
            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)
        if 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'))
        if hsum:
            print ' '.join(split_by_n(binascii.hexlify(hsum),4))

def load_key(key):
    # asserts that self is specified
    if not key:
        return None
    if os.path.exists(key):
        with open(opts.key,'r') as fd:
            key = fd.read()
    return key

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")